MailPoet Newsletters (Previous) - Version 2.6

Version Description

  • 2014-03-18 =
  • This is the juiciest of all releases. Ready?
  • a new statistics dashboard in Premium. The beauty of the big picture
  • add more fields in your subscription forms, like phone number, address, or whatever you like
  • display an archive of your past newsletters in a page with a shortcode. Find it in the settings
  • display your posts' author names and categories in the newsletter editor
  • insert several posts at once in the editor, instead of one at a time. Time saver
  • a dozen new display options when you drop your posts in the newsletter, for the control freaks
  • find a list of add-ons in the settings. Plug your MailPoet with your other favorite plugins, like Gravity Forms
  • select your own WordPress pages for your confirmation and unsubscribe pages
  • use your MailPoet shortcodes in your confirmation emails, like [user:firstname | default:reader]
  • MailPoet now abides to German privacy laws. Guten tag Alex!
  • the browser version of your newsletter now include the Google Analytics tracking code (Premium)
  • right to left language improvements
  • our user interface is now styled for 3.8
  • needless to say, hundreds of mini improvements
  • we hand over to you 6 months of hard work. Enjoy!
Download this release

Release Info

Developer wysija
Plugin Icon 128x128 MailPoet Newsletters (Previous)
Version 2.6
Comparing to
See all releases

Code changes from version 2.6.8 to 2.6

Files changed (65) hide show
  1. add-ons/add-ons-list.php +120 -118
  2. add-ons/add-ons.php +164 -155
  3. classes/WJ_Export.php +194 -205
  4. classes/WJ_Field.php +257 -248
  5. classes/WJ_Import.php +9 -12
  6. classes/WJ_Stats.php +6 -6
  7. classes/WJ_Upgrade.php +9 -51
  8. controllers/ajax/campaigns.php +951 -998
  9. controllers/ajax/statistics.php +72 -81
  10. controllers/ajax/tmce.php +139 -138
  11. controllers/back.php +1 -1
  12. controllers/back/campaigns.php +2730 -2744
  13. controllers/back/config.php +8 -5
  14. controllers/back/statistics.php +169 -190
  15. controllers/back/subscribers.php +8 -41
  16. controllers/front/stats.php +4 -25
  17. core/base.php +113 -230
  18. core/model.php +1032 -1028
  19. core/module/module.php +38 -38
  20. core/view.php +1 -7
  21. css/admin-campaigns-dividers.css +1 -1
  22. css/admin-campaigns-medias.css +1 -1
  23. css/admin-campaigns-viewstats.css +1 -1
  24. css/admin-campaigns.css +1 -1
  25. css/admin-config.css +1 -1
  26. css/admin-global.css +1 -1
  27. css/admin-premium.css +1 -1
  28. css/admin-statistics.css +1 -1
  29. css/admin.css +1 -1
  30. css/adminPopup.css +1 -1
  31. css/qtip2/jquery.qtip.min.css +2 -0
  32. css/rtl.css +1 -1
  33. css/select2/select2.css +0 -615
  34. css/tmce/editor.css +0 -2317
  35. css/vendor/bootstrap.tooltip.css +0 -101
  36. css/wysija-editor.css +1 -1
  37. css/wysija-form-editor.css +1 -1
  38. docs/german-disclaimer.md +0 -4
  39. helpers/articles.php +12 -21
  40. helpers/back.php +44 -52
  41. helpers/backloader.php +281 -397
  42. helpers/bounce.php +2 -1
  43. helpers/campaigns.php +44 -48
  44. helpers/email.php +2 -2
  45. helpers/forms.php +239 -245
  46. helpers/front.php +12 -8
  47. helpers/install.php +13 -16
  48. helpers/licence.php +1 -1
  49. helpers/mailer.php +3 -6
  50. helpers/queue.php +9 -14
  51. helpers/quick_html.php +36 -36
  52. helpers/render_engine.php +3 -22
  53. helpers/server.php +4 -4
  54. helpers/update.php +873 -926
  55. helpers/user.php +14 -13
  56. helpers/wj_engine.php +1454 -1615
  57. helpers/wp_tools.php +335 -322
  58. img/controls/image-placeholder.png +0 -0
  59. img/select2/select2-spinner.gif +0 -0
  60. img/select2/select2.png +0 -0
  61. img/select2/select2x2.png +0 -0
  62. index.php +3 -3
  63. js/admin-campaigns-articles.js +1 -1
  64. js/admin-campaigns-autopost.js +1 -1
  65. js/admin-campaigns-editDetails.js +1 -1
add-ons/add-ons-list.php CHANGED
@@ -8,46 +8,30 @@ function add_ons_list(){
8
  'name' => 'WooCommerce: Subscribe on Checkout',
9
  'search' => 'MailPoet WooCommerce Add-on',
10
  'thumbnail' => 'woocommerce.png',
11
- 'description' => __( 'Add a checkbox on checkout page for your customers to subscribe to your MailPoet newsletters.', WYSIJA ),
12
  'plugin_url' => 'mailpoet-woocommerce-addon/mailpoet-woocommerce-addon.php',
13
  'version' => '1.0.2',
14
  'config_url' => 'admin.php?page=woocommerce_settings&tab=mailpoet',
15
- 'official' => true,
16
- 'on_wordpress.org' => true,
17
- 'free' => true,
18
- 'service' => false,
19
  'requires' => 'woocommerce/woocommerce.php',
20
  'requires_name' => 'WooCommerce',
21
  ),
22
 
23
- array(
24
- 'name' => 'Autoresponders for WooCommerce Products',
25
- 'search' => 'Autoresponders for WooCommerce Products',
26
- 'thumbnail' => 'woocommerce.png',
27
- 'description' => __( 'Decide which emails a new customer gets automatically, based on the product he just purchased. This a Premium add-on for WooCommerce.', WYSIJA ),
28
- 'review' => '',
29
- 'plugin_url' => '',
30
- 'author_url' => 'http://clicky.me/woocommerce-autoresponder',
31
- 'purchase_url' => 'http://clicky.me/woocommerce-autoresponder',
32
- 'version' => '1.0.1',
33
- 'official' => true,
34
- 'on_wordpress.org' => false,
35
- 'free' => false,
36
- 'service' => false,
37
- ),
38
-
39
  array(
40
  'name' => 'Jigoshop: Subscribe on Checkout',
41
  'search' => 'MailPoet Jigoshop Add-on',
42
  'thumbnail' => 'jigoshop.png',
43
- 'description' => __( 'Add a checkbox on checkout page for your customers to subscribe to your MailPoet newsletters.', WYSIJA ),
44
  'plugin_url' => 'mailpoet-jigoshop-addon/mailpoet-jigoshop-addon.php',
45
  'version' => '1.0.3',
46
  'config_url' => 'admin.php?page=jigoshop_settings&tab=mailpoet',
47
- 'official' => true,
48
- 'on_wordpress.org' => true,
49
- 'free' => true,
50
- 'service' => false,
51
  'requires' => 'jigoshop/jigoshop.php',
52
  'requires_name' => 'Jigoshop',
53
  ),
@@ -56,13 +40,13 @@ function add_ons_list(){
56
  'name' => 'Gravity Forms: Subscribe Add-on',
57
  'search' => 'MailPoet Gravity Forms Add-on',
58
  'thumbnail' => 'gravity-forms.png',
59
- 'description' => __( 'Add a new field to add to your forms so your visitors can subscriber to your MailPoet newsletters.', WYSIJA ),
60
  'plugin_url' => 'mailpoet-gravity-forms-addon/mailpoet-gravity-forms-addon.php',
61
  'version' => '1.0.0',
62
- 'official' => true,
63
- 'on_wordpress.org' => true,
64
- 'free' => true,
65
- 'service' => false,
66
  'requires' => 'gravityforms/gravityforms.php',
67
  'requires_name' => 'Gravity Forms',
68
  ),
@@ -71,14 +55,14 @@ function add_ons_list(){
71
  'name' => 'WP e-Commerce: Subscribe on Checkout',
72
  'search' => 'MailPoet WP e-Commerce Add-on',
73
  'thumbnail' => 'wp-e-commerce.png',
74
- 'description' => __( 'Add a checkbox on checkout page for your customers to subscribe to your MailPoet newsletters.', WYSIJA ),
75
  'plugin_url' => 'mailpoet-wp-ecommerce-addon/mailpoet-wp-ecommerce-addon.php',
76
  'version' => '1.0.0',
77
  'config_url' => 'edit.php?post_type=wpsc-product&page=mailpoet',
78
- 'official' => true,
79
- 'on_wordpress.org' => true,
80
- 'free' => true,
81
- 'service' => false,
82
  'requires' => 'wp-e-commerce/wp-shopping-cart.php',
83
  'requires_name' => 'WP e-Commerce',
84
  ),
@@ -87,13 +71,13 @@ function add_ons_list(){
87
  'name' => 'Restrict Content Pro: Registration Add-on',
88
  'search' => 'Restrict Content Pro Wysija',
89
  'thumbnail' => 'pippins.png',
90
- 'description' => __( 'Add a checkbox on the registration form of this plugin so your new users join a list of your choice.', WYSIJA ),
91
  'plugin_url' => 'restrict-content-pro-wysija/rcp-wysija.php',
92
  'version' => '1.0',
93
- 'official' => true,
94
- 'on_wordpress.org' => true,
95
- 'free' => true,
96
- 'service' => false,
97
  'requires' => 'restrict-content-pro/restrict-content-pro.php',
98
  'requires_name' => 'Restrict Content Pro',
99
  ),
@@ -102,14 +86,14 @@ function add_ons_list(){
102
  'name' => 'Contact Form 7: MailPoet Add-on',
103
  'search' => 'MailPoet Contact Form 7',
104
  'thumbnail' => 'cf7.png',
105
- 'description' => __( 'Add a checkbox in your forms, and choose which lists the user gets added to.', WYSIJA ),
106
  'plugin_url' => 'mailpoet-contact-form-7/mailpoet-contact-form-7.php',
107
  'author_url' => '',
108
  'version' => '1.0.0',
109
- 'official' => true,
110
- 'on_wordpress.org' => true,
111
- 'free' => true,
112
- 'service' => false,
113
  'requires' => 'contact-form-7/wp-contact-form-7.php',
114
  'requires_name' => 'Contact Form 7',
115
  ),
@@ -118,15 +102,15 @@ function add_ons_list(){
118
  'name' => 'WangGuard: MailPoet Connector',
119
  'search' => 'WangGuard Wysija Newsletter Connector',
120
  'thumbnail' => 'wangguard.png',
121
- 'description' => __( 'Stop fake signups by robots with WangGuard, a free white listing service, and plugin.', WYSIJA ),
122
- 'review' => __( 'If you have this problem, then this is your solution. Totally free too.', WYSIJA ),
123
  'plugin_url' => 'wangguard-wysija-newsletter-connector/wangguard-wysija.php',
124
  'author_url' => 'http://clicky.me/wangguard',
125
  'version' => '1.0.0',
126
- 'official' => true,
127
- 'on_wordpress.org' => true,
128
- 'free' => true,
129
- 'service' => false,
130
  'requires' => '',
131
  ),
132
 
@@ -134,29 +118,29 @@ function add_ons_list(){
134
  'name' => 'Leaky Paywall: MailPoet Add-on',
135
  'search' => 'Leaky Paywall: MailPoet Add-on',
136
  'thumbnail' => 'leakypw.png',
137
- 'description' => __( 'Leaky Paywall is a Premium plugin to put content behind a paywall. This add-on manages your customers\' customers subscriptions.', WYSIJA ),
138
  'plugin_url' => 'leaky-paywall-mail-poet/issuem-leaky-paywall-mailpoet.php',
139
  'author_url' => 'http://clicky.me/leakypw',
140
  'version' => '1.0.0',
141
- 'official' => true,
142
- 'on_wordpress.org' => true,
143
- 'free' => true,
144
- 'service' => false,
145
  ),
146
 
147
  array(
148
  'name' => 'GetConversion: Bar and Box Forms Add-on',
149
  'search' => 'GC MailPoet EX',
150
  'thumbnail' => 'getconversion.png',
151
- 'description' => __( 'Put a form in a top or bottom bar of your site, or in a nice box within your posts with GetConversion\'s free plugins. Connect them to MailPoet with this add-on.<br/></br>Get 30% off the Premium version of their add-on by clicking <a href="http://getconversion.com/products/gc-mailpoet-ex-pro/?coupon=MAILPOET">here</a>.', WYSIJA ),
152
- 'review' => __( 'Try it yourself, we were impressed by the free versions.', WYSIJA ),
153
  'plugin_url' => 'gc-message-bar/main.php',
154
  'author_url' => 'http://clicky.me/GC-add-on',
155
  'version' => '1.0.0',
156
- 'official' => true,
157
- 'on_wordpress.org' => true,
158
- 'free' => true,
159
- 'service' => false,
160
  ),
161
 
162
  /* Below is the list of services that work with MailPoet */
@@ -165,34 +149,34 @@ function add_ons_list(){
165
  'name' => 'OptinMonster: Slick Forms',
166
  'search' => 'OptinMonster: slick forms',
167
  'thumbnail' => 'optinmonster.png',
168
- 'description' => __( 'Put a subscription form in a popup, footer bar or slide-in to add subscribers with this Premium plugin.', WYSIJA ),
169
- 'review' => __( 'The authors have done a pretty awesome job.', WYSIJA ),
170
  'plugin_url' => '',
171
  'author_url' => 'http://clicky.me/optinmonsteraddon',
172
  'purchase_url' => '',
173
  'version' => '',
174
- 'official' => false,
175
- 'on_wordpress.org' => false,
176
- 'free' => false,
177
- 'service' => true,
178
- 'premium_offer' => __( 'Premium users save 20% with this coupon: MP20', WYSIJA ),
179
  ),
180
 
181
  array(
182
  'name' => 'Pippity: Form in a Popup',
183
  'search' => 'Pippity: form in a popup',
184
  'thumbnail' => 'pippity.png',
185
- 'description' => __( 'This Premium plugin allows you to add a MailPoet form in a popup.', WYSIJA ),
186
- 'review' => __( 'You\'ll need to know CSS to design it to your taste.', WYSIJA ),
187
  'plugin_url' => '',
188
  'author_url' => 'http://clicky.me/pippity',
189
  'purchase_url' => '',
190
  'version' => '',
191
- 'official' => false,
192
- 'on_wordpress.org' => false,
193
- 'free' => false,
194
- 'service' => true,
195
- 'premium_offer' => __( 'Premium users save 25% with this coupon: mailpoet25', WYSIJA ),
196
  ),
197
 
198
 
@@ -200,16 +184,16 @@ function add_ons_list(){
200
  'name' => 'Hybrid Connect: Forms and Facebook',
201
  'search' => 'Hybrid Connect: forms and Facebook',
202
  'thumbnail' => 'hybrid-connect.png',
203
- 'description' => __( 'This Premium plugin allows you to add MailPoet\'s forms in many places, and in Facebook.', WYSIJA ),
204
- 'review' => __( 'Very powerful, if not a quirky user interface.', WYSIJA ),
205
  'plugin_url' => '',
206
  'author_url' => 'http://clicky.me/hybrid-connect',
207
  'purchase_url' => '',
208
  'version' => '',
209
- 'official' => false,
210
- 'on_wordpress.org' => false,
211
- 'free' => false,
212
- 'service' => true,
213
  'premium_offer' => '',
214
  ),
215
 
@@ -217,16 +201,16 @@ function add_ons_list(){
217
  'name' => 'Magic Action Box: Pretty forms in post',
218
  'search' => 'Magic Action Box: pretty forms in post',
219
  'thumbnail' => 'magic-action-box.png',
220
- 'description' => __( 'This free plugin allows you to design and position a form at the beginning or bottom of a post.', WYSIJA ),
221
- 'review' => __( 'It\'s free, and has proven popular with our users.', WYSIJA ),
222
  'plugin_url' => '',
223
  'author_url' => 'http://clicky.me/magic-action-box',
224
  'purchase_url' => '',
225
  'version' => '',
226
- 'official' => false,
227
- 'on_wordpress.org' => false,
228
- 'free' => false,
229
- 'service' => true,
230
  'premium_offer' => '',
231
  ),
232
 
@@ -234,16 +218,16 @@ function add_ons_list(){
234
  'name' => 'Optin Revolution: Popup form',
235
  'search' => 'Optin Revolution: popup form',
236
  'thumbnail' => 'optin-revolution.png',
237
- 'description' => __( 'This free plugin allows you to put a form in a popup, that\'s it.', WYSIJA ),
238
- 'review' => __( 'This is the free version of a more powerful Premium version.', WYSIJA ),
239
  'plugin_url' => '',
240
  'author_url' => 'http://clicky.me/optin-revolution',
241
  'purchase_url' => '',
242
  'version' => '',
243
- 'official' => false,
244
- 'on_wordpress.org' => false,
245
- 'free' => false,
246
- 'service' => true,
247
  'premium_offer' => '',
248
  ),
249
 
@@ -251,33 +235,33 @@ function add_ons_list(){
251
  'name' => 'Ultimate Coming Soon Page',
252
  'search' => 'Ultimate Coming Soon Page',
253
  'thumbnail' => 'ultimate-coming-soon.png',
254
- 'description' => __( 'Your new site is not yet launched? Put a coming soon page with a form to capture emails with this Premium plugin.', WYSIJA ),
255
- 'review' => __( 'A well designed plugin for a simple idea.', WYSIJA ),
256
  'plugin_url' => '',
257
  'author_url' => 'http://clicky.me/coming-soon',
258
  'purchase_url' => '',
259
  'version' => '',
260
- 'official' => false,
261
- 'on_wordpress.org' => false,
262
- 'free' => false,
263
- 'service' => true,
264
- 'premium_offer' => __( 'Premium users save 20% with this coupon: MAILPOET20', WYSIJA ),
265
  ),
266
 
267
  array(
268
  'name' => 'Plugmatter: form below your header',
269
  'search' => 'Plugmatter',
270
  'thumbnail' => 'plugmatter.png',
271
- 'description' => __( 'This Premium plugin allows you to put a pretty form right below the header. Nothing more, nothing less.', WYSIJA ),
272
  'review' => '',
273
  'plugin_url' => '',
274
  'author_url' => 'http://clicky.me/plugmatter',
275
  'purchase_url' => '',
276
  'version' => '',
277
- 'official' => false,
278
- 'on_wordpress.org' => false,
279
- 'free' => false,
280
- 'service' => true,
281
  'premium_offer' => '',
282
  ),
283
 
@@ -285,16 +269,16 @@ function add_ons_list(){
285
  'name' => 'EDD: MailPoet: Subscribe on Checkout',
286
  'search' => 'Easy Digital Downloads - MailPoet',
287
  'thumbnail' => 'easy-digital-downloads.png',
288
- 'description' => __( 'A checkbox is added as option for your customers to signup for your newsletter while purchasing from your digital store.', WYSIJA ),
289
  'review' => '',
290
  'plugin_url' => '',
291
  'author_url' => 'http://clicky.me/easy-digital-downloads',
292
  'purchase_url' => 'http://clicky.me/easy-digital-downloads',
293
  'version' => '1.1.2',
294
- 'official' => false,
295
- 'on_wordpress.org' => false,
296
- 'free' => false,
297
- 'service' => false,
298
  'requires' => 'easy-digital-downloads/easy-digital-downloads.php',
299
  'requires_name' => 'Easy Digital Downloads',
300
  'premium_offer' => '',
@@ -304,21 +288,39 @@ function add_ons_list(){
304
  'name' => 'Ninja Forms: Subscribe Add-on',
305
  'search' => 'Ninja Forms: Subscribe Add-on',
306
  'thumbnail' => 'ninja-forms.png',
307
- 'description' => __( 'Quickly create newsletter signup forms for your MailPoet mailing lists using the power and flexibility that Ninja Forms provides.', WYSIJA ),
308
  'review' => '',
309
  'plugin_url' => 'ninja-forms-mailpoet/nf-mailpoet.php',
310
  'author_url' => 'http://clicky.me/ninja-forms',
311
  'purchase_url' => 'http://clicky.me/ninja-forms',
312
  'version' => '1.0.1',
313
- 'official' => false,
314
- 'on_wordpress.org' => false,
315
- 'free' => true,
316
- 'service' => false,
317
  'requires' => 'ninja-forms/ninja-forms.php',
318
  'requires_name' => 'Ninja Forms',
319
  'premium_offer' => '',
320
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
  );
322
 
323
  return $available_add_ons;
324
- }
 
8
  'name' => 'WooCommerce: Subscribe on Checkout',
9
  'search' => 'MailPoet WooCommerce Add-on',
10
  'thumbnail' => 'woocommerce.png',
11
+ 'description' => __('Add a checkbox on checkout page for your customers to subscribe to your MailPoet newsletters.', WYSIJA),
12
  'plugin_url' => 'mailpoet-woocommerce-addon/mailpoet-woocommerce-addon.php',
13
  'version' => '1.0.2',
14
  'config_url' => 'admin.php?page=woocommerce_settings&tab=mailpoet',
15
+ 'official' => 'yes',
16
+ 'on_wordpress.org' => 'yes',
17
+ 'free' => 'yes',
18
+ 'service' => 'no',
19
  'requires' => 'woocommerce/woocommerce.php',
20
  'requires_name' => 'WooCommerce',
21
  ),
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  array(
24
  'name' => 'Jigoshop: Subscribe on Checkout',
25
  'search' => 'MailPoet Jigoshop Add-on',
26
  'thumbnail' => 'jigoshop.png',
27
+ 'description' => __('Add a checkbox on checkout page for your customers to subscribe to your MailPoet newsletters.', WYSIJA),
28
  'plugin_url' => 'mailpoet-jigoshop-addon/mailpoet-jigoshop-addon.php',
29
  'version' => '1.0.3',
30
  'config_url' => 'admin.php?page=jigoshop_settings&tab=mailpoet',
31
+ 'official' => 'yes',
32
+ 'on_wordpress.org' => 'yes',
33
+ 'free' => 'yes',
34
+ 'service' => 'no',
35
  'requires' => 'jigoshop/jigoshop.php',
36
  'requires_name' => 'Jigoshop',
37
  ),
40
  'name' => 'Gravity Forms: Subscribe Add-on',
41
  'search' => 'MailPoet Gravity Forms Add-on',
42
  'thumbnail' => 'gravity-forms.png',
43
+ 'description' => __('Add a new field to add to your forms so your visitors can subscriber to your MailPoet newsletters.', WYSIJA),
44
  'plugin_url' => 'mailpoet-gravity-forms-addon/mailpoet-gravity-forms-addon.php',
45
  'version' => '1.0.0',
46
+ 'official' => 'yes',
47
+ 'on_wordpress.org' => 'yes',
48
+ 'free' => 'yes',
49
+ 'service' => 'no',
50
  'requires' => 'gravityforms/gravityforms.php',
51
  'requires_name' => 'Gravity Forms',
52
  ),
55
  'name' => 'WP e-Commerce: Subscribe on Checkout',
56
  'search' => 'MailPoet WP e-Commerce Add-on',
57
  'thumbnail' => 'wp-e-commerce.png',
58
+ 'description' => __('Add a checkbox on checkout page for your customers to subscribe to your MailPoet newsletters.', WYSIJA),
59
  'plugin_url' => 'mailpoet-wp-ecommerce-addon/mailpoet-wp-ecommerce-addon.php',
60
  'version' => '1.0.0',
61
  'config_url' => 'edit.php?post_type=wpsc-product&page=mailpoet',
62
+ 'official' => 'yes',
63
+ 'on_wordpress.org' => 'yes',
64
+ 'free' => 'yes',
65
+ 'service' => 'no',
66
  'requires' => 'wp-e-commerce/wp-shopping-cart.php',
67
  'requires_name' => 'WP e-Commerce',
68
  ),
71
  'name' => 'Restrict Content Pro: Registration Add-on',
72
  'search' => 'Restrict Content Pro Wysija',
73
  'thumbnail' => 'pippins.png',
74
+ 'description' => __('Add a checkbox on the registration form of this plugin so your new users join a list of your choice.', WYSIJA),
75
  'plugin_url' => 'restrict-content-pro-wysija/rcp-wysija.php',
76
  'version' => '1.0',
77
+ 'official' => 'yes',
78
+ 'on_wordpress.org' => 'yes',
79
+ 'free' => 'yes',
80
+ 'service' => 'no',
81
  'requires' => 'restrict-content-pro/restrict-content-pro.php',
82
  'requires_name' => 'Restrict Content Pro',
83
  ),
86
  'name' => 'Contact Form 7: MailPoet Add-on',
87
  'search' => 'MailPoet Contact Form 7',
88
  'thumbnail' => 'cf7.png',
89
+ 'description' => __('Add a checkbox in your forms, and choose which lists the user gets added to.', WYSIJA),
90
  'plugin_url' => 'mailpoet-contact-form-7/mailpoet-contact-form-7.php',
91
  'author_url' => '',
92
  'version' => '1.0.0',
93
+ 'official' => 'yes',
94
+ 'on_wordpress.org' => 'yes',
95
+ 'free' => 'yes',
96
+ 'service' => 'no',
97
  'requires' => 'contact-form-7/wp-contact-form-7.php',
98
  'requires_name' => 'Contact Form 7',
99
  ),
102
  'name' => 'WangGuard: MailPoet Connector',
103
  'search' => 'WangGuard Wysija Newsletter Connector',
104
  'thumbnail' => 'wangguard.png',
105
+ 'description' => __('Stop fake signups by robots with WangGuard, a free white listing service, and plugin.', WYSIJA),
106
+ 'review' => __('If you have this problem, then this is your solution. Totally free too.', WYSIJA),
107
  'plugin_url' => 'wangguard-wysija-newsletter-connector/wangguard-wysija.php',
108
  'author_url' => 'http://clicky.me/wangguard',
109
  'version' => '1.0.0',
110
+ 'official' => 'yes',
111
+ 'on_wordpress.org' => 'yes',
112
+ 'free' => 'yes',
113
+ 'service' => 'no',
114
  'requires' => '',
115
  ),
116
 
118
  'name' => 'Leaky Paywall: MailPoet Add-on',
119
  'search' => 'Leaky Paywall: MailPoet Add-on',
120
  'thumbnail' => 'leakypw.png',
121
+ 'description' => __('Leaky Paywall is a Premium plugin to put content behind a paywall. This add-on manages your customers\' customers subscriptions.', WYSIJA),
122
  'plugin_url' => 'leaky-paywall-mail-poet/issuem-leaky-paywall-mailpoet.php',
123
  'author_url' => 'http://clicky.me/leakypw',
124
  'version' => '1.0.0',
125
+ 'official' => 'yes',
126
+ 'on_wordpress.org' => 'yes',
127
+ 'free' => 'yes',
128
+ 'service' => 'no',
129
  ),
130
 
131
  array(
132
  'name' => 'GetConversion: Bar and Box Forms Add-on',
133
  'search' => 'GC MailPoet EX',
134
  'thumbnail' => 'getconversion.png',
135
+ 'description' => __('Put a form in a top or bottom bar of your site, or in a nice box within your posts with GetConversion\'s free plugins. Connect them to MailPoet with this add-on.', WYSIJA),
136
+ 'review' => __('Try it yourself, we were impressed by the free versions.', WYSIJA),
137
  'plugin_url' => 'gc-message-bar/main.php',
138
  'author_url' => 'http://clicky.me/GC-add-on',
139
  'version' => '1.0.0',
140
+ 'official' => 'yes',
141
+ 'on_wordpress.org' => 'yes',
142
+ 'free' => 'yes',
143
+ 'service' => 'no',
144
  ),
145
 
146
  /* Below is the list of services that work with MailPoet */
149
  'name' => 'OptinMonster: Slick Forms',
150
  'search' => 'OptinMonster: slick forms',
151
  'thumbnail' => 'optinmonster.png',
152
+ 'description' => __('Put a subscription form in a popup, footer bar or slide-in to add subscribers with this Premium plugin.', WYSIJA),
153
+ 'review' => __('The authors have done a pretty awesome job.', WYSIJA),
154
  'plugin_url' => '',
155
  'author_url' => 'http://clicky.me/optinmonsteraddon',
156
  'purchase_url' => '',
157
  'version' => '',
158
+ 'official' => 'no',
159
+ 'on_wordpress.org' => 'no',
160
+ 'free' => 'no',
161
+ 'service' => 'yes',
162
+ 'premium_offer' => __('Premium users save 20% with this coupon: MP20', WYSIJA),
163
  ),
164
 
165
  array(
166
  'name' => 'Pippity: Form in a Popup',
167
  'search' => 'Pippity: form in a popup',
168
  'thumbnail' => 'pippity.png',
169
+ 'description' => __('This Premium plugin allows you to add a MailPoet form in a popup.', WYSIJA),
170
+ 'review' => __('You\'ll need to know CSS to design it to your taste.', WYSIJA),
171
  'plugin_url' => '',
172
  'author_url' => 'http://clicky.me/pippity',
173
  'purchase_url' => '',
174
  'version' => '',
175
+ 'official' => 'no',
176
+ 'on_wordpress.org' => 'no',
177
+ 'free' => 'no',
178
+ 'service' => 'yes',
179
+ 'premium_offer' => __('Premium users save 20% with this coupon: mailpoet25', WYSIJA),
180
  ),
181
 
182
 
184
  'name' => 'Hybrid Connect: Forms and Facebook',
185
  'search' => 'Hybrid Connect: forms and Facebook',
186
  'thumbnail' => 'hybrid-connect.png',
187
+ 'description' => __('This Premium plugin allows you to add MailPoet\'s forms in many places, and in Facebook.', WYSIJA),
188
+ 'review' => __('Very powerful, if not a quirky user interface.', WYSIJA),
189
  'plugin_url' => '',
190
  'author_url' => 'http://clicky.me/hybrid-connect',
191
  'purchase_url' => '',
192
  'version' => '',
193
+ 'official' => 'no',
194
+ 'on_wordpress.org' => 'no',
195
+ 'free' => 'no',
196
+ 'service' => 'yes',
197
  'premium_offer' => '',
198
  ),
199
 
201
  'name' => 'Magic Action Box: Pretty forms in post',
202
  'search' => 'Magic Action Box: pretty forms in post',
203
  'thumbnail' => 'magic-action-box.png',
204
+ 'description' => __('This free plugin allows you to design and position a form at the beginning or bottom of a post.', WYSIJA),
205
+ 'review' => __('It\'s free, and has proven popular with our users.', WYSIJA),
206
  'plugin_url' => '',
207
  'author_url' => 'http://clicky.me/magic-action-box',
208
  'purchase_url' => '',
209
  'version' => '',
210
+ 'official' => 'no',
211
+ 'on_wordpress.org' => 'no',
212
+ 'free' => 'no',
213
+ 'service' => 'yes',
214
  'premium_offer' => '',
215
  ),
216
 
218
  'name' => 'Optin Revolution: Popup form',
219
  'search' => 'Optin Revolution: popup form',
220
  'thumbnail' => 'optin-revolution.png',
221
+ 'description' => __('This free plugin allows you to put a form in a popup, that\'s it.', WYSIJA),
222
+ 'review' => __('This is the free version of a more powerful Premium version.', WYSIJA),
223
  'plugin_url' => '',
224
  'author_url' => 'http://clicky.me/optin-revolution',
225
  'purchase_url' => '',
226
  'version' => '',
227
+ 'official' => 'no',
228
+ 'on_wordpress.org' => 'no',
229
+ 'free' => 'no',
230
+ 'service' => 'yes',
231
  'premium_offer' => '',
232
  ),
233
 
235
  'name' => 'Ultimate Coming Soon Page',
236
  'search' => 'Ultimate Coming Soon Page',
237
  'thumbnail' => 'ultimate-coming-soon.png',
238
+ 'description' => __('Your new site is not yet launched? Put a coming soon page with a form to capture emails with this Premium plugin.', WYSIJA),
239
+ 'review' => __('A well designed plugin for a simple idea.', WYSIJA),
240
  'plugin_url' => '',
241
  'author_url' => 'http://clicky.me/coming-soon',
242
  'purchase_url' => '',
243
  'version' => '',
244
+ 'official' => 'no',
245
+ 'on_wordpress.org' => 'no',
246
+ 'free' => 'no',
247
+ 'service' => 'yes',
248
+ 'premium_offer' => __('Premium users save 20% with this coupon: MAILPOET20', WYSIJA),
249
  ),
250
 
251
  array(
252
  'name' => 'Plugmatter: form below your header',
253
  'search' => 'Plugmatter',
254
  'thumbnail' => 'plugmatter.png',
255
+ 'description' => __('This Premium plugin allows you to put a pretty form right below the header. Nothing more, nothing less.', WYSIJA),
256
  'review' => '',
257
  'plugin_url' => '',
258
  'author_url' => 'http://clicky.me/plugmatter',
259
  'purchase_url' => '',
260
  'version' => '',
261
+ 'official' => 'no',
262
+ 'on_wordpress.org' => 'no',
263
+ 'free' => 'no',
264
+ 'service' => 'yes',
265
  'premium_offer' => '',
266
  ),
267
 
269
  'name' => 'EDD: MailPoet: Subscribe on Checkout',
270
  'search' => 'Easy Digital Downloads - MailPoet',
271
  'thumbnail' => 'easy-digital-downloads.png',
272
+ 'description' => __('A checkbox is added as option for your customers to signup for your newsletter while purchasing from your digital store.', WYSIJA),
273
  'review' => '',
274
  'plugin_url' => '',
275
  'author_url' => 'http://clicky.me/easy-digital-downloads',
276
  'purchase_url' => 'http://clicky.me/easy-digital-downloads',
277
  'version' => '1.1.2',
278
+ 'official' => 'no',
279
+ 'on_wordpress.org' => 'no',
280
+ 'free' => 'no',
281
+ 'service' => 'no',
282
  'requires' => 'easy-digital-downloads/easy-digital-downloads.php',
283
  'requires_name' => 'Easy Digital Downloads',
284
  'premium_offer' => '',
288
  'name' => 'Ninja Forms: Subscribe Add-on',
289
  'search' => 'Ninja Forms: Subscribe Add-on',
290
  'thumbnail' => 'ninja-forms.png',
291
+ 'description' => __('Quickly create newsletter signup forms for your MailPoet mailing lists using the power and flexibility that Ninja Forms provides.', WYSIJA),
292
  'review' => '',
293
  'plugin_url' => 'ninja-forms-mailpoet/nf-mailpoet.php',
294
  'author_url' => 'http://clicky.me/ninja-forms',
295
  'purchase_url' => 'http://clicky.me/ninja-forms',
296
  'version' => '1.0.1',
297
+ 'official' => 'no',
298
+ 'on_wordpress.org' => 'no',
299
+ 'free' => 'no',
300
+ 'service' => 'no',
301
  'requires' => 'ninja-forms/ninja-forms.php',
302
  'requires_name' => 'Ninja Forms',
303
  'premium_offer' => '',
304
  ),
305
+
306
+ /*array(
307
+ 'name' => 'WangGuard: block fake signups',
308
+ 'search' => 'WangGuard: block fake signups',
309
+ 'thumbnail' => 'wangguard.png',
310
+ 'description' => __('This plugin blocks spam signups to your site. Connect it to MailPoet with an additional add-on.'),
311
+ 'review' => __('If you have this problem, then this is your solution. Totally free too.', WYSIJA),
312
+ 'plugin_url' => '',
313
+ 'author_url' => 'http://clicky.me/wangguard-plugin',
314
+ 'purchase_url' => '',
315
+ 'version' => '',
316
+ 'official' => 'no',
317
+ 'on_wordpress.org' => 'yes',
318
+ 'free' => 'yes',
319
+ 'service' => 'yes',
320
+ 'premium_offer' => '',
321
+ ),*/
322
  );
323
 
324
  return $available_add_ons;
325
+ }
326
+ ?>
add-ons/add-ons.php CHANGED
@@ -1,15 +1,13 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ){
3
- exit; // Exit if accessed directly
4
- }
5
 
 
6
  class MailPoet_Add_ons {
7
  /**
8
  * Constructor
9
  */
10
  public function __construct(){
11
  $this->plugin_path = WYSIJA_DIR;
12
- $this->wp_plugin_path = str_replace( 'wysija-newsletters', '', $this->plugin_path );
13
  $this->plugin_url = WYSIJA_URL;
14
  $this->image_url = 'http://ps.w.org/wysija-newsletters/assets/add-ons/';
15
 
@@ -30,9 +28,9 @@ class MailPoet_Add_ons {
30
  * administration panel and the public facing site.
31
  */
32
  public function register_scripts_and_styles(){
33
- if ( is_admin() ) {
34
- wp_register_style( 'mail_poet_add_ons', WYSIJA_URL . 'css/add-ons.css' );
35
- wp_enqueue_style( 'mail_poet_add_ons' );
36
  } // end if
37
  } // end register_scripts_and_styles
38
 
@@ -46,34 +44,35 @@ class MailPoet_Add_ons {
46
 
47
  require_once(ABSPATH.'/wp-admin/includes/plugin.php');
48
 
49
- if ( isset($_GET['action'] ) && $_GET['action'] == 'activate' && isset( $_GET['module'] ) ) {
50
 
51
- $plugin = plugin_basename( $_GET['module'] );
52
- $plugin_data = get_plugin_data( $this->wp_plugin_path . $plugin );
53
 
54
- $plugin_name = esc_attr( str_replace( ' ', '_', $plugin_data['Name'] ) );
55
- $plugin_name = esc_attr( str_replace( '&#039;', '_', $plugin_name ) );
56
 
57
- if ( isset( $_GET['requires'] ) ) {
58
- if ( file_exists( $this->wp_plugin_path . plugin_basename( $_GET['requires'] ) ) ) {
59
- if ( ! WYSIJA::is_plugin_active( $_GET['requires'] ) ) {
60
- $location = admin_url( 'admin.php?page=wysija_config&status=not-activated&add-on=' . $plugin_name . '&requires=' . esc_attr( str_replace( ' ', '_', $_GET['requires_name'] ) ) . '#tab-add-ons' );
61
- wp_safe_redirect( $location );
62
  exit;
63
  }
64
- } else {
65
- $location = admin_url( 'admin.php?page=wysija_config&status=not-installed&add-on=' . $plugin_name . '&requires=' . esc_attr( str_replace( ' ', '_', $_GET['requires_name'] ) ) . '#tab-add-ons' );
66
- wp_safe_redirect( $location );
 
67
  exit;
68
  }
69
  }
70
 
71
  // Activate the add-on plugin.
72
- activate_plugin( $plugin );
73
 
74
  // Return back to add-on page.
75
- $location = admin_url( 'admin.php?page=wysija_config&status=activated&add-on=' . $plugin_name . '#tab-add-ons' );
76
- wp_safe_redirect( $location );
77
  exit;
78
  }
79
 
@@ -81,24 +80,13 @@ class MailPoet_Add_ons {
81
  * Display message if the plugin was not able to activate due
82
  * to a required plugin is not active first.
83
  */
84
- if ( $current_screen->parent_base == 'wysija_campaigns' && isset( $_GET['status'] ) && $_GET['status'] == 'not-activated' || isset( $_GET['status'] ) && $_GET['status'] == 'not-installed' ){
85
- echo
86
- '<div id="message" class="error fade" style="display:block !important;">' .
87
- '<p>' .
88
- '<strong>' . esc_attr( str_replace( '_', ' ', $_GET['add-on'] ) ) . '</strong> ' .
89
- wp_kses( sprintf(
90
- __( 'was not activated as it requires <strong><a href="%s">%s</a></strong> to be installed and active first.', WYSIJA ),
91
- esc_url( admin_url( 'plugin-install.php?tab=search&type=term&s=' . esc_attr( strtolower( str_replace( ' ', '+', $_GET['requires'] ) ) ) ) ),
92
- str_replace( '_', ' ', $_GET['requires'] )
93
- ), array( 'a' => array( 'href' => array() ), 'strong' => array(), 'b' => array(), 'em' => array() ) ) .
94
- ' <input type="button" class="button" value="' . esc_attr__( 'Hide this message', WYSIJA ) . '" onclick="document.location.href=\'' . esc_url( admin_url( 'admin.php?page=wysija_config#tab-add_ons' ) ) . '\';">' .
95
- '</p>' .
96
- '</div>';
97
  }
98
 
99
  // Display message once the add-on has been activated.
100
- if ( $current_screen->parent_base == 'wysija_campaigns' && isset( $_GET['status'] ) && $_GET['status'] == 'activated' ){
101
- echo '<div id="message" class="updated fade" style="display:block !important;"><p><strong>' . esc_attr( str_replace( '_', ' ', $_GET['add-on'] ) ) . '</strong> ' . esc_attr__( 'has been activated.', WYSIJA ) . '</p></div>';
102
  }
103
  }
104
 
@@ -110,24 +98,24 @@ class MailPoet_Add_ons {
110
  public function mailpoet_add_on_deactivated_notice(){
111
  global $current_screen;
112
 
113
- require_once ABSPATH . '/wp-admin/includes/plugin.php';
114
 
115
- if ( isset( $_GET['action'] ) && $_GET['action'] == 'deactivate' && isset( $_GET['module'] ) ) {
116
- $plugin = plugin_basename( $_GET['module'] );
117
- $plugin_data = get_plugin_data( $this->wp_plugin_path . $plugin );
118
 
119
  // Deactivate the add-on plugin.
120
- deactivate_plugins( $plugin );
121
 
122
  // Return back to add-on page.
123
- $location = admin_url( 'admin.php?page=wysija_config&status=deactivated&add-on=' . esc_html( str_replace( ' ', '_', $plugin_data['Name'] ) ) . '#tab-add-ons' );
124
- wp_safe_redirect( $location );
125
  exit;
126
  }
127
 
128
  // Display message once the add-on has been deactivated.
129
- if ( $current_screen->parent_base == 'wysija_campaigns' && isset( $_GET['status'] ) && $_GET['status'] == 'deactivated' ) {
130
- echo '<div id="message" class="updated fade" style="display:block !important;"><p><strong>' . esc_attr( str_replace( '_', ' ', $_GET['add-on'] ) ) . '</strong> ' . esc_attr__( 'has been de-activated.', WYSIJA ) . '</p></div>';
131
  }
132
 
133
  }
@@ -137,116 +125,136 @@ class MailPoet_Add_ons {
137
  * the plugins and services available.
138
  */
139
  public function add_ons_page(){
140
- require_once WYSIJA_DIR . '/add-ons/add-ons-list.php';
141
-
142
- echo '<div class="module-container">';
143
- foreach ( add_ons_list() as $plugin => $product ){
144
- $status = ''; // Status class.
145
-
146
- /**
147
- * Queries if the plugin is installed,
148
- * active and meets the requirements
149
- * it requires if any.
150
- */
151
- if ( file_exists( $this->wp_plugin_path . plugin_basename( $product['plugin_url'] ) ) ) {
152
- $status .= ' installed';
153
- } else {
154
- $status .= ' not-installed';
155
- }
156
-
157
- if ( WYSIJA::is_plugin_active( $product['plugin_url'] ) ) {
158
- $status .= ' active';
159
- } else {
160
- $status .= ' inactive';
161
- }
162
-
163
- if ( empty( $product['requires'] ) ) {
164
- $status .= ' ready';
165
- } elseif ( ! empty( $product['requires'] ) && file_exists( $this->wp_plugin_path . plugin_basename( $product['requires'] ) ) ) {
166
- $status .= ' ready';
167
- if ( WYSIJA::is_plugin_active( $product['requires'] ) ) {
168
  $status .= ' ready';
169
- } else {
170
- $status .= ' not-ready';
171
  }
172
- } elseif ( ! empty( $product['requires'] ) && ! file_exists( $this->wp_plugin_path . plugin_basename( $product['requires'] ) ) ) {
173
- $status .= ' not-ready';
174
- }
175
-
176
- if ( WYSIJA::is_plugin_active( 'wysija-newsletters-premium/index.php' ) ) {
177
- $status .= ' premium-active';
178
- }
179
-
180
- echo
181
- '<div class="mailpoet-module' . esc_attr( $status ) . '" id="product">' .
182
- '<h3>' . esc_attr( $product['name'] ) . '</h3>';
183
-
184
- if ( ! empty( $product['thumbnail'] ) ) {
185
- echo '<div class="mailpoet-module-image"><img src="' . esc_url( $this->image_url . $product['thumbnail'] ) . '" width="100%" title="' . esc_attr( $product['name'] ) . '" alt=""></div>';
186
- }
187
-
188
- echo
189
- '<div class="mailpoet-module-content">' .
190
- '<div class="mailpoet-module-description">' .
191
- '<p>' . wp_kses( $product['description'], array() ) . '</p>';
192
-
193
- if ( ! empty( $product['review'] ) ) {
194
- echo '<p><strong>' . esc_attr__( 'MailPoet says: ', WYSIJA ) . '<em>' . esc_attr( $product['review'] ) . '</em>' . '</strong></p>';
195
- }
196
-
197
- if ( WYSIJA::is_plugin_active( 'wysija-newsletters-premium/index.php' ) && ! empty( $product['premium_offer'] ) ) {
198
- echo '<p><strong>' . esc_attr( $product['premium_offer'] ) . '</strong></p>';
199
- }
200
- echo
201
- '</div>' .
202
- '</div>' .
203
-
204
- '<div class="mailpoet-module-actions">';
205
-
206
- if ( ! empty( $product['author_url'] ) ) {
207
- echo '<a href="' . esc_url( $product['author_url'] ) . '" target="_blank" rel="external" class="button-primary website">' . esc_attr__( 'Website', WYSIJA ) . '</a>&nbsp;';
208
- }
209
-
210
- if ( $product['free'] == false && ! empty( $product['purchase_url'] ) ) {
211
- if ( ! empty( $product['plugin_url'] ) && ! file_exists( $this->wp_plugin_path . plugin_basename( $product['plugin_url'] ) ) ) {
212
- echo '<a href="' . esc_url( $product['purchase_url'] ) . '" target="_blank" rel="external" class="button-primary purchase">' . esc_attr__( 'Purchase', WYSIJA ) . '</a>&nbsp;';
213
- } // end if plugin is installed, don't show purchase button.
214
- } // end if product is not free.
215
-
216
- if ( $product['service'] == false ){
217
- if ( $product['on_wordpress.org'] == true ){
218
- if ( ! file_exists( $this->wp_plugin_path . plugin_basename( $product['plugin_url'] ) ) ) {
219
- echo '<a href="' . esc_url( admin_url( 'plugin-install.php?tab=search&type=term&s=' . strtolower( str_replace( ' ', '+', $product['search'] ) ) ) ) . '" class="button-primary install">' . esc_attr__( 'Install from WordPress.org', WYSIJA ) . '</a>&nbsp;';
220
- }
221
- } // end if $product['on_wordpress.org'];
222
-
223
- if ( ! empty( $product['plugin_url'] ) && file_exists( $this->wp_plugin_path . plugin_basename( $product['plugin_url'] ) ) ) {
224
- if ( ! WYSIJA::is_plugin_active( $product['plugin_url'] ) ) {
225
- if ( ! empty( $product['requires'] ) ) {
226
- $requires = '&amp;requires=' . $product['requires'] . '&amp;requires_name=' . $product['requires_name'];
227
- } else {
228
- $requires = '';
229
- }
230
- echo '<a href="' . esc_url( admin_url( 'admin.php?page=wysija_config&amp;action=activate&amp;module=' . $product['plugin_url'] . $requires ) ) . '" class="button-primary activate">' . esc_attr__( 'Activate', WYSIJA ) . '</a>&nbsp;';
231
- } else {
232
- if ( ! empty( $product['config_url'] ) ) {
233
- echo '<a href="' . esc_url( $product['config_url'] ) . '" class="mailpoet-configure-button button-secondary">' . esc_attr__( 'Configure', WYSIJA ) . '</a>';
234
- }
235
- }
236
  }
237
- }
238
-
239
- echo
240
- '</div>' .
241
- '</div>';
242
- } // end if local is yes.
243
-
244
- echo
245
- '<div class="submit-idea">' .
246
- '<p>' . wp_kses( sprintf( __( 'Don\'t see the add-on you\'re looking for? <a href="%s">Submit it</a> in our contact form.', WYSIJA ), 'http://www.mailpoet.com/contact/" target="blank' ), array( 'a' => array( 'href' => array() ) ) ) . '</p>' .
247
- '</div>' .
248
- '</div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  }
 
250
  } // end class
251
 
252
  /**
@@ -260,4 +268,5 @@ function load_add_ons_manager(){
260
  $mailpoet_add_ons->init_mail_poet_add_ons();
261
  $mailpoet_add_ons->add_ons_page();
262
  }
263
- load_add_ons_manager();
 
1
+ <?php if(!defined('ABSPATH')) exit; // Exit if accessed directly ?>
 
 
 
2
 
3
+ <?php
4
  class MailPoet_Add_ons {
5
  /**
6
  * Constructor
7
  */
8
  public function __construct(){
9
  $this->plugin_path = WYSIJA_DIR;
10
+ $this->wp_plugin_path = str_replace('wysija-newsletters', '', $this->plugin_path);
11
  $this->plugin_url = WYSIJA_URL;
12
  $this->image_url = 'http://ps.w.org/wysija-newsletters/assets/add-ons/';
13
 
28
  * administration panel and the public facing site.
29
  */
30
  public function register_scripts_and_styles(){
31
+ if(is_admin()){
32
+ wp_register_style('mail_poet_add_ons', WYSIJA_URL.'css/add-ons.css');
33
+ wp_enqueue_style('mail_poet_add_ons');
34
  } // end if
35
  } // end register_scripts_and_styles
36
 
44
 
45
  require_once(ABSPATH.'/wp-admin/includes/plugin.php');
46
 
47
+ if(isset($_GET['action']) && $_GET['action'] == 'activate' && isset($_GET['module'])){
48
 
49
+ $plugin = plugin_basename($_GET['module']);
50
+ $plugin_data = get_plugin_data($this->wp_plugin_path.''.$plugin);
51
 
52
+ $plugin_name = esc_attr(str_replace(' ', '_', $plugin_data['Name']));
53
+ $plugin_name = esc_attr(str_replace('&#039;', '_', $plugin_name));
54
 
55
+ if(isset($_GET['requires'])){
56
+ if(file_exists($this->wp_plugin_path.''.plugin_basename($_GET['requires']))){
57
+ if(!WYSIJA::is_plugin_active($_GET['requires'])){
58
+ $location = admin_url('admin.php?page=wysija_config&status=not-activated&add-on='.$plugin_name.'&requires='.esc_attr(str_replace(' ', '_', $_GET['requires_name'])).'#tab-add-ons');
59
+ wp_safe_redirect($location);
60
  exit;
61
  }
62
+ }
63
+ else{
64
+ $location = admin_url('admin.php?page=wysija_config&status=not-installed&add-on='.$plugin_name.'&requires='.esc_attr(str_replace(' ', '_', $_GET['requires_name'])).'#tab-add-ons');
65
+ wp_safe_redirect($location);
66
  exit;
67
  }
68
  }
69
 
70
  // Activate the add-on plugin.
71
+ activate_plugin($plugin);
72
 
73
  // Return back to add-on page.
74
+ $location = admin_url('admin.php?page=wysija_config&status=activated&add-on='.$plugin_name.'#tab-add-ons');
75
+ wp_safe_redirect($location);
76
  exit;
77
  }
78
 
80
  * Display message if the plugin was not able to activate due
81
  * to a required plugin is not active first.
82
  */
83
+ if($current_screen->parent_base == 'wysija_campaigns' && isset($_GET['status']) && $_GET['status'] == 'not-activated' || isset($_GET['status']) && $_GET['status'] == 'not-installed'){
84
+ echo '<div id="message" class="error fade" style="display:block !important;"><p><strong>'.str_replace('_', ' ', $_GET['add-on']).'</strong> '.sprintf(__('was not activated as it requires <strong><a href="%s">%s</a></strong> to be installed and active first.', WYSIJA), admin_url('plugin-install.php?tab=search&type=term&s='.strtolower(str_replace(' ', '+', $_GET['requires']))), str_replace('_', ' ', $_GET['requires'])).' <input type="button" class="button" value="'.__('Hide this message', WYSIJA).'" onclick="document.location.href=\''.admin_url('admin.php?page=wysija_config#tab-add_ons').'\';"></p></div>';
 
 
 
 
 
 
 
 
 
 
 
85
  }
86
 
87
  // Display message once the add-on has been activated.
88
+ if($current_screen->parent_base == 'wysija_campaigns' && isset($_GET['status']) && $_GET['status'] == 'activated'){
89
+ echo '<div id="message" class="updated fade" style="display:block !important;"><p><strong>'.str_replace('_', ' ', $_GET['add-on']).'</strong> '.__('has been activated.', WYSIJA).'</p></div>';
90
  }
91
  }
92
 
98
  public function mailpoet_add_on_deactivated_notice(){
99
  global $current_screen;
100
 
101
+ require_once(ABSPATH.'/wp-admin/includes/plugin.php');
102
 
103
+ if(isset($_GET['action']) && $_GET['action'] == 'deactivate' && isset($_GET['module'])){
104
+ $plugin = plugin_basename($_GET['module']);
105
+ $plugin_data = get_plugin_data($this->wp_plugin_path.''.$plugin);
106
 
107
  // Deactivate the add-on plugin.
108
+ deactivate_plugins($plugin);
109
 
110
  // Return back to add-on page.
111
+ $location = admin_url('admin.php?page=wysija_config&status=deactivated&add-on='.esc_html(str_replace(' ', '_', $plugin_data['Name'])).'#tab-add-ons');
112
+ wp_safe_redirect($location);
113
  exit;
114
  }
115
 
116
  // Display message once the add-on has been deactivated.
117
+ if($current_screen->parent_base == 'wysija_campaigns' && isset($_GET['status']) && $_GET['status'] == 'deactivated'){
118
+ echo '<div id="message" class="updated fade" style="display:block !important;"><p><strong>'.str_replace('_', ' ', $_GET['add-on']).'</strong> '.__('has been de-activated.', WYSIJA).'</p></div>';
119
  }
120
 
121
  }
125
  * the plugins and services available.
126
  */
127
  public function add_ons_page(){
128
+ require_once(WYSIJA_DIR.'/add-ons/add-ons-list.php');
129
+ ?>
130
+ <div class="module-container">
131
+ <?php
132
+ foreach(add_ons_list() as $plugin => $product){
133
+ if(empty($product['official']) || $product['official'] == 'yes'){
134
+
135
+ $status = ''; // Status class.
136
+
137
+ /**
138
+ * Queries if the plugin is installed,
139
+ * active and meets the requirements
140
+ * it requires if any.
141
+ */
142
+ if(file_exists($this->wp_plugin_path.''.plugin_basename($product['plugin_url']))){ $status .= ' installed'; }else{ $status .= ' not-installed'; }
143
+ if(WYSIJA::is_plugin_active($product['plugin_url'])){ $status .= ' active'; }else{ $status .= ' inactive'; }
144
+ if(empty($product['requires'])){ $status .= ' ready'; }
145
+ else if(!empty($product['requires']) && file_exists($this->wp_plugin_path.''.plugin_basename($product['requires']))){
 
 
 
 
 
 
 
 
 
 
146
  $status .= ' ready';
147
+ if(WYSIJA::is_plugin_active($product['requires'])){ $status .= ' ready'; }
148
+ else{ $status .= ' not-ready'; }
149
  }
150
+ else if(!empty($product['requires']) && !file_exists($this->wp_plugin_path.''.plugin_basename($product['requires']))){ $status .= ' not-ready'; }
151
+ if(WYSIJA::is_plugin_active('wysija-newsletters-premium/index.php')){ $status .= ' premium-active'; }
152
+ ?>
153
+ <div class="mailpoet-module<?php echo $status; ?>" id="product">
154
+ <h3><?php echo $product['name']; ?></h3>
155
+
156
+ <?php if(!empty($product['thumbnail'])){ ?><div class="mailpoet-module-image"><img src="<?php echo $this->image_url.$product['thumbnail']; ?>" width="100%" title="<?php echo $product['name']; ?>" alt=""></div><?php } ?>
157
+
158
+ <div class="mailpoet-module-content">
159
+ <div class="mailpoet-module-description">
160
+ <p><?php echo $product['description']; ?></p>
161
+ <p><?php if(!empty($product['review'])){ echo '<strong>'.sprintf(__('MailPoet says:&nbsp;<em>%s</em>', WYSIJA), $product['review']).'</strong>'; } ?></p>
162
+ <?php if(WYSIJA::is_plugin_active('wysija-newsletters-premium/index.php') && !empty($product['premium_offer'])){ ?><p><strong><?php echo $product['premium_offer']; ?></strong></p><?php } ?>
163
+ </div>
164
+
165
+ <div class="mailpoet-module-actions">
166
+ <?php if(!empty($product['author_url'])){ ?><a href="<?php echo esc_url($product['author_url']); ?>" target="_blank" class="button-primary website"><?php _e('Website', WYSIJA); ?></a>&nbsp;<?php } ?>
167
+ <?php if($product['free'] == 'yes' && !empty($product['download_url'])){ if(!file_exists($this->wp_plugin_path.''.plugin_basename($product['plugin_url']))){ ?><a href="<?php echo $product['download_url']; ?>" target="_blank" class="button-primary download"><?php _e('Download Plugin', WYSIJA); ?></a>&nbsp;<?php } } ?>
168
+ <?php if($product['service'] == 'no'){ ?>
169
+ <?php if($product['on_wordpress.org'] == 'yes'){ if(!file_exists($this->wp_plugin_path.''.plugin_basename($product['plugin_url']))){ ?><a href="<?php echo admin_url('plugin-install.php?tab=search&type=term&s='.strtolower(str_replace(' ', '+', $product['search']))); ?>" class="button-primary install"><?php _e('Install from WordPress.org', WYSIJA); ?></a>&nbsp;<?php } } ?>
170
+ <?php if(file_exists($this->wp_plugin_path.''.plugin_basename($product['plugin_url']))){ if(!WYSIJA::is_plugin_active($product['plugin_url'])){ ?><a href="<?php if(!empty($product['requires'])){ $requires = '&amp;requires='.$product['requires'].'&amp;requires_name='.$product['requires_name']; }else{ $requires = ''; } echo admin_url('admin.php?page=wysija_config&amp;action=activate&amp;module='.$product['plugin_url'].''.$requires); ?>" class="button-primary activate"><?php _e('Activate', WYSIJA); ?></a>&nbsp;<?php }else{ ?>
171
+ <?php if(!empty($product['config_url'])){ ?><a href="<?php echo $product['config_url']; ?>" class="mailpoet-configure-button button-secondary"><?php _e('Configure', WYSIJA); ?></a><?php } } } ?>
172
+ <?php } ?>
173
+ </div>
174
+ </div>
175
+ </div>
176
+ <?php
177
+ } // end if local is yes.
178
+ }
179
+ ?>
180
+ </div><!-- .module-container -->
181
+
182
+ <div class="submit-idea">
183
+ <p><?php echo sprintf(__('Don\'t see the add-on you\'re looking for? <a href="%s">Submit it</a> in our contact form.', WYSIJA), 'http://www.mailpoet.com/contact/" target="blank'); ?></p>
184
+ </div>
185
+
186
+ <div class="module-container">
187
+ <h2><?php _e('Works with MailPoet', WYSIJA); ?></h2>
188
+ <p><?php _e('This list of plugins and services that might be useful to you. We don\'t offer support for them, and we\'re not affiliated with them.', WYSIJA); ?></p>
189
+
190
+ <?php
191
+ foreach(add_ons_list() as $plugin => $product){
192
+ if($product['official'] == 'no'){
193
+
194
+ $status = ''; // Status class.
195
+
196
+ /**
197
+ * Queries if the plugin is installed,
198
+ * active and meets the requirements
199
+ * it requires if any.
200
+ */
201
+ if(file_exists($this->wp_plugin_path.''.plugin_basename($product['plugin_url']))){ $status .= ' installed'; }else{ $status .= ' not-installed'; }
202
+ if(WYSIJA::is_plugin_active($product['plugin_url'])){ $status .= ' active'; }else{ $status .= ' inactive'; }
203
+ if(empty($product['requires'])){ $status .= ' ready'; }
204
+ else if(!empty($product['requires']) && file_exists($this->wp_plugin_path.''.plugin_basename($product['requires']))){
205
+ $status .= ' ready';
206
+ if(WYSIJA::is_plugin_active($product['requires'])){ $status .= ' ready'; }
207
+ else{ $status .= ' not-ready'; }
 
 
 
 
 
 
208
  }
209
+ else if(!empty($product['requires']) && !file_exists($this->wp_plugin_path.''.plugin_basename($product['requires']))){ $status .= ' not-ready'; }
210
+ if(WYSIJA::is_plugin_active('wysija-newsletters-premium/index.php')){ $status .= ' premium-active'; }
211
+ ?>
212
+ <div class="mailpoet-module<?php echo $status; ?>" id="product">
213
+ <h3><?php echo $product['name']; ?></h3>
214
+ <?php if(!empty($product['thumbnail'])){ ?><div class="mailpoet-module-image"><img src="<?php echo $this->image_url.$product['thumbnail']; ?>" width="100%" title="<?php echo $product['name']; ?>" alt=""></div><?php } ?>
215
+
216
+ <div class="mailpoet-module-content">
217
+ <div class="mailpoet-module-description">
218
+ <p><?php echo $product['description']; ?></p>
219
+ <p><?php if(!empty($product['review'])){ echo '<strong>'.sprintf(__('MailPoet says:&nbsp;<em>%s</em>', WYSIJA), $product['review']).'</strong>'; } ?></p>
220
+ <?php if(WYSIJA::is_plugin_active('wysija-newsletters-premium/index.php') && !empty($product['premium_offer'])){ ?><p><strong><?php echo $product['premium_offer']; ?></strong></p><?php } ?>
221
+ </div>
222
+
223
+ <div class="mailpoet-module-actions">
224
+ <?php if(!empty($product['author_url'])){ ?><a href="<?php echo esc_url($product['author_url']); ?>" target="_blank" rel="external" class="button-primary website"><?php _e('Website', WYSIJA); ?></a>&nbsp;<?php } ?>
225
+ <?php
226
+ if($product['free'] == 'no' && !empty($product['purchase_url'])){
227
+ if(!empty($product['plugin_url']) && !file_exists($this->wp_plugin_path.''.plugin_basename($product['plugin_url']))){ ?><a href="<?php echo $product['purchase_url']; ?>" target="_blank" rel="external" class="button-primary purchase"><?php _e('Purchase', WYSIJA); ?></a>&nbsp;
228
+ <?php
229
+ } // end if plugin is installed, don't show purchase button.
230
+ } // end if product is not free.
231
+ ?>
232
+
233
+ <?php
234
+ if($product['service'] == 'no'){
235
+ if($product['on_wordpress.org'] == 'yes'){
236
+ if(!file_exists($this->wp_plugin_path.''.plugin_basename($product['plugin_url']))){ ?><a href="<?php echo admin_url('plugin-install.php?tab=search&type=term&s='.strtolower(str_replace(' ', '+', $product['search']))); ?>" class="button-primary install"><?php _e('Install from WordPress.org', WYSIJA); ?></a>&nbsp;
237
+ <?php } // end if file_exists.
238
+ } // end if $product['on_wordpress.org'];
239
+
240
+ if(!empty($product['plugin_url']) && file_exists($this->wp_plugin_path.''.plugin_basename($product['plugin_url']))){
241
+ if(!WYSIJA::is_plugin_active($product['plugin_url'])){ ?><a href="<?php if(!empty($product['requires'])){ $requires = '&amp;requires='.$product['requires'].'&amp;requires_name='.$product['requires_name']; }else{ $requires = ''; } echo admin_url('admin.php?page=wysija_config&amp;action=activate&amp;module='.$product['plugin_url'].''.$requires); ?>" class="button-primary activate"><?php _e('Activate', WYSIJA); ?></a>&nbsp;<?php }else{ ?>
242
+ <?php if(!empty($product['config_url'])){ ?><a href="<?php echo $product['config_url']; ?>" class="mailpoet-configure-button button-secondary"><?php _e('Configure', WYSIJA); ?></a><?php } // end if ?>
243
+ <?php
244
+ }
245
+ }
246
+ } // end if plugin is installed. ?>
247
+ </div>
248
+ </div>
249
+ </div>
250
+ <?php
251
+ } // end if local is yes.
252
+ }
253
+ ?>
254
+ </div><!-- .module-container -->
255
+ <?php
256
  }
257
+
258
  } // end class
259
 
260
  /**
268
  $mailpoet_add_ons->init_mail_poet_add_ons();
269
  $mailpoet_add_ons->add_ons_page();
270
  }
271
+ load_add_ons_manager();
272
+ ?>
classes/WJ_Export.php CHANGED
@@ -7,210 +7,199 @@
7
  */
8
  class WJ_Export extends WYSIJA_object {
9
 
10
- private $_file_header = '';
11
- private $_file_handle = null;
12
- private $_user_ids_rows = 0;
13
- private $_user_ids = array();
14
- private $_fields = array();
15
- private $_export_batch = 2000;
16
- private $_filter_list = '';
17
- private $_filter_confirmed = '';
18
- private $_fields_separator = ';';
19
- private $_lines_separator = "\n";
20
- private $_base_encode = 'UTF-8';
21
- private $_output_encode = 'UTF-8//TRANSLIT//IGNORE';
22
-
23
- //needed for tung's batch actions
24
- public $batch_select = null;
25
-
26
- function __construct() {
27
- if ( ! empty( $_POST['wysija']['export']['fields'] ) ) {
28
- $this->_fields = $_POST['wysija']['export']['fields'];
29
- }
30
-
31
- if ( ! empty( $_POST['wysija']['export']['user_ids'] ) ) {
32
- $this->_user_ids = $this->_get_posted_user_ids();
33
- }
34
- if ( ! empty($_POST['wysija']['export']['filter']['list'] ) ) {
35
- $this->_filter_list = $_POST['wysija']['export']['filter']['list'];
36
- }
37
-
38
- // how do we separate the values in the files commas or semy colons ?
39
- if ( ! empty($_POST['wysija']['export']['format'] ) ) {
40
- $this->_fields_separator = $_POST['wysija']['export']['format'];
41
- }
42
-
43
- if ( ! empty($_POST['wysija']['export']['filter']['confirmed'] ) ) {
44
- $this->_filter_confirmed = $_POST['wysija']['export']['filter']['confirmed'];
45
- }
46
- }
47
-
48
- /**
49
- * export the subscribers
50
- * @return type
51
- */
52
- public function export_subscribers() {
53
-
54
- //generate temp file
55
- $helper_file = WYSIJA::get( 'file', 'helper' );
56
- $this->_prepare_headers();
57
- $result_file = $helper_file->temp( $this->_file_header, 'export', '.csv' );
58
-
59
- //open the created file in append mode
60
- $this->_file_handle = fopen( $result_file['path'], 'a' );
61
-
62
- //get a list of user_ids to export
63
- if ( ! empty( $this->_user_ids ) && empty( $this->batch_select ) ) {
64
-
65
- $this->_user_ids_rows = count( $this->_user_ids );
66
- $this->_push_data_to_export_file();
67
- } else {
68
-
69
- $this->_get_chunks_user_ids();
70
- }
71
-
72
- fclose( $this->_file_handle );
73
- return $result_file['path'];
74
- }
75
-
76
- /**
77
- * get the number of rows exported
78
- * @return type
79
- */
80
- public function get_user_ids_rows() {
81
- return $this->_user_ids_rows;
82
- }
83
-
84
- /**
85
- * get an array of user_ids from the global $_POST
86
- * @return type
87
- */
88
- private function _get_posted_user_ids() {
89
- return unserialize( base64_decode( $_POST['wysija']['export']['user_ids'] ) );
90
- }
91
-
92
- /**
93
- * get the query used to select a bung of ids
94
- * @return string
95
- */
96
- private function _get_query_users_ids() {
97
-
98
- // based on filters prepare a query to get a list of user_ids
99
- if ( ! empty( $this->batch_select ) ) { // batch select and export
100
- $this->_user_ids_rows = $this->batch_select['count'];
101
- $qry = $this->batch_select['original_query'];
102
- } else { // export all list
103
- // prepare the filters
104
- $filters = array();
105
- if ( ! empty( $this->_filter_list ) ) {
106
- if ( ! is_array( $this->_filter_list ) ) {
107
- $this->_filter_list = array( $this->_filter_list );
108
- }
109
- }
110
- $filters['lists'] = $this->_filter_list;
111
-
112
- // include also unsubscribed and unconfirmed
113
- if ( ! empty( $this->_filter_confirmed ) ) {
114
- $filters['status'] = 'subscribed';
115
- }
116
-
117
- $model_user = WYSIJA::get( 'user', 'model' );
118
- $select = array( 'A.user_id' );
119
- $qry = $model_user->get_subscribers( $select, $filters, '', $return_query = true );
120
- }
121
-
122
- return $qry;
123
- }
124
-
125
- /**
126
- * get chunks of subscribers ids and push them step by step to the export file
127
- */
128
- private function _get_chunks_user_ids() {
129
-
130
- $model_user = WYSIJA::get( 'user', 'model' );
131
- $this->_user_ids = array();
132
- $query_user_ids = $this->_get_query_users_ids();
133
- $query_count = str_replace( array( 'DISTINCT(A.user_id)', 'DISTINCT(B.user_id)' ), 'COUNT(DISTINCT(A.user_id))', $query_user_ids );
134
-
135
- if ( empty( $this->_user_ids_rows ) ) {
136
- $useridsrows_result = $model_user->getResults( $query_count, ARRAY_N );
137
- $this->_user_ids_rows = (int) $useridsrows_result[0][0];
138
- }
139
-
140
- if ( $this->_user_ids_rows <= $this->_export_batch ) {
141
- $user_ids_db = $model_user->getResults( $query_user_ids, ARRAY_N );
142
-
143
- foreach ( $user_ids_db as $uarr ) {
144
- $this->_user_ids[] = $uarr[0];
145
- }
146
-
147
- $this->_push_data_to_export_file();
148
- } else {
149
- $pages = ceil( $this->_user_ids_rows / $this->_export_batch ); //pagination
150
- for ( $i = 0; $i < $pages; $i++ ) {
151
- $query_batch = $query_user_ids . ' ORDER BY user_id ASC LIMIT ' . ($i * $this->_export_batch) . ',' . $this->_export_batch;
152
- $user_ids_db = $model_user->getResults( $query_batch, ARRAY_N );
153
- foreach ( $user_ids_db as $uarr ) {
154
- $this->_user_ids[] = $uarr[0];
155
- }
156
- $this->_push_data_to_export_file();
157
-
158
- unset($user_ids_db); //free memory
159
- }
160
- }
161
- }
162
-
163
- /**
164
- * split the user_ids array into chunks, load the fields of all the concerned
165
- * users and push the data to the file
166
- */
167
- function _push_data_to_export_file() {
168
- $user_ids_chunks = array(); // chunk rows into separated batchs, limit by $this->_export_batch
169
- $user_ids_chunks = array_chunk( $this->_user_ids, 200 );
170
- $this->_user_ids = null; // free memory
171
-
172
- $model_user = WYSIJA::get( 'user', 'model' );
173
- foreach ( $user_ids_chunks as $user_id_chunk ) {
174
- // get the full data for that specific chunk of ids
175
- $data = $model_user->get( $this->_fields, array( 'user_id' => $user_id_chunk ) );
176
-
177
- if ( in_array( 'created_at', $this->_fields ) ) {
178
- foreach ( $data as $key => $row ) {
179
- $data[$key]['created_at'] = date_i18n( get_option( 'date_format' ), $row['created_at'] );
180
- }
181
- }
182
-
183
- $rows_count = count( $data );
184
-
185
- // As required in Wysija/plugin#798 removed BOM from file
186
- // fwrite( $this->_file_handle, "\xEF\xBB\xBF" );
187
-
188
- // append content to the file
189
- foreach ( $data as $k => $row ) {
190
- $row_string = implode( $this->_fields_separator, $row );
191
- $encoded_string = iconv( $this->_base_encode, $this->_output_encode, $row_string );
192
- fwrite( $this->_file_handle, $encoded_string . ( $rows_count !== $k ? $this->_lines_separator : '' ) );
193
- }
194
- }
195
- }
196
-
197
- /**
198
- * simply prepare the header of the file based on the fields
199
- */
200
- private function _prepare_headers() {
201
- $model_user = WYSIJA::get( 'user_field', 'model' );
202
- $database_fields = $model_user->getFields();
203
-
204
- $name_fields = array();
205
- //prepare the columns that need to be exported
206
- foreach ( $this->_fields as $key_field ) {
207
- $name_fields[] = $database_fields[$key_field];
208
- }
209
-
210
- //create the export file step by step
211
- $row_string = implode( $this->_fields_separator, $name_fields ) . $this->_lines_separator;
212
- $encoded_string = iconv( $this->_base_encode, $this->_output_encode, $row_string );
213
- $this->_file_header = $encoded_string;
214
- }
215
 
216
  }
7
  */
8
  class WJ_Export extends WYSIJA_object {
9
 
10
+ private $_file_header = '';
11
+ private $_file_handle = null;
12
+ private $_user_ids_rows = 0;
13
+ private $_user_ids = array();
14
+ private $_fields = array();
15
+ private $_export_batch = 2000;
16
+ private $_filter_list = '';
17
+ private $_filter_confirmed = '';
18
+ private $_fields_separator = ';';
19
+ private $_lines_separator = "\n";
20
+
21
+ private $_base_encode = "UTF-8";
22
+ private $_output_encode = "Windows-1252";
23
+ //needed for tung's batch actions
24
+ public $batch_select = null;
25
+
26
+ function __construct() {
27
+ if (!empty($_POST['wysija']['export']['fields']))
28
+ $this->_fields = $_POST['wysija']['export']['fields'];
29
+ if (!empty($_POST['wysija']['export']['user_ids']))
30
+ $this->_user_ids = $this->_get_posted_user_ids();
31
+ if (!empty($_POST['wysija']['export']['filter']['list']))
32
+ $this->_filter_list = $_POST['wysija']['export']['filter']['list'];
33
+
34
+ // how do we separate the values in the files commas or semy colons ?
35
+ if (!empty($_POST['wysija']['export']['format']))
36
+ $this->_fields_separator = $_POST['wysija']['export']['format'];
37
+
38
+ if (!empty($_POST['wysija']['export']['filter']['confirmed']))
39
+ $this->_filter_confirmed = $_POST['wysija']['export']['filter']['confirmed'];
40
+ }
41
+
42
+ /**
43
+ * export the subscribers
44
+ * @return type
45
+ */
46
+ public function export_subscribers() {
47
+
48
+ //generate temp file
49
+ $helper_file = WYSIJA::get('file', 'helper');
50
+ $this->_prepare_headers();
51
+ $result_file = $helper_file->temp($this->_file_header, 'export', '.csv');
52
+
53
+ //open the created file in append mode
54
+ $this->_file_handle = fopen($result_file['path'], 'a');
55
+
56
+ //get a list of user_ids to export
57
+ if (!empty($this->_user_ids) && empty($this->batch_select)) {
58
+
59
+ $this->_user_ids_rows = count($this->_user_ids);
60
+ $this->_push_data_to_export_file();
61
+ } else {
62
+
63
+ $this->_get_chunks_user_ids();
64
+ }
65
+
66
+ fclose($this->_file_handle);
67
+ return $result_file['path'];
68
+ }
69
+
70
+ /**
71
+ * get the number of rows exported
72
+ * @return type
73
+ */
74
+ public function get_user_ids_rows() {
75
+ return $this->_user_ids_rows;
76
+ }
77
+
78
+ /**
79
+ * get an array of user_ids from the global $_POST
80
+ * @return type
81
+ */
82
+ private function _get_posted_user_ids() {
83
+ return unserialize(base64_decode($_POST['wysija']['export']['user_ids']));
84
+ }
85
+
86
+ /**
87
+ * get the query used to select a bung of ids
88
+ * @return string
89
+ */
90
+ private function _get_query_users_ids() {
91
+
92
+ // based on filters prepare a query to get a list of user_ids
93
+ if (!empty($this->batch_select)) { // batch select and export
94
+ $this->_user_ids_rows = $this->batch_select['count'];
95
+ $qry = $this->batch_select['original_query'];
96
+ } else { // export all list
97
+ // prepare the filters
98
+ $filters = array();
99
+ if (!empty($this->_filter_list)) {
100
+ if (!is_array($this->_filter_list)) {
101
+ $this->_filter_list = array($this->_filter_list);
102
+ }
103
+ }
104
+ $filters['lists'] = $this->_filter_list;
105
+
106
+ // include also unsubscribed and unconfirmed
107
+ if (!empty($this->_filter_confirmed)) {
108
+ $filters['status'] = 'subscribed';
109
+ }
110
+
111
+ $model_user = WYSIJA::get('user', 'model');
112
+ $select = array('A.user_id');
113
+ $qry = $model_user->get_subscribers($select, $filters, '', $return_query = true);
114
+ }
115
+
116
+ return $qry;
117
+ }
118
+
119
+ /**
120
+ * get chunks of subscribers ids and push them step by step to the export file
121
+ */
122
+ private function _get_chunks_user_ids() {
123
+
124
+ $model_user = WYSIJA::get('user', 'model');
125
+ $this->_user_ids = array();
126
+ $query_user_ids = $this->_get_query_users_ids();
127
+ $query_count = str_replace(array('DISTINCT(A.user_id)', 'DISTINCT(B.user_id)'), 'COUNT(DISTINCT(A.user_id))', $query_user_ids);
128
+
129
+ if (empty($this->_user_ids_rows)) {
130
+ $useridsrows_result = $model_user->getResults($query_count, ARRAY_N);
131
+ $this->_user_ids_rows = (int) $useridsrows_result[0][0];
132
+ }
133
+
134
+ if ($this->_user_ids_rows <= $this->_export_batch) {
135
+ $user_ids_db = $model_user->getResults($query_user_ids, ARRAY_N);
136
+
137
+ foreach ($user_ids_db as $uarr) {
138
+ $this->_user_ids[] = $uarr[0];
139
+ }
140
+
141
+ $this->_push_data_to_export_file();
142
+ } else {
143
+ $pages = ceil($this->_user_ids_rows / $this->_export_batch); //pagination
144
+ for ($i = 0; $i < $pages; $i++) {
145
+ $query_batch = $query_user_ids . ' ORDER BY user_id ASC LIMIT ' . ($i * $this->_export_batch) . ',' . $this->_export_batch;
146
+ $user_ids_db = $model_user->getResults($query_batch, ARRAY_N);
147
+ foreach ($user_ids_db as $uarr) {
148
+ $this->_user_ids[] = $uarr[0];
149
+ }
150
+ $this->_push_data_to_export_file();
151
+
152
+ unset($user_ids_db); //free memory
153
+ }
154
+ }
155
+ }
156
+
157
+ /**
158
+ * split the user_ids array into chunks, load the fields of all the concerned
159
+ * users and push the data to the file
160
+ */
161
+ function _push_data_to_export_file() {
162
+ $user_ids_chunks = array(); // chunk rows into separated batchs, limit by $this->_export_batch
163
+ $user_ids_chunks = array_chunk($this->_user_ids, 200);
164
+ $this->_user_ids = null; // free memory
165
+
166
+ $model_user = WYSIJA::get('user', 'model');
167
+ foreach ($user_ids_chunks as $user_id_chunk) {
168
+ // get the full data for that specific chunk of ids
169
+ $data = $model_user->get($this->_fields, array('user_id' => $user_id_chunk));
170
+
171
+ if (in_array('created_at', $this->_fields)) {
172
+ foreach ($data as $key => $row) {
173
+ $data[$key]['created_at'] = date_i18n(get_option('date_format'), $row['created_at']);
174
+ }
175
+ }
176
+
177
+ // append content to the file
178
+ foreach ($data as $row) {
179
+ $row_string = implode($this->_fields_separator, $row);
180
+ $encoded_string = iconv($this->_base_encode, $this->_output_encode, $row_string);
181
+ fwrite($this->_file_handle, $encoded_string . $this->_lines_separator);
182
+ }
183
+ }
184
+ }
185
+
186
+ /**
187
+ * simply prepare the header of the file based on the fields
188
+ */
189
+ private function _prepare_headers() {
190
+ $model_user = WYSIJA::get('user_field', 'model');
191
+ $database_fields = $model_user->getFields();
192
+
193
+ $name_fields = array();
194
+ //prepare the columns that need to be exported
195
+ foreach ($this->_fields as $key_field) {
196
+ $name_fields[] = $database_fields[$key_field];
197
+ }
198
+
199
+ //create the export file step by step
200
+ $row_string = implode($this->_fields_separator, $name_fields) . $this->_lines_separator;
201
+ $encoded_string = iconv($this->_base_encode, $this->_output_encode, $row_string);
202
+ $this->_file_header = $encoded_string;
203
+ }
 
 
 
 
 
 
 
 
 
 
 
204
 
205
  }
classes/WJ_Field.php CHANGED
@@ -7,277 +7,286 @@ can be added to a form.
7
  Example:
8
  $custom_field = new WJ_Field();
9
  $custom_field->set(array(
10
- 'name' => 'Fruits',
11
- 'type' => 'select',
12
- 'required' => false,
13
- 'settings' => array(
14
- 'label' => 'Select a fruit:',
15
- 'values' => array(
16
- 'Apple', 'Orange', 'Banana'
17
- ),
18
- 'default_value' => 'Orange'
19
- )
20
  ));
21
  $custom_field->save();
22
  */
23
 
24
  class WJ_Field {
25
 
26
- // The custom fields DB table.
27
- private $table;
28
- // The Users table.
29
- private $user_table;
30
- // The ID of the custom field.
31
- public $id;
32
- // The name of the custom field.
33
- public $name;
34
- // input, textarea, checkbox, radio, select
35
- public $type;
36
- // true | false
37
- public $required;
38
- // Settings.
39
- public $settings = array();
40
 
41
- /*
42
- Just set the correct tables on creation.
43
- $custom_field = new WJ_Field();
44
- */
45
- function __construct() {
46
- $this->table = WJ_Settings::db_prefix( 'custom_field' );
47
- $this->user_table = WJ_Settings::db_prefix( 'user' );
48
- }
49
 
50
- /*
51
- Get the table name.
52
- Useful for statistics and counts on Custom Fields.
53
- Generally when we want to run DB queries.
54
- */
55
- public function get_table_name() {
56
- return $this->table;
57
- }
58
 
59
- /*
60
- Static method to get a Custom field by id.
61
- WJ_Field::get(id);
62
- # => WJCustomField Object
63
- */
64
- public static function get( $id ) {
65
- $object = new self();
66
- global $wpdb;
67
- $result = $wpdb->get_row( $wpdb->prepare( "SELECT * from {$object->table} WHERE id = %d", $id ), ARRAY_A );
68
- if ( $result != null ) {
69
- $result['settings'] = unserialize( $result['settings'] );
70
- $result['required'] = WJ_Utils::to_bool( $result['required'] );
71
- $object->set( $result );
72
- return $object;
73
- } else {
74
- return null;
75
- }
76
- }
 
 
 
 
77
 
78
- /*
79
- Get all custom fields.
80
- WJ_Field::get_all();
81
- # => Array of WJ_Field
82
- */
83
- public static function get_all( $options = array() ) {
84
- $object = new self();
85
- global $wpdb;
86
 
87
- // default order by
88
- $order_by = 'id ASC';
89
- if ( isset($options['order_by'] ) ){
90
- $order_by = $options['order_by'];
91
- }
92
 
93
- // fetch rows from db
94
- $results = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$object->table} ORDER BY %s", $order_by ), ARRAY_A );
 
 
 
95
 
96
- if ( $results != null ) {
97
- $collection = array();
98
- foreach ( $results as $result ) {
99
- $result['settings'] = unserialize( $result['settings'] );
100
- $result['required'] = WJ_Utils::to_bool( $result['required'] );
101
- $field = new self();
102
- $field->set( $result );
103
- $collection[] = $field;
104
- }
105
- return $collection;
106
- } else {
107
- return null;
108
- }
109
- }
110
 
111
 
112
- /*
113
- Get a custom fields names list.
114
- WJ_Field::get_names_list();
115
- # => array(1 => 'Address', 2 => 'Gender')
116
- */
117
- public static function get_all_names() {
118
- $fields = self::get_all();
119
- $fields_list = array();
120
- if ( isset( $fields ) ) {
121
- foreach ( $fields as $field ) {
122
- $fields_list[$field->id] = $field->name;
123
- }
124
- }
125
- return $fields_list;
126
- }
127
 
128
- /*
129
- Set all object properties.
130
- $custom_field->set(array(
131
- 'name' => 'First Name',
132
- 'type' => 'text',
133
- 'required' => true
134
- ));
135
- */
136
- public function set( $args ) {
137
- if ( isset( $args['id'] ) ) {
138
- $this->id = $args['id'];
139
- }
140
- $this->name = $args['name'];
141
- $this->type = $args['type'];
142
- $this->required = $args['required'];
143
- $this->settings = $args['settings'];
144
- }
145
 
146
- /*
147
- Store Custom Field in DB.
148
- If already stored, updates it.
149
- $custom_field->save();
150
- */
151
- public function save() {
152
- // Check if it's a new object or an update.
153
- if ( isset( $this->id ) ) {
154
- $this->update();
155
- } else {
156
- $this->create();
157
- }
158
- }
159
 
160
- // Delete custom field from DB.
161
- public function delete() {
162
- global $wpdb;
163
- $result = $wpdb->delete( $this->table, array( 'id' => $this->id ), array( '%d' ) );
164
- $this->delete_user_col( $this->id );
165
- return $result;
166
- }
 
 
 
167
 
168
- /*
169
- Generates user column name;
170
- $custom_field->user_column_name();
171
- # => 'cf_1'
172
- */
173
- public function user_column_name() {
174
- $column_name = 'cf_' . $this->id;
175
- return $column_name;
176
- }
177
 
178
- /*
179
- Creates the Custom Field.
180
- It also creates the user column, depending on type.
181
- */
182
- private function create() {
183
- global $wpdb;
184
- $required = WJ_Utils::to_int( $this->required );
185
- $wpdb->insert(
186
- $this->table,
187
- array(
188
- 'name' => $this->name,
189
- 'type' => $this->type,
190
- 'required' => $required,
191
- 'settings' => serialize( $this->settings ),
192
- ),
193
- array( '%s', '%s', '%d', '%s', '%s' )
194
- );
195
- // ! No id in user col?
196
- if ( $wpdb->insert_id ) {
197
- $this->id = $wpdb->insert_id;
198
- $this->create_user_col();
199
- } else {
200
- return false;
201
- }
202
- }
203
 
204
- /*
205
- Updates the value of the custom field.
206
- $custom_field->update('New address');
207
- */
208
- private function update() {
209
- global $wpdb;
210
- $required = WJ_Utils::to_int( $this->required );
211
- $result = $wpdb->update(
212
- $this->table,
213
- array(
214
- 'name' => $this->name,
215
- 'type' => $this->type,
216
- 'required' => $required,
217
- 'settings' => serialize( $this->settings ),
218
- ),
219
- array( 'id' => $this->id ),
220
- array( '%s', '%s', '%d' ),
221
- array( '%d' )
222
- );
223
- return $result;
224
- }
225
 
226
- /*
227
- Creates the correct user columnn, named cf_x, in the
228
- user table. x is the ID if the custom field.
229
- */
230
- private function create_user_col() {
231
- global $wpdb;
232
- $column_name = $this->user_column_name();
233
- $column_type = $this->generate_column_type();
234
- $result = $wpdb->query(
235
- "ALTER TABLE $this->user_table ADD COLUMN $column_name $column_type"
236
- );
237
- return $result;
238
- }
239
 
240
- /*
241
- Calculates the correct column type, based on custom field type.
242
- $custom_field->generate_column_type();
243
- # => 'VARCHAR(100)'
244
- */
245
- private function generate_column_type() {
246
- switch ( $this->type ) {
247
- case 'input':
248
- $column_type = 'VARCHAR(100)';
249
- break;
250
- case 'textarea':
251
- $column_type = 'VARCHAR(255)';
252
- break;
253
- case 'checkbox':
254
- $column_type = 'TINYINT(1)';
255
- break;
256
- case 'radio':
257
- $column_type = 'VARCHAR(255)';
258
- break;
259
- case 'select':
260
- $column_type = 'VARCHAR(255)';
261
- break;
262
- case 'date':
263
- $column_type = 'INT(10) UNSIGNED';
264
- break;
265
- default:
266
- $column_type = 'VARCHAR(255)';
267
- break;
268
- }
269
- return $column_type;
270
- }
271
 
272
- /*
273
- Deletes the user column in the user table.
274
- Needed when we remove a custom field.
275
- */
276
- private function delete_user_col( $custom_field_id ) {
277
- global $wpdb;
278
- $cf_column = 'cf_' . $custom_field_id;
279
- $result = $wpdb->query( "ALTER TABLE $this->user_table DROP COLUMN $cf_column" );
280
- return $result;
281
- }
 
 
 
282
 
283
  }
7
  Example:
8
  $custom_field = new WJ_Field();
9
  $custom_field->set(array(
10
+ 'name' => 'Fruits',
11
+ 'type' => 'select',
12
+ 'required' => false,
13
+ 'settings' => array(
14
+ 'label' => 'Select a fruit:',
15
+ 'values' => array(
16
+ 'Apple', 'Orange', 'Banana'
17
+ ),
18
+ 'default_value' => 'Orange'
19
+ )
20
  ));
21
  $custom_field->save();
22
  */
23
 
24
  class WJ_Field {
25
 
26
+ // The custom fields DB table.
27
+ private $table;
28
+ // The Users table.
29
+ private $user_table;
30
+ // The ID of the custom field.
31
+ public $id;
32
+ // The name of the custom field.
33
+ public $name;
34
+ // input, textarea, checkbox, radio, select
35
+ public $type;
36
+ // true | false
37
+ public $required;
38
+ // Settings.
39
+ public $settings = array();
40
 
41
+ /*
42
+ Just set the correct tables on creation.
43
+ $custom_field = new WJ_Field();
44
+ */
45
+ function __construct() {
46
+ $this->table = WJ_Settings::db_prefix('custom_field');
47
+ $this->user_table = WJ_Settings::db_prefix('user');
48
+ }
49
 
50
+ /*
51
+ Get the table name.
52
+ Useful for statistics and counts on Custom Fields.
53
+ Generally when we want to run DB queries.
54
+ */
55
+ public function get_table_name() {
56
+ return $this->table;
57
+ }
58
 
59
+ /*
60
+ Static method to get a Custom field by id.
61
+ WJ_Field::get(id);
62
+ # => WJCustomField Object
63
+ */
64
+ public static function get($id) {
65
+ $object = new self();
66
+ global $wpdb;
67
+ $result = $wpdb->get_row($wpdb->prepare(
68
+ "SELECT * FROM $object->table
69
+ WHERE id = %d",
70
+ array($id)
71
+ ), ARRAY_A);
72
+ if ($result != null) {
73
+ $result['settings'] = unserialize($result['settings']);
74
+ $result['required'] = WJ_Utils::to_bool($result['required']);
75
+ $object->set($result);
76
+ return $object;
77
+ } else {
78
+ return null;
79
+ }
80
+ }
81
 
82
+ /*
83
+ Get all custom fields.
84
+ WJ_Field::get_all();
85
+ # => Array of WJ_Field
86
+ */
87
+ public static function get_all($options = array()) {
88
+ $object = new self();
89
+ global $wpdb;
90
 
91
+ // default order by
92
+ $order_by = 'id ASC';
93
+ if(isset($options['order_by'])) $order_by = $options['order_by'];
 
 
94
 
95
+ // fetch rows from db
96
+ $results = $wpdb->get_results($wpdb->prepare(
97
+ "SELECT * FROM $object->table ORDER BY $order_by",
98
+ array()
99
+ ), ARRAY_A);
100
 
101
+ if ($results != null) {
102
+ $collection = array();
103
+ foreach ($results as $result) {
104
+ $result['settings'] = unserialize($result['settings']);
105
+ $result['required'] = WJ_Utils::to_bool($result['required']);
106
+ $field = new self();
107
+ $field->set($result);
108
+ $collection[] = $field;
109
+ }
110
+ return $collection;
111
+ } else {
112
+ return null;
113
+ }
114
+ }
115
 
116
 
117
+ /*
118
+ Get a custom fields names list.
119
+ WJ_Field::get_names_list();
120
+ # => array(1 => 'Address', 2 => 'Gender')
121
+ */
122
+ public static function get_all_names() {
123
+ $fields = self::get_all();
124
+ $fields_list = array();
125
+ if (isset($fields)) {
126
+ foreach ($fields as $field) {
127
+ $fields_list[$field->id] = $field->name;
128
+ }
129
+ }
130
+ return $fields_list;
131
+ }
132
 
133
+ /*
134
+ Set all object properties.
135
+ $custom_field->set(array(
136
+ 'name' => 'First Name',
137
+ 'type' => 'text',
138
+ 'required' => true
139
+ ));
140
+ */
141
+ public function set($args) {
142
+ if (isset($args['id'])) {
143
+ $this->id = $args['id'];
144
+ }
145
+ $this->name = $args['name'];
146
+ $this->type = $args['type'];
147
+ $this->required = $args['required'];
148
+ $this->settings = $args['settings'];
149
+ }
150
 
151
+ /*
152
+ Store Custom Field in DB.
153
+ If already stored, updates it.
154
+ $custom_field->save();
155
+ */
156
+ public function save() {
157
+ // Check if it's a new object or an update.
158
+ if (isset($this->id)) {
159
+ $this->update();
160
+ } else {
161
+ $this->create();
162
+ }
163
+ }
164
 
165
+ // Delete custom field from DB.
166
+ public function delete() {
167
+ global $wpdb;
168
+ $result = $wpdb->delete($this->table,
169
+ array('id' => $this->id),
170
+ array('%d')
171
+ );
172
+ $this->delete_user_col($this->id);
173
+ return $result;
174
+ }
175
 
176
+ /*
177
+ Generates user column name;
178
+ $custom_field->user_column_name();
179
+ # => 'cf_1'
180
+ */
181
+ public function user_column_name() {
182
+ $column_name = 'cf_' . $this->id;
183
+ return $column_name;
184
+ }
185
 
186
+ /*
187
+ Creates the Custom Field.
188
+ It also creates the user column, depending on type.
189
+ */
190
+ private function create() {
191
+ global $wpdb;
192
+ $required = WJ_Utils::to_int($this->required);
193
+ $wpdb->insert(
194
+ $this->table,
195
+ array(
196
+ 'name' => $this->name,
197
+ 'type' => $this->type,
198
+ 'required' => $required,
199
+ 'settings' => serialize($this->settings)
200
+ ), array('%s', '%s', '%d', '%s', '%s')
201
+ );
202
+ // ! No id in user col?
203
+ if ($wpdb->insert_id) {
204
+ $this->id = $wpdb->insert_id;
205
+ $this->create_user_col();
206
+ } else {
207
+ return false;
208
+ }
209
+ }
 
210
 
211
+ /*
212
+ Updates the value of the custom field.
213
+ $custom_field->update('New address');
214
+ */
215
+ private function update() {
216
+ global $wpdb;
217
+ $required = WJ_Utils::to_int($this->required);
218
+ $result = $wpdb->update(
219
+ $this->table,
220
+ array(
221
+ 'name' => $this->name,
222
+ 'type' => $this->type,
223
+ 'required' => $required,
224
+ 'settings' => serialize($this->settings)
225
+ ), array("id" => $this->id),
226
+ array('%s', '%s', '%d'),
227
+ array("%d")
228
+ );
229
+ return $result;
230
+ }
 
231
 
232
+ /*
233
+ Creates the correct user columnn, named cf_x, in the
234
+ user table. x is the ID if the custom field.
235
+ */
236
+ private function create_user_col() {
237
+ global $wpdb;
238
+ $column_name = $this->user_column_name();
239
+ $column_type = $this->generate_column_type();
240
+ $result = $wpdb->query(
241
+ "ALTER TABLE $this->user_table ADD COLUMN $column_name $column_type"
242
+ );
243
+ return $result;
244
+ }
245
 
246
+ /*
247
+ Calculates the correct column type, based on custom field type.
248
+ $custom_field->generate_column_type();
249
+ # => 'VARCHAR(100)'
250
+ */
251
+ private function generate_column_type() {
252
+ switch ($this->type) {
253
+ case 'input':
254
+ $column_type = 'VARCHAR(100)';
255
+ break;
256
+ case 'textarea':
257
+ $column_type = 'VARCHAR(255)';
258
+ break;
259
+ case 'checkbox':
260
+ $column_type = 'TINYINT(1)';
261
+ break;
262
+ case 'radio':
263
+ $column_type = 'VARCHAR(255)';
264
+ break;
265
+ case 'select':
266
+ $column_type = 'VARCHAR(255)';
267
+ break;
268
+ case 'date':
269
+ $column_type = 'INT(10) UNSIGNED';
270
+ break;
271
+ default:
272
+ $column_type = 'VARCHAR(255)';
273
+ break;
274
+ }
275
+ return $column_type;
276
+ }
277
 
278
+ /*
279
+ Deletes the user column in the user table.
280
+ Needed when we remove a custom field.
281
+ */
282
+ private function delete_user_col($custom_field_id) {
283
+ global $wpdb;
284
+ $cf_column = 'cf_' . $custom_field_id;
285
+ $result = $wpdb->query(
286
+ "ALTER TABLE $this->user_table
287
+ DROP COLUMN $cf_column"
288
+ );
289
+ return $result;
290
+ }
291
 
292
  }
classes/WJ_Import.php CHANGED
@@ -16,7 +16,6 @@ class WJ_Import extends WYSIJA_object {
16
  private $_data_to_insert = array();
17
  private $_number_list = 0;
18
  private $_data_numbers = array();
19
- private $_line_delimiter = "\n";
20
  private $_duplicate_emails_count = array(); // detect the emails that are duplicates in the import file
21
  private $_csv_array = array(); // containing the csv into an array
22
  private $_ignored_row_count = 0; // the count of rows we ignore because there was no valid email present
@@ -120,10 +119,7 @@ class WJ_Import extends WYSIJA_object {
120
  'type' => $maybe_newfield[1],
121
  'required' => false,
122
  'settings' => array(
123
- 'label' => $maybe_newfield[2],
124
- 'date_type' => 'year_month_day',
125
- 'is_default_today' => 0,
126
- 'date_order' => 'mm/dd/yyyy'
127
  )
128
  ));
129
 
@@ -313,7 +309,7 @@ class WJ_Import extends WYSIJA_object {
313
  $data = array();
314
 
315
  // the new way for splitting a string into an array of lines
316
- $csv_data_array = explode( $this->_line_delimiter, $csv_file_content );
317
 
318
  $i=1;
319
  foreach($csv_data_array as $csv_line){
@@ -664,21 +660,21 @@ class WJ_Import extends WYSIJA_object {
664
  */
665
  private function _run_test_on_csv_file(){
666
  // try different set of enclosure and separator for the csv which can have different look depending on the data carried
667
- $field_separators_to_test = array( ',', ';', "\t" );
668
- $field_enclosers_to_test = array( '"', '' );
669
  $this->_csv_data['fsep'] = false;
670
  $this->_csv_data['fenc'] = '';
671
  $helper_user = WYSIJA::get('user','helper');
672
-
673
  foreach($field_enclosers_to_test as $enclosure){
674
  foreach($field_separators_to_test as $fsep){
675
 
676
  // testing different combinations of separator and enclosers
677
- $this->_csv_array = $this->_csv_to_array( $this->_csv_file_string, 10, $fsep, $enclosure );
678
 
679
  // make sure that our CSV has more than one row and that it has the same number of values in the first row and the second row
680
- if ( ( count( $this->_csv_array ) > 1 && count( $this->_csv_array[0] ) == count( $this->_csv_array[1] ) ) ) {
681
- if ( count( $this->_csv_array[0] ) > 1 || $helper_user->validEmail( trim( $this->_csv_array[0][0] ) ) || $helper_user->validEmail( trim( $this->_csv_array[1][0] ) ) ) {
 
682
  $this->_csv_data['fsep'] = $fsep;
683
  $this->_csv_data['fenc'] = $enclosure;
684
  break(2);
@@ -687,6 +683,7 @@ class WJ_Import extends WYSIJA_object {
687
  }
688
  }
689
 
 
690
  // if we didn't manage to find a separator in that file then it is not a csv file and we come out
691
  if(empty($this->_csv_data['fsep'])){
692
  $this->notice( sprintf(
16
  private $_data_to_insert = array();
17
  private $_number_list = 0;
18
  private $_data_numbers = array();
 
19
  private $_duplicate_emails_count = array(); // detect the emails that are duplicates in the import file
20
  private $_csv_array = array(); // containing the csv into an array
21
  private $_ignored_row_count = 0; // the count of rows we ignore because there was no valid email present
119
  'type' => $maybe_newfield[1],
120
  'required' => false,
121
  'settings' => array(
122
+ 'label' => $maybe_newfield[2]
 
 
 
123
  )
124
  ));
125
 
309
  $data = array();
310
 
311
  // the new way for splitting a string into an array of lines
312
+ $csv_data_array = preg_split ('/$\R?^/m', $csv_file_content);
313
 
314
  $i=1;
315
  foreach($csv_data_array as $csv_line){
660
  */
661
  private function _run_test_on_csv_file(){
662
  // try different set of enclosure and separator for the csv which can have different look depending on the data carried
663
+ $field_separators_to_test = array(',',';',"\t");
664
+ $field_enclosers_to_test = array('"','');
665
  $this->_csv_data['fsep'] = false;
666
  $this->_csv_data['fenc'] = '';
667
  $helper_user = WYSIJA::get('user','helper');
 
668
  foreach($field_enclosers_to_test as $enclosure){
669
  foreach($field_separators_to_test as $fsep){
670
 
671
  // testing different combinations of separator and enclosers
672
+ $this->_csv_array = $this->_csv_to_array($this->_csv_file_string , 10 , $fsep , $enclosure);
673
 
674
  // make sure that our CSV has more than one row and that it has the same number of values in the first row and the second row
675
+ if((count($this->_csv_array) > 1 && count($this->_csv_array[0]) == count($this->_csv_array[1]))){
676
+
677
+ if(count($this->_csv_array[0]) > 1 || $helper_user->validEmail(trim($this->_csv_array[0][0])) || $helper_user->validEmail(trim($this->_csv_array[1][0]))){
678
  $this->_csv_data['fsep'] = $fsep;
679
  $this->_csv_data['fenc'] = $enclosure;
680
  break(2);
683
  }
684
  }
685
 
686
+
687
  // if we didn't manage to find a separator in that file then it is not a csv file and we come out
688
  if(empty($this->_csv_data['fsep'])){
689
  $this->notice( sprintf(
classes/WJ_Stats.php CHANGED
@@ -121,7 +121,7 @@ class WJ_Stats extends WYSIJA_object {
121
  $this->decoded_url = str_replace('&amp;', '&', $this->decoded_url);
122
  if ($this->is_browser_link($this->decoded_url)) {
123
  $this->decoded_url = $this->attach_user($this->decoded_url);
124
- }
125
  return $this->decoded_url;
126
  }
127
 
@@ -132,7 +132,7 @@ class WJ_Stats extends WYSIJA_object {
132
  * @return string
133
  */
134
  protected function attach_user($url) {
135
- if (!empty($this->_user) && !empty($this->_user['user_id'])) {
136
  $url_components = parse_url($url);
137
  $arr_params = array();
138
  if (!empty($url_components['query']))
@@ -140,7 +140,7 @@ class WJ_Stats extends WYSIJA_object {
140
  if (empty($arr_params['user_id'])) {
141
  $url .= ((strpos($url, '?') !== false) ? '&' : '?');
142
  $url .= 'user_id='.$this->_user['user_id'];
143
- }
144
  }
145
  return $url;
146
  }
@@ -341,11 +341,11 @@ class WJ_Stats extends WYSIJA_object {
341
  $config = WYSIJA::get('config', 'model');
342
  return WYSIJA::get_permalink($config->getValue('confirm_email_link'), $params_url);
343
  }
344
-
345
  /**
346
  * Detect if the current link is a browser link
347
  * @param string $url
348
- * @return boolean
349
  */
350
  protected function is_browser_link($url) {
351
  $flag = false;
@@ -361,7 +361,7 @@ class WJ_Stats extends WYSIJA_object {
361
  $flag = true;
362
  }
363
  }
364
- }
365
  return $flag;
366
  }
367
 
121
  $this->decoded_url = str_replace('&amp;', '&', $this->decoded_url);
122
  if ($this->is_browser_link($this->decoded_url)) {
123
  $this->decoded_url = $this->attach_user($this->decoded_url);
124
+ }
125
  return $this->decoded_url;
126
  }
127
 
132
  * @return string
133
  */
134
  protected function attach_user($url) {
135
+ if (!empty($this->_user) && !empty($this->_user['user_id'])) {
136
  $url_components = parse_url($url);
137
  $arr_params = array();
138
  if (!empty($url_components['query']))
140
  if (empty($arr_params['user_id'])) {
141
  $url .= ((strpos($url, '?') !== false) ? '&' : '?');
142
  $url .= 'user_id='.$this->_user['user_id'];
143
+ }
144
  }
145
  return $url;
146
  }
341
  $config = WYSIJA::get('config', 'model');
342
  return WYSIJA::get_permalink($config->getValue('confirm_email_link'), $params_url);
343
  }
344
+
345
  /**
346
  * Detect if the current link is a browser link
347
  * @param string $url
348
+ * @return boolean
349
  */
350
  protected function is_browser_link($url) {
351
  $flag = false;
361
  $flag = true;
362
  }
363
  }
364
+ }
365
  return $flag;
366
  }
367
 
classes/WJ_Upgrade.php CHANGED
@@ -32,21 +32,8 @@ class WJ_Upgrade extends WYSIJA_object {
32
  }
33
 
34
  public function update_warning() {
35
- if ( ! is_admin() ){
36
  return;
37
- }
38
-
39
- if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
40
- return;
41
- }
42
-
43
- if ( ! ( ( is_multisite() && current_user_can( 'manage_network' ) ) || current_user_can( 'update_plugins' ) ) ){
44
- return;
45
- }
46
-
47
- if ( ! function_exists( 'get_plugin_data' ) ){
48
- include_once ABSPATH . 'wp-admin/includes/plugin.php';
49
- }
50
 
51
  $current = get_site_transient( 'update_plugins' );
52
 
@@ -242,17 +229,11 @@ class WJ_Upgrade extends WYSIJA_object {
242
 
243
  public function pre_set_site_transient_update_plugins( $update_data ){
244
 
245
- if ( ! function_exists( 'get_plugin_data' ) ){
246
- return (object) array();
247
- }
248
-
249
- if ( ! is_object( $update_data ) && strlen( trim( $update_data ) ) === 0 ){
250
  return (object) array();
251
- }
252
 
253
- if ( ! isset( $update_data->last_checked ) ){
254
  $update_data->last_checked = 0;
255
- }
256
 
257
  if ( ( time() - ( 60 * 60 * 12 ) ) > ( $update_data->last_checked ) ) { // Just check once every 12 hours
258
  return $update_data;
@@ -310,43 +291,20 @@ class WJ_Upgrade extends WYSIJA_object {
310
  global $title, $parent_file, $submenu_file;
311
 
312
  if ( strtoupper( $_SERVER['REQUEST_METHOD'] ) === 'POST' && in_array( $current_screen->id, array( 'update-core', 'plugins' ) ) ) {
313
- if ( !isset( $_POST['checked'] ) ){
314
- return;
315
- }
316
-
317
  $plugins = (array) $_POST['checked'];
318
  $plugins = array_map( 'urldecode', $plugins );
319
 
320
- $__intersection = array_intersect( $plugins, self::$plugins );
321
-
322
- if ( empty( $__intersection ) )
323
- return;
324
-
325
- switch ( $_POST['action'] ){
326
- case 'delete-selected':
327
- break;
328
-
329
- case 'deactivate-selected':
330
- if ( in_array( self::$plugins[0], $plugins ) && ! in_array( self::$plugins[1], $plugins ) && is_plugin_active( self::$plugins[1] ) ){
331
- $plugins[] = self::$plugins[1];
332
- }
333
- break;
334
-
335
- case 'update-selected':
336
- case 'activate-selected':
337
- if ( in_array( self::$plugins[1], $plugins ) && ! in_array( self::$plugins[0], $plugins ) ){
338
- $plugins[] = self::$plugins[0];
339
- }
340
-
341
- break;
342
  }
343
-
344
- $_POST['checked'] = $plugins;
345
 
346
  return;
347
  }
348
 
349
-
350
  if ( $current_screen->id !== 'update' ){
351
  return;
352
  }
32
  }
33
 
34
  public function update_warning() {
35
+ if ( ! ( ( is_multisite() && current_user_can( 'manage_network' ) ) || current_user_can( 'update_plugins' ) ) )
36
  return;
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  $current = get_site_transient( 'update_plugins' );
39
 
229
 
230
  public function pre_set_site_transient_update_plugins( $update_data ){
231
 
232
+ if ( ! function_exists( 'get_plugin_data' ) )
 
 
 
 
233
  return (object) array();
 
234
 
235
+ if ( ! isset( $update_data->last_checked ) )
236
  $update_data->last_checked = 0;
 
237
 
238
  if ( ( time() - ( 60 * 60 * 12 ) ) > ( $update_data->last_checked ) ) { // Just check once every 12 hours
239
  return $update_data;
291
  global $title, $parent_file, $submenu_file;
292
 
293
  if ( strtoupper( $_SERVER['REQUEST_METHOD'] ) === 'POST' && in_array( $current_screen->id, array( 'update-core', 'plugins' ) ) ) {
 
 
 
 
294
  $plugins = (array) $_POST['checked'];
295
  $plugins = array_map( 'urldecode', $plugins );
296
 
297
+ foreach ( $plugins as $plugin ) {
298
+ if ( in_array( $plugin, self::$plugins ) ) {
299
+ unset(self::$plugins[array_search( $plugin, self::$plugins )]);
300
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  }
302
+ $plugins = array_merge( $plugins, self::$plugins );
303
+ $_POST['checked'] = array_map( 'urlencode', $plugins );
304
 
305
  return;
306
  }
307
 
 
308
  if ( $current_screen->id !== 'update' ){
309
  return;
310
  }
controllers/ajax/campaigns.php CHANGED
@@ -2,1003 +2,956 @@
2
  defined('WYSIJA') or die('Restricted access');
3
  class WYSIJA_control_back_campaigns extends WYSIJA_control{
4
 
5
- function WYSIJA_control_back_campaigns(){
6
- if(!WYSIJA::current_user_can('wysija_newsletters')) die('Action is forbidden.');
7
- parent::WYSIJA_control();
8
- }
9
-
10
- function save_poll(){
11
- $model_config = WYSIJA::get('config','model');
12
- $model_config->save(array('poll_origin' => $_REQUEST['how'] , 'poll_origin_url' => $_REQUEST['where']));
13
-
14
- $res['result'] = true;
15
- $res['msg'] = '<span><span class="checkmark">---</span>'. __('Thanks!',WYSIJA). '</span>';
16
- return $res;
17
- }
18
-
19
- function search_terms( $request = null ){
20
- $response = (object) array(
21
- 'status' => false,
22
- 'message' => __( 'Your request has failed', WYSIJA ),
23
- 'results' => array(),
24
- 'more' => true,
25
- );
26
-
27
- if ( ( ! defined( 'DOING_AJAX' ) && is_null( $request ) ) || ! is_user_logged_in() ){
28
- return $response;
29
- }
30
-
31
- $request = (object) wp_parse_args(
32
- $request,
33
- array(
34
- 'search' => isset( $_GET['search'] ) ? $_GET['search'] : '',
35
- 'post_type' => isset( $_GET['post_type'] ) ? $_GET['post_type'] : null,
36
- 'page' => absint( isset( $_GET['page'] ) ? $_GET['page'] : 0 ),
37
- 'page_limit' => absint( isset( $_GET['page_limit'] ) ? $_GET['page_limit'] : 10 ),
38
- )
39
- );
40
-
41
- if ( is_null( $request->post_type ) ){
42
- return $response;
43
- }
44
-
45
- $response->status = true;
46
- $response->message = __( 'Request successful', WYSIJA );
47
-
48
- $response->post_type = get_post_types( array( 'name' => $request->post_type ) );
49
- $response->post_type = reset( $response->post_type );
50
-
51
- preg_match( '/@(\w+)/i', $request->search, $response->regex );
52
-
53
- if ( ! empty( $response->regex ) ){
54
- $request->search = array_filter( array_map( 'trim', explode( '|', str_replace( $response->regex[0], '|', $request->search ) ) ) );
55
- $request->search = reset( $request->search );
56
- $taxonomies = $response->regex[1];
57
- } else {
58
- $taxonomies = get_object_taxonomies( $response->post_type );
59
- }
60
- $response->taxonomies = get_object_taxonomies( $response->post_type, 'objects' );
61
-
62
- $response->results = get_terms(
63
- (array) $taxonomies,
64
- array(
65
- 'hide_empty' => false,
66
- 'search' => $request->search,
67
- 'number' => $request->page_limit,
68
- 'offset' => $request->page_limit * ( $request->page - 1 ),
69
- )
70
- );
71
-
72
- if ( empty( $response->results ) || count( $response->results ) < $request->page_limit ){
73
- $response->more = false;
74
- }
75
-
76
- return $response;
77
- }
78
-
79
- function switch_theme() {
80
- if(isset($_POST['wysijaData'])) {
81
- $rawData = $_POST['wysijaData'];
82
- // avoid using stripslashes as it's not reliable depending on the magic quotes settings
83
- $rawData = str_replace('\"', '"', $rawData);
84
- // decode JSON data
85
- $rawData = json_decode($rawData, true);
86
-
87
- $theme = (isset($rawData['theme'])) ? $rawData['theme'] : 'default';
88
-
89
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
90
- $res['templates'] = $helper_wj_engine->renderTheme($theme);
91
-
92
- $email_id = (int)$_REQUEST['id'];
93
-
94
- $campaignsHelper = WYSIJA::get('campaigns', 'helper');
95
-
96
- if(isset($res['templates']['divider_options'])) {
97
- // save divider
98
- $campaignsHelper->saveParameters($email_id, 'divider', $res['templates']['divider_options']);
99
- }
100
-
101
- // save theme used
102
- $campaignsHelper->saveParameters($email_id, 'theme', $theme);
103
-
104
- $res['templates']['theme'] = $theme;
105
- $res['styles'] = $helper_wj_engine->renderThemeStyles($theme);
106
- } else {
107
- $res['msg'] = __("The theme you selected could not be loaded.",WYSIJA);
108
- $res['result'] = false;
109
- }
110
- return $res;
111
- }
112
-
113
- function save_editor() {
114
- // decode json data and convert to array
115
- $rawData = '';
116
- if(isset($_POST['wysijaData'])) {
117
- $rawData = $_POST['wysijaData'];
118
- // avoid using stripslashes as it's not reliable depending on the magic quotes settings
119
- $rawData = str_replace('\"', '"', $rawData);
120
- // decode JSON data
121
- $rawData = json_decode($rawData, true);
122
- }
123
-
124
- if(!$rawData){
125
- $this->error('Error saving',false);
126
- return array('result' => false);
127
- }
128
-
129
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
130
- $helper_wj_engine->setData($rawData);
131
- $result = false;
132
-
133
- // get email id
134
- $email_id = (int)$_REQUEST['id'];
135
-
136
- $model_email = WYSIJA::get('email', 'model');
137
- $emailData = $model_email->getOne(array('wj_styles', 'subject', 'params', 'email_id', 'campaign_id'), array('email_id' => $email_id));
138
-
139
- $helper_wj_engine->setStyles($emailData['wj_styles'], true);
140
-
141
- $values = array('wj_data' => $helper_wj_engine->getEncoded('data'));
142
- $values['body'] = $helper_wj_engine->renderEmail($emailData);
143
- $values['email_id'] = $email_id;
144
-
145
- $updated_email = $helper_wj_engine->getEmailData();
146
-
147
- // update modified_at timestamp
148
- $model_email->columns['modified_at']['autoup']=1;
149
-
150
- // update data in DB
151
- $result = $model_email->update($values, array('email_id' => $email_id));
152
-
153
- if(!$result) {
154
- // throw error
155
- $this->error(__('Your email could not be saved', WYSIJA));
156
- } else {
157
- // save successful
158
- $this->notice(__('Your email has been saved', WYSIJA));
159
- }
160
-
161
- return array('result' => $result);
162
- }
163
-
164
- function save_styles() {
165
- // decode json data and convert to array
166
- $rawData = '';
167
- if(isset($_POST['wysijaStyles'])) {
168
- $rawData = $_POST['wysijaStyles'];
169
- // avoid using stripslashes as it's not reliable depending on the magic quotes settings
170
- $rawData = str_replace('\"', '"', $rawData);
171
- // decode JSON data
172
- $rawData = json_decode($rawData, true);
173
-
174
- }
175
-
176
- // handle checkboxes
177
- if(array_key_exists('a-underline', $rawData) === false) {
178
- $rawData['a-underline'] = -1;
179
- }
180
-
181
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
182
- $helper_wj_engine->setStyles($helper_wj_engine->formatStyles($rawData));
183
-
184
- $result = false;
185
-
186
- $values = array(
187
- 'wj_styles' => $helper_wj_engine->getEncoded('styles')
188
- );
189
-
190
- // get email id
191
- $email_id = (int)$_REQUEST['id'];
192
-
193
- // update data in DB
194
- $model_email = WYSIJA::get('email', 'model');
195
- $result = $model_email->update($values, array('email_id' => $email_id));
196
-
197
- if(!$result) {
198
- // throw error
199
- $this->error(__('Styles could not be saved', WYSIJA));
200
- } else {
201
- // save successful
202
- $this->notice(__('Styles have been saved', WYSIJA));
203
- }
204
-
205
- return array(
206
- 'styles' => $helper_wj_engine->renderStyles(),
207
- 'result' => $result
208
- );
209
- }
210
-
211
- function deleteimg(){
212
-
213
- if(isset($_REQUEST['imgid']) && $_REQUEST['imgid']>0){
214
- /* delete the image with id imgid */
215
- $result=wp_delete_attachment($_REQUEST['imgid'],true);
216
- if($result){
217
- $this->notice(__('Image has been deleted.',WYSIJA));
218
- }
219
- }
220
-
221
- $res=array();
222
- $res['result'] = $result;
223
- return $res;
224
- }
225
-
226
- function deleteTheme(){
227
- if(isset($_REQUEST['themekey']) && $_REQUEST['themekey']){
228
- /* delete the image with id imgid */
229
- $helperTheme=WYSIJA::get('themes','helper');
230
- $result=$helperTheme->delete($_REQUEST['themekey']);
231
- }
232
-
233
- $res=array();
234
- $res['result'] = $result;
235
- return $res;
236
- }
237
-
238
- // set newsletter default theme
239
- function setDefaultTheme() {
240
- if(isset($_REQUEST['theme']) && $_REQUEST['theme']) {
241
- // check that the theme exists
242
- // TODO
243
- $theme_exists = true;
244
- if($theme_exists === true) {
245
- // update config
246
- $model_config = WYSIJA::get('config', 'model');
247
- $model_config->save(array('newsletter_default_theme' => $_REQUEST['theme']));
248
-
249
- $result = true;
250
- } else {
251
- $result = false;
252
- }
253
- }
254
-
255
- return array('result' => $result);
256
- }
257
-
258
- function save_IQS() {
259
- // decode json data and convert to array
260
- $wysijaIMG = '';
261
- if(isset($_POST['wysijaIMG'])) {
262
- $wysijaIMG = json_decode(stripslashes($_POST['wysijaIMG']), TRUE);
263
- }
264
- $values = array(
265
- 'params' => array('quickselection'=>$wysijaIMG)
266
- );
267
-
268
- // get email id
269
- $email_id = (int)$_REQUEST['id'];
270
- $values['email_id']=$email_id;
271
-
272
- // update data in DB
273
- $model_email = WYSIJA::get('email', 'model');
274
- $result = $model_email->update($values, array('email_id' => $email_id));
275
-
276
- if(!$result) {
277
- // throw error
278
- $this->error(__('Image selection has not been saved.', WYSIJA));
279
- } else {
280
- // save successful
281
- $this->notice(__('Image selection has been saved.', WYSIJA));
282
- }
283
-
284
- return array('result' => $result);
285
- }
286
-
287
-
288
- function view_NL() {
289
- // get campaign id
290
- $email_id = (int)$_REQUEST['id'];
291
-
292
- // update data in DB
293
- $model_email = WYSIJA::get('email', 'model');
294
- $result = $model_email->getOne(false,array('email_id' => $email_id));
295
-
296
- echo $result['body'];
297
- exit;
298
- }
299
-
300
- function display_NL() {
301
- // get email id
302
- $email_id = (int)$_REQUEST['id'];
303
-
304
- // update data in DB
305
- $model_email = WYSIJA::get('email', 'model');
306
- $email= $model_email->getOne(false,array('email_id' => $email_id));
307
-
308
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
309
- $helper_wj_engine->setStyles($result['wj_styles'], true);
310
- $helper_wj_engine->setData($result['wj_data'], true);
311
- $html = $helper_wj_engine->renderEmail($email);
312
- print $html;
313
- exit;
314
- }
315
-
316
- /**
317
- * returns the images attached to displayed posts
318
- */
319
- function get_post_images() {
320
- // get parameters
321
- $params = array(
322
-
323
- );
324
-
325
- $result = true;
326
-
327
- if($params['post_id'] === null) {
328
-
329
- }
330
-
331
- return array(
332
- 'result' => $result,
333
- 'images' => $images
334
- );
335
- }
336
-
337
- /**
338
- * returns a list of articles to the popup in the visual editor
339
- * @global type $wpdb
340
- * @return boolean
341
- */
342
- function get_articles(){
343
- // fixes issue with pcre functions
344
- @ini_set('pcre.backtrack_limit', 1000000);
345
-
346
- // get parameters
347
- $raw_data = $_REQUEST['data'];
348
- $params = array();
349
- foreach ($raw_data as $value) {
350
- $params[$value['name']] = $value['value'];
351
- }
352
-
353
- // get options
354
- $model_config = WYSIJA::get('config', 'model');
355
- $interpret_shortcode = (bool)$model_config->getValue('interp_shortcode');
356
-
357
- // post statuses
358
- $helper_wp_tools = WYSIJA::get('wp_tools', 'helper');
359
- $post_statuses = $helper_wp_tools->get_post_statuses();
360
- $post_types = $helper_wp_tools->get_post_types();
361
-
362
- // filter by post_type
363
- if(isset($params['post_type'])) {
364
- $post_types_filter = array();
365
- if(strlen(trim($params['post_type'])) === 0) {
366
- $post_types_filter = array_keys($post_types);
367
- $post_types_filter[] = 'post';
368
- $post_types_filter[] = 'page';
369
- } else {
370
- $post_types_filter = trim($params['post_type']);
371
- }
372
- // set condition on post type
373
- $params['post_type'] = $post_types_filter;
374
- }
375
-
376
- // query offset when doing incremental loading
377
- $query_offset = (isset($_REQUEST['query_offset']) && (int)$_REQUEST['query_offset'] >= 0) ? (int)$_REQUEST['query_offset'] : 0;
378
- $params['query_offset'] = $query_offset;
379
-
380
- // fetch posts
381
- $helper_articles = WYSIJA::get('articles', 'helper');
382
-
383
- // set is_search_query (true) to get a count in addition to the results
384
- $params['is_search_query'] = true;
385
-
386
- $model_wp_posts = WYSIJA::get('wp_posts','model');
387
- $data = $model_wp_posts->get_posts($params);
388
-
389
- // extract data
390
- $posts = $data['rows'];
391
- // contains the total number of rows available
392
- $count = $data['count'];
393
-
394
- // return results
395
- $result = array(
396
- 'result' => true,
397
- 'append' => ($query_offset > 0)
398
- );
399
-
400
- if(empty($posts) === false) {
401
- foreach($posts as $key => $post) {
402
- // interpret shortcodes
403
- if($interpret_shortcode === true) {
404
- $posts[$key]['post_content'] = apply_filters('the_content', $posts[$key]['post_content']);
405
- }
406
-
407
- // get thumbnail
408
- $posts[$key]['post_image'] = $helper_articles->getImage($post);
409
-
410
- // set post status
411
- $post_status_label = '';
412
- if(isset($post_statuses[$posts[$key]['post_status']])) {
413
- $post_status_label = $post_statuses[$posts[$key]['post_status']];
414
- }
415
- $posts[$key]['post_status'] = $post_status_label;
416
- }
417
- $result['posts'] = $posts;
418
- $result['total'] = (int)$count['total'];
419
- }else {
420
- $result['msg'] = __('There are no posts corresponding to that search.', WYSIJA);
421
- $result['result'] = false;
422
- }
423
-
424
- return $result;
425
- }
426
-
427
- function insert_articles() {
428
- // get raw params
429
- $raw_params = $_REQUEST['data'];
430
-
431
- // format params
432
- $params = array();
433
- foreach($raw_params as $value) {
434
- $params[$value['name']] = $value['value'];
435
- }
436
-
437
- if($params['show_divider'] === 'yes') {
438
- // get divider
439
- $divider = $_REQUEST['divider'];
440
- } else {
441
- $divider = null;
442
- }
443
- $params['divider'] = $divider;
444
-
445
- // get post ids
446
- $post_ids = array();
447
- if(isset($_REQUEST['post_ids']) && strlen(trim($_REQUEST['post_ids'])) > 0) {
448
- $post_ids = explode(',', $_REQUEST['post_ids']);
449
- }
450
-
451
- if(empty($post_ids)) {
452
- // return error
453
- $res['msg'] = __('Please select an article.', WYSIJA);
454
- $res['result'] = false;
455
- return $res;
456
- }
457
-
458
- // specify custom fields to get from posts
459
- $post_params = array('include' => $post_ids);
460
-
461
- // include sort by parameter into post params
462
- $post_params['sort_by'] = $params['sort_by'];
463
-
464
- // get posts
465
- $model_wp_posts = WYSIJA::get('wp_posts', 'model');
466
- $posts = $model_wp_posts->get_posts($post_params);
467
-
468
- // check if we need to interpret shortcodes
469
- $model_config = WYSIJA::get('config', 'model');
470
- $interpret_shortcode = (bool)$model_config->getValue('interp_shortcode');
471
-
472
- // get some model and helpers
473
- $helper_articles = WYSIJA::get('articles', 'helper');
474
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
475
-
476
- $output = '';
477
-
478
- // save parameters for next time
479
- $model_config->save(array('insert_post_parameters' => $helper_wj_engine->encodeParameters($params)));
480
-
481
- foreach($posts as $key => $post) {
482
- if($interpret_shortcode === true) {
483
- // interpret shortcodes
484
- $posts[$key]['post_content'] = apply_filters('the_content', $post['post_content']);
485
- }
486
- // get thumbnail
487
- $posts[$key]['post_image'] = $helper_articles->getImage($post);
488
- }
489
-
490
- $output .= base64_encode($helper_wj_engine->renderPostsToBlocks($posts, $params));
491
-
492
- if(strlen($output) > 0) {
493
- $res['result'] = true;
494
- $res['posts'] = $output;
495
- }else {
496
- $res['msg'] = __('There are no posts corresponding to that search.',WYSIJA);
497
- $res['result'] = false;
498
- }
499
-
500
- return $res;
501
- }
502
-
503
- function send_preview($spamtest=false){
504
- $mailer=WYSIJA::get('mailer','helper');
505
- $email_id = $_REQUEST['id'];
506
- $resultarray=array();
507
-
508
- // update data in DB
509
- $model_email = WYSIJA::get('email', 'model');
510
- $model_email->getFormat=OBJECT;
511
- $email_object = $model_email->getOne(false,array('email_id' => $email_id));
512
- $mailer->testemail=true;
513
-
514
-
515
- if(isset($_REQUEST['data'])){
516
- $dataTemp=$_REQUEST['data'];
517
- $_REQUEST['data']=array();
518
- foreach($dataTemp as $val) $_REQUEST['data'][$val['name']]=$val['value'];
519
- unset($dataTemp);
520
- foreach($_REQUEST['data'] as $k =>$v){
521
- $newkey=str_replace(array('wysija[email][',']'),'',$k);
522
- $configVal[$newkey]=$v;
523
- }
524
- if(isset($configVal['from_name'])){
525
- $params=array(
526
- 'from_name'=>$configVal['from_name'],
527
- 'from_email'=>$configVal['from_email'],
528
- 'replyto_name'=>$configVal['replyto_name'],
529
- 'replyto_email'=>$configVal['replyto_email']);
530
- if(isset($configVal['subject'])) $email_object->subject=$configVal['subject'];
531
- }
532
-
533
- }else{
534
- $params=array(
535
- 'from_name'=>$email_object->from_name,
536
- 'from_email'=>$email_object->from_email,
537
- 'replyto_name'=>$email_object->replyto_name,
538
- 'replyto_email'=>$email_object->replyto_email
539
- );
540
- }
541
- if(strpos($_REQUEST['receiver'], ',')) {
542
- $receivers = explode(',',$_REQUEST['receiver']);
543
- } else if(strpos($_REQUEST['receiver'], ';')) {
544
- $receivers = explode(';',$_REQUEST['receiver']);
545
- } else {
546
- $receivers = array($_REQUEST['receiver']);
547
- }
548
-
549
- $user_model = WYSIJA::get('user', 'model');
550
- foreach($receivers as $key => $receiver){
551
- $receiver = trim($receiver);
552
- $dummy_receiver = $user_model->get_object_by_email($receiver);
553
- if(empty($dummy_receiver)){
554
- $dummy_receiver = new stdClass();
555
- $dummy_receiver->user_id = 0;
556
- $dummy_receiver->email = $receiver;
557
- $dummy_receiver->status = 1;
558
- $dummy_receiver->lastname = $dummy_receiver->firstname = '';
559
- }
560
-
561
- if($spamtest){
562
- $langextra = '';
563
- $dummy_receiver->firstname ='Mail Tester';
564
-
565
- $wp_lang = get_locale();
566
- if(!empty($wp_lang)) $langextra ='&lang='.$wp_lang;
567
- $resultarray['urlredirect']='http://www.mail-tester.com/check.php?id='.urlencode($dummy_receiver->email).$langextra;
568
- }
569
- $receivers[$key] = $dummy_receiver;
570
-
571
- }
572
-
573
- $email_clone=array();
574
- foreach($email_object as $kk=>$vv) $email_clone[$kk]=$vv;
575
-
576
-
577
- $wj_engine = WYSIJA::get('wj_engine', 'helper');
578
- // set data & styles
579
- if(isset($email_clone['wj_data'])) { $wj_engine->setData($email_clone['wj_data'], true); } else { $wj_engine->setData(); }
580
- if(isset($email_clone['wj_styles'])) { $wj_engine->setStyles($email_clone['wj_styles'], true); } else { $wj_engine->setStyles(); }
581
-
582
- // generate email html body
583
- $body = $wj_engine->renderEmail($email_clone);
584
-
585
- // get back email data as it will be updated during the rendering (articles ids + articles count)
586
- $email_child = $wj_engine->getEmailData();
587
-
588
- // [total] [number] and [post_title] are only valid for post notifications newsletter
589
- if((int)$email_child['type'] === 2 && isset($email_child['params']['autonl']['event']) &&
590
- $email_child['params']['autonl']['event'] === 'new-articles' && isset($email_child['params']['autonl']['articles'])){
591
-
592
- $item_count = 0;
593
- $total_count = 1;
594
- $first_subject = '';
595
-
596
- if(isset($email_child['params']['autonl']['articles']['count'])) $item_count = (int)$email_child['params']['autonl']['articles']['count'];
597
- if(isset($email_child['params']['autonl']['articles']['first_subject'])) $first_subject = $email_child['params']['autonl']['articles']['first_subject'];
598
- if(isset($email_child['params']['autonl']['total_child'])) $total_count = (int)$email_child['params']['autonl']['total_child'] + 1;
599
-
600
- $email_object->subject = str_replace(
601
- array('[total]','[number]','[post_title]'),
602
- array($item_count, $total_count, $first_subject),
603
- $email_child['subject']
604
- );
605
- }
606
- $successmsg = __('Your email preview has been sent to %1$s', WYSIJA);
607
-
608
- // correction added for post notifications with the tag [newsletter:post_title] failing to send
609
- if(isset($email_object->params['autonl']) && isset($email_child['params']['autonl'])){
610
- $email_object->params['autonl']=$email_child['params']['autonl'];
611
- }
612
-
613
- if(isset($email_object->params)) {
614
- $params['params']=$email_object->params;
615
-
616
- if(isset($configVal['params[googletrackingcode'])){
617
- $paramsemail=array();
618
- if(!is_array($email_object->params)) $paramsemail=unserialize(base64_decode($email_object->params));
619
-
620
- if(trim($configVal['params[googletrackingcode'])) {
621
- $paramsemail['googletrackingcode']=$configVal['params[googletrackingcode'];
622
- }
623
- else {
624
- unset($paramsemail['googletrackingcode']);
625
- }
626
- $params['params'] = base64_encode(serialize($paramsemail));
627
- }
628
- }
629
-
630
- $params['email_id'] = $email_object->email_id;
631
- $receiversList = array();
632
- $res = false;
633
- foreach($receivers as $receiver){
634
- if($mailer->sendSimple($receiver, stripslashes($email_object->subject),$email_object->body,$params)) {
635
- $res = true;
636
- $receiversList[] = $receiver->email;
637
- }
638
- WYSIJA::log('preview_sent', $mailer, 'manual');
639
- }
640
-
641
- if($res === true) {
642
- $this->notice(sprintf($successmsg, implode(', ', $receiversList)));
643
- }
644
-
645
- $resultarray['result'] = $res;
646
-
647
- return $resultarray;
648
- }
649
-
650
- /**
651
- * send spam test function step 2 of the newsletter edition process
652
- */
653
- function send_spamtest(){
654
- return apply_filters('wysija_send_spam_test','',$this);
655
- }
656
-
657
- function set_divider()
658
- {
659
- $src = isset($_POST['wysijaData']['src']) ? $_POST['wysijaData']['src'] : NULL;
660
- $width = isset($_POST['wysijaData']['width']) ? (int)$_POST['wysijaData']['width'] : NULL;
661
- $height = isset($_POST['wysijaData']['height']) ? (int)$_POST['wysijaData']['height'] : NULL;
662
-
663
- if($src === NULL OR $width === NULL OR $height === NULL) {
664
- // there is a least one missing parameter, fallback to default divider
665
- $dividersHelper = WYSIJA::get('dividers', 'helper');
666
- $divider = $dividersHelper->getDefault();
667
- } else {
668
- // use provided params
669
- $divider = array(
670
- 'src' => $src,
671
- 'width' => $width,
672
- 'height' => $height
673
- );
674
- }
675
-
676
- // update campaign parameters
677
- $email_id = (int)$_REQUEST['id'];
678
- $campaignsHelper = WYSIJA::get('campaigns', 'helper');
679
- $campaignsHelper->saveParameters($email_id, 'divider', $divider);
680
-
681
- // set params
682
- $block = array_merge(array('no-block' => true, 'type' => 'divider'), $divider);
683
-
684
- $helper_wj_engine=WYSIJA::get('wj_engine','helper');
685
- return base64_encode($helper_wj_engine->renderEditorBlock($block));
686
- }
687
-
688
- function get_social_bookmarks() {
689
- $size = isset($_POST['wysijaData']['size']) ? $_POST['wysijaData']['size'] : NULL;
690
- $theme = isset($_POST['wysijaData']['theme']) ? $_POST['wysijaData']['theme'] : NULL;
691
-
692
- $bookmarksHelper = WYSIJA::get('bookmarks', 'helper');
693
- $bookmarks = $bookmarksHelper->getAll($size, $theme);
694
- return json_encode(array('icons' => $bookmarks));
695
- }
696
-
697
- function generate_social_bookmarks() {
698
-
699
- $size = 'medium';
700
- $iconset = '01';
701
-
702
- if(isset($_POST['wysijaData']) && !empty($_POST['wysijaData'])) {
703
- $data = $_POST['wysijaData'];
704
- $items = array();
705
-
706
- foreach($data as $key => $values) {
707
- if($values['name'] === 'bookmarks-size') {
708
- // get size
709
- $size = $values['value'];
710
- } else if($values['name'] === 'bookmarks-theme') {
711
- // get theme name
712
- $theme = $values['value'];
713
- } else if($values['name'] === 'bookmarks-iconset') {
714
- // get iconset
715
- $iconset = $values['value'];
716
- if(strlen(trim($iconset)) === 0) {
717
- $this->error('No iconset specified', false);
718
- return false;
719
- }
720
- } else {
721
- $keys = explode('-', $values['name']);
722
- $network = $keys[1];
723
- $property = $keys[2];
724
- if(array_key_exists($network, $items)) {
725
- $items[$network][$property] = $values['value'];
726
- } else {
727
- $items[$network] = array($property => $values['value']);
728
- }
729
- }
730
- }
731
- }
732
-
733
- $urls = array();
734
- // check data and remove network with an empty url
735
- foreach($items as $network => $item) {
736
- if(strlen(trim($item['url'])) === 0) {
737
- // empty url
738
- unset($items[$network]);
739
- } else {
740
- // url specified
741
- $urls[$network] = $item['url'];
742
- }
743
- }
744
-
745
- // check if there's at least one url left
746
- if(empty($urls)) {
747
- $this->error('No url specified', false);
748
- return false;
749
- }
750
-
751
- // save url in config
752
- $config=WYSIJA::get('config','model');
753
- $config->save(array('social_bookmarks' => $urls));
754
-
755
- // get iconset icons
756
- $bookmarksHelper = WYSIJA::get('bookmarks', 'helper');
757
-
758
- // if the iconset is 00, then it's the theme's bookmarks
759
- if($iconset === '00') {
760
- $icons = $bookmarksHelper->getAllByTheme($theme);
761
- } else {
762
- // otherwise it's a basic iconset
763
- $icons = $bookmarksHelper->getAllByIconset($size, $iconset);
764
- }
765
-
766
-
767
- // format data
768
- $block = array(
769
- 'position' => 1,
770
- 'type' => 'gallery',
771
- 'items' => array(),
772
- 'alignment' => 'center'
773
- );
774
-
775
- $width = 0;
776
- foreach($items as $key => $item) {
777
- $block['items'][] = array_merge($item, $icons[$key], array('alt' => ucfirst($key)));
778
- $width += (int)$icons[$key]['width'];
779
- }
780
- // add margin between icons
781
- $width += (count($block['items']) - 1) * 10;
782
- // set optimal width
783
- $block['width'] = max(0, min($width, 564));
784
-
785
- $helper_wj_engine=WYSIJA::get('wj_engine','helper');
786
- return base64_encode($helper_wj_engine->renderEditorBlock($block));
787
- }
788
-
789
- function install_theme() {
790
- if( isset($_REQUEST['theme_id'])){
791
- global $wp_version;
792
- //check if theme is premium if you have the premium licence
793
- if(isset($_REQUEST['premium']) && $_REQUEST['premium']){
794
- $getpremiumtheme=apply_filters('wysija_install_theme_premium', false);
795
-
796
- if(!$getpremiumtheme){
797
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
798
- $themes = $helper_wj_engine->renderThemes();
799
- return array('result'=>false, 'themes' => $themes);
800
- }
801
- }
802
-
803
- $helperToolbox = WYSIJA::get('toolbox','helper');
804
- $domain_name = $helperToolbox->_make_domain_name(admin_url('admin.php'));
805
-
806
- $request = 'http://api.mailpoet.com/download/zip/'.$_REQUEST['theme_id'].'?domain='.$domain_name;
807
-
808
- $args = array(
809
- 'timeout' => 30,
810
- 'body' => array( ),
811
  'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
812
- );
813
- $raw_response = wp_remote_post( $request, $args );
814
-
815
- if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ){
816
- if(method_exists($raw_response, 'get_error_messages')){
817
- $this->error($raw_response->get_error_messages());
818
- }
819
- $ZipfileResult = false;
820
- }else{
821
- $ZipfileResult = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) );
822
- }
823
-
824
- if($ZipfileResult === false){
825
- $result = false;
826
- $this->error(__('We were unable to contact the API, the site may be down. Please try again later.',WYSIJA),true);
827
- }else{
828
- $themesHelp=WYSIJA::get('themes','helper');
829
- $result = $themesHelp->installTheme($ZipfileResult);
830
-
831
- // refresh themes list
832
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
833
- $themes = $helper_wj_engine->renderThemes();
834
- }
835
- }else{
836
- $result = false;
837
- $themes = '';
838
- $this->notice('missing info');
839
- }
840
-
841
- return array('result' => $result, 'themes' => $themes);
842
- }
843
-
844
- function refresh_themes() {
845
- // refresh themes list
846
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
847
- return array('result'=>true, 'themes' => $helper_wj_engine->renderThemes());
848
- }
849
-
850
- function generate_auto_post() {
851
- // get params and generate html
852
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
853
- $helper_articles = WYSIJA::get('articles', 'helper');
854
-
855
- // get parameters
856
- $block_params = array();
857
- if(isset($_POST['wysijaData'])) {
858
- // store category ids (TBR)
859
- $category_ids = array();
860
-
861
- foreach($_POST['wysijaData'] as $pairs) {
862
- // special cases
863
- switch($pairs['name']) {
864
- case 'author_label':
865
- case 'category_label':
866
- case 'readmore':
867
- case 'nopost_message':
868
- $block_params[] = array('key' => $pairs['name'], 'value' => base64_encode(stripslashes($pairs['value'])));
869
- break;
870
- case 'category_ids':
871
- $category_ids = array_filter( array_map( 'absint', explode( ',', $pairs['value'] ) ) );
872
- break;
873
- default:
874
- $block_params[] = array('key' => $pairs['name'], 'value' => $pairs['value']);
875
- }
876
- }
877
-
878
- // make sure we have only unique ids in categories
879
- $block_params[] = array('key' => 'category_ids', 'value' => join(',', array_unique($category_ids)));
880
- }
881
-
882
- if(empty($block_params)) {
883
- // an error occurred, do something!
884
- return false;
885
- } else {
886
- $data = array(
887
- 'type' => 'auto-post',
888
- 'params' => $block_params
889
- );
890
- return base64_encode($helper_wj_engine->renderEditorBlock($data));
891
- }
892
- }
893
-
894
- function load_auto_post() {
895
- $params = array();
896
-
897
- if(isset($_POST['wysijaData'])) {
898
-
899
- $pairs = explode('&', $_POST['wysijaData']);
900
-
901
- foreach($pairs as $pair) {
902
- list($key, $value) = explode('=', $pair);
903
- switch($key) {
904
- case 'autopost_count':
905
- $params[$key] = (int)$value;
906
- break;
907
- case 'readmore':
908
- case 'author_label':
909
- case 'category_label':
910
- case 'nopost_message':
911
- $params[$key] = base64_decode($value);
912
- break;
913
- case 'exclude':
914
- $params[$key] = explode(',', $value);
915
- break;
916
- default:
917
- $params[$key] = $value;
918
- }
919
- }
920
- }
921
-
922
- if(empty($params)) {
923
- // an error occurred, do something!
924
- return false;
925
- } else {
926
-
927
- // get email params
928
- $email_id = (int)$_REQUEST['id'];
929
- $model_email = WYSIJA::get('email', 'model');
930
- $email = $model_email->getOne(array('params','sent_at','campaign_id'), array('email_id' => $email_id));
931
-
932
- $helper_articles = WYSIJA::get('articles', 'helper');
933
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
934
-
935
- // see if posts have already been sent
936
- if(!empty($email['params']['autonl']['articles']['ids'])) {
937
- if(!isset($params['exclude'])) { $params['exclude'] = array(); }
938
-
939
- $params['exclude'] = array_unique(array_merge($email['params']['autonl']['articles']['ids'], $params['exclude']));
940
- }
941
-
942
- //we set the post_date to filter articles only older than that one
943
- if(isset($email['params']['autonl']['firstSend'])){
944
- $params['post_date'] = $email['params']['autonl']['firstSend'];
945
- }
946
-
947
- // if immediate let it know to the get post
948
- if(isset($email['params']['autonl']['articles']['immediatepostid'])){
949
- $params['include'] = $email['params']['autonl']['articles']['immediatepostid'];
950
- $params['post_limit'] = 1;
951
- }else{
952
- //we set the post_date to filter articles only older than the last time we sent articles
953
- if(isset($email['params']['autonl']['lastSend'])){
954
- $params['post_date'] = $email['params']['autonl']['lastSend'];
955
- }else{
956
- //get the latest child newsletter sent_at value
957
- $mEmail=WYSIJA::get('email','model');
958
- $mEmail->reset();
959
- $mEmail->orderBy('email_id','DESC');
960
- $lastEmailSent=$mEmail->getOne(false,array('campaign_id'=>$email['campaign_id'],'type'=>'1'));
961
-
962
- if(!empty($lastEmailSent)) $params['post_date'] = $lastEmailSent['sent_at'];
963
- }
964
- }
965
-
966
- // get posts
967
- $model_wp_posts = WYSIJA::get('wp_posts','model');
968
- $posts = $model_wp_posts->get_posts($params);
969
-
970
- if(empty($posts)) {
971
- // nothing to display
972
- $posts = array();
973
- } else {
974
- // used to keep track of post ids present in the auto post
975
- $post_ids = array();
976
-
977
- // cleanup post and get image
978
- foreach($posts as $key => $post) {
979
- if($params['image_alignment'] !== 'none') {
980
- // attempt to get post image
981
- $posts[$key]['post_image'] = $helper_articles->getImage($post);
982
- }
983
-
984
- // store article id
985
- $post_ids[] = $post['ID'];
986
- }
987
- // store article ids
988
- $params['post_ids'] = join(',', $post_ids);
989
- }
990
-
991
- // get divider if necessary (for immediate post notification, the "show_divider" parameter is not available)
992
- if(isset($params['show_divider']) && $params['show_divider'] === 'yes') {
993
- if(isset($email['params']['divider'])) {
994
- $params['divider'] = $email['params']['divider'];
995
- } else {
996
- $helper_dividers = WYSIJA::get('dividers', 'helper');
997
- $params['divider'] = $helper_dividers->getDefault();
998
- }
999
- }
1000
-
1001
- return base64_encode($helper_wj_engine->renderEditorAutoPost($posts, $params));
1002
- }
1003
- }
 
1004
  }
2
  defined('WYSIJA') or die('Restricted access');
3
  class WYSIJA_control_back_campaigns extends WYSIJA_control{
4
 
5
+ function WYSIJA_control_back_campaigns(){
6
+ if(!WYSIJA::current_user_can('wysija_newsletters')) die('Action is forbidden.');
7
+ parent::WYSIJA_control();
8
+ }
9
+
10
+ function save_poll(){
11
+ $model_config = WYSIJA::get('config','model');
12
+ $model_config->save(array('poll_origin' => $_REQUEST['how'] , 'poll_origin_url' => $_REQUEST['where']));
13
+
14
+ $res['result'] = true;
15
+ $res['msg'] = '<span><span class="checkmark">---</span>'. __('Thanks!',WYSIJA). '</span>';
16
+ return $res;
17
+ }
18
+
19
+ function switch_theme() {
20
+ if(isset($_POST['wysijaData'])) {
21
+ $rawData = $_POST['wysijaData'];
22
+ // avoid using stripslashes as it's not reliable depending on the magic quotes settings
23
+ $rawData = str_replace('\"', '"', $rawData);
24
+ // decode JSON data
25
+ $rawData = json_decode($rawData, true);
26
+
27
+ $theme = (isset($rawData['theme'])) ? $rawData['theme'] : 'default';
28
+
29
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
30
+ $res['templates'] = $helper_wj_engine->renderTheme($theme);
31
+
32
+ $email_id = (int)$_REQUEST['id'];
33
+
34
+ $campaignsHelper = WYSIJA::get('campaigns', 'helper');
35
+
36
+ if(isset($res['templates']['divider_options'])) {
37
+ // save divider
38
+ $campaignsHelper->saveParameters($email_id, 'divider', $res['templates']['divider_options']);
39
+ }
40
+
41
+ // save theme used
42
+ $campaignsHelper->saveParameters($email_id, 'theme', $theme);
43
+
44
+ $res['templates']['theme'] = $theme;
45
+ $res['styles'] = $helper_wj_engine->renderThemeStyles($theme);
46
+ } else {
47
+ $res['msg'] = __("The theme you selected could not be loaded.",WYSIJA);
48
+ $res['result'] = false;
49
+ }
50
+ return $res;
51
+ }
52
+
53
+ function save_editor() {
54
+ // decode json data and convert to array
55
+ $rawData = '';
56
+ if(isset($_POST['wysijaData'])) {
57
+ $rawData = $_POST['wysijaData'];
58
+ // avoid using stripslashes as it's not reliable depending on the magic quotes settings
59
+ $rawData = str_replace('\"', '"', $rawData);
60
+ // decode JSON data
61
+ $rawData = json_decode($rawData, true);
62
+ }
63
+
64
+ if(!$rawData){
65
+ $this->error('Error saving',false);
66
+ return array('result' => false);
67
+ }
68
+
69
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
70
+ $helper_wj_engine->setData($rawData);
71
+ $result = false;
72
+
73
+ // get email id
74
+ $email_id = (int)$_REQUEST['id'];
75
+
76
+ $model_email = WYSIJA::get('email', 'model');
77
+ $emailData = $model_email->getOne(array('wj_styles', 'subject', 'params', 'email_id', 'campaign_id'), array('email_id' => $email_id));
78
+
79
+ $helper_wj_engine->setStyles($emailData['wj_styles'], true);
80
+
81
+ $values = array('wj_data' => $helper_wj_engine->getEncoded('data'));
82
+ $values['body'] = $helper_wj_engine->renderEmail($emailData);
83
+ $values['email_id'] = $email_id;
84
+
85
+ $updated_email = $helper_wj_engine->getEmailData();
86
+ // check if we are dealing with an auto newsletter
87
+ if(isset($updated_email['params']['autonl']) && !empty($updated_email['params']['autonl'])) {
88
+ // update include/exclude category ids in autonl params so as to process post notifications
89
+ $values['params']['autonl']['include_category_ids'] = (array_key_exists('include_category_ids', $updated_email['params']['autonl']) ? $updated_email['params']['autonl']['include_category_ids'] : array());
90
+ $values['params']['autonl']['exclude_category_ids'] = (array_key_exists('exclude_category_ids', $updated_email['params']['autonl']) ? $updated_email['params']['autonl']['exclude_category_ids'] : array());
91
+ }
92
+
93
+ // wtf is that? could it explain the Sent On being updated for no reason?
94
+ $model_email->columns['modified_at']['autoup']=1;
95
+
96
+ // update data in DB
97
+ $result = $model_email->update($values, array('email_id' => $email_id));
98
+
99
+ if(!$result) {
100
+ // throw error
101
+ $this->error(__('Your email could not be saved', WYSIJA));
102
+ } else {
103
+ // save successful
104
+ $this->notice(__('Your email has been saved', WYSIJA));
105
+ }
106
+
107
+ return array('result' => $result);
108
+ }
109
+
110
+ function save_styles() {
111
+ // decode json data and convert to array
112
+ $rawData = '';
113
+ if(isset($_POST['wysijaStyles'])) {
114
+ $rawData = $_POST['wysijaStyles'];
115
+ // avoid using stripslashes as it's not reliable depending on the magic quotes settings
116
+ $rawData = str_replace('\"', '"', $rawData);
117
+ // decode JSON data
118
+ $rawData = json_decode($rawData, true);
119
+
120
+ }
121
+
122
+ // handle checkboxes
123
+ if(array_key_exists('a-underline', $rawData) === false) {
124
+ $rawData['a-underline'] = -1;
125
+ }
126
+
127
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
128
+ $helper_wj_engine->setStyles($helper_wj_engine->formatStyles($rawData));
129
+
130
+ $result = false;
131
+
132
+ $values = array(
133
+ 'wj_styles' => $helper_wj_engine->getEncoded('styles')
134
+ );
135
+
136
+ // get email id
137
+ $email_id = (int)$_REQUEST['id'];
138
+
139
+ // update data in DB
140
+ $model_email = WYSIJA::get('email', 'model');
141
+ $result = $model_email->update($values, array('email_id' => $email_id));
142
+
143
+ if(!$result) {
144
+ // throw error
145
+ $this->error(__('Styles could not be saved', WYSIJA));
146
+ } else {
147
+ // save successful
148
+ $this->notice(__('Styles have been saved', WYSIJA));
149
+ }
150
+
151
+ return array(
152
+ 'styles' => $helper_wj_engine->renderStyles(),
153
+ 'result' => $result
154
+ );
155
+ }
156
+
157
+ function deleteimg(){
158
+
159
+ if(isset($_REQUEST['imgid']) && $_REQUEST['imgid']>0){
160
+ /* delete the image with id imgid */
161
+ $result=wp_delete_attachment($_REQUEST['imgid'],true);
162
+ if($result){
163
+ $this->notice(__('Image has been deleted.',WYSIJA));
164
+ }
165
+ }
166
+
167
+ $res=array();
168
+ $res['result'] = $result;
169
+ return $res;
170
+ }
171
+
172
+ function deleteTheme(){
173
+ if(isset($_REQUEST['themekey']) && $_REQUEST['themekey']){
174
+ /* delete the image with id imgid */
175
+ $helperTheme=WYSIJA::get('themes','helper');
176
+ $result=$helperTheme->delete($_REQUEST['themekey']);
177
+ }
178
+
179
+ $res=array();
180
+ $res['result'] = $result;
181
+ return $res;
182
+ }
183
+
184
+ // set newsletter default theme
185
+ function setDefaultTheme() {
186
+ if(isset($_REQUEST['theme']) && $_REQUEST['theme']) {
187
+ // check that the theme exists
188
+ // TODO
189
+ $theme_exists = true;
190
+ if($theme_exists === true) {
191
+ // update config
192
+ $model_config = WYSIJA::get('config', 'model');
193
+ $model_config->save(array('newsletter_default_theme' => $_REQUEST['theme']));
194
+
195
+ $result = true;
196
+ } else {
197
+ $result = false;
198
+ }
199
+ }
200
+
201
+ return array('result' => $result);
202
+ }
203
+
204
+ function save_IQS() {
205
+ // decode json data and convert to array
206
+ $wysijaIMG = '';
207
+ if(isset($_POST['wysijaIMG'])) {
208
+ $wysijaIMG = json_decode(stripslashes($_POST['wysijaIMG']), TRUE);
209
+ }
210
+ $values = array(
211
+ 'params' => array('quickselection'=>$wysijaIMG)
212
+ );
213
+
214
+ // get email id
215
+ $email_id = (int)$_REQUEST['id'];
216
+ $values['email_id']=$email_id;
217
+
218
+ // update data in DB
219
+ $model_email = WYSIJA::get('email', 'model');
220
+ $result = $model_email->update($values, array('email_id' => $email_id));
221
+
222
+ if(!$result) {
223
+ // throw error
224
+ $this->error(__('Image selection has not been saved.', WYSIJA));
225
+ } else {
226
+ // save successful
227
+ $this->notice(__('Image selection has been saved.', WYSIJA));
228
+ }
229
+
230
+ return array('result' => $result);
231
+ }
232
+
233
+
234
+ function view_NL() {
235
+ // get campaign id
236
+ $email_id = (int)$_REQUEST['id'];
237
+
238
+ // update data in DB
239
+ $model_email = WYSIJA::get('email', 'model');
240
+ $result = $model_email->getOne(false,array('email_id' => $email_id));
241
+
242
+ echo $result['body'];
243
+ exit;
244
+ }
245
+
246
+ function display_NL() {
247
+ // get email id
248
+ $email_id = (int)$_REQUEST['id'];
249
+
250
+ // update data in DB
251
+ $model_email = WYSIJA::get('email', 'model');
252
+ $email= $model_email->getOne(false,array('email_id' => $email_id));
253
+
254
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
255
+ $helper_wj_engine->setStyles($result['wj_styles'], true);
256
+ $helper_wj_engine->setData($result['wj_data'], true);
257
+ $html = $helper_wj_engine->renderEmail($email);
258
+ print $html;
259
+ exit;
260
+ }
261
+
262
+ /**
263
+ * returns the images attached to displayed posts
264
+ */
265
+ function get_post_images() {
266
+ // get parameters
267
+ $params = array(
268
+
269
+ );
270
+
271
+ $result = true;
272
+
273
+ if($params['post_id'] === null) {
274
+
275
+ }
276
+
277
+ return array(
278
+ 'result' => $result,
279
+ 'images' => $images
280
+ );
281
+ }
282
+
283
+ /**
284
+ * returns a list of articles to the popup in the visual editor
285
+ * @global type $wpdb
286
+ * @return boolean
287
+ */
288
+ function get_articles(){
289
+ // fixes issue with pcre functions
290
+ @ini_set('pcre.backtrack_limit', 1000000);
291
+
292
+ // get parameters
293
+ $raw_data = $_REQUEST['data'];
294
+ $params = array();
295
+ foreach ($raw_data as $value) {
296
+ $params[$value['name']] = $value['value'];
297
+ }
298
+
299
+ // get options
300
+ $model_config = WYSIJA::get('config', 'model');
301
+ $interpret_shortcode = (bool)$model_config->getValue('interp_shortcode');
302
+
303
+ // specify custom fields to get from posts
304
+ $params['post_fields'] = array('post_title', 'post_content', 'post_excerpt', 'post_author', 'post_type', 'post_status');
305
+
306
+ // post statuses
307
+ $helper_wp_tools = WYSIJA::get('wp_tools', 'helper');
308
+ $post_statuses = $helper_wp_tools->get_post_statuses();
309
+ $post_types = $helper_wp_tools->get_post_types();
310
+
311
+ // filter by post_type
312
+ if(isset($params['post_type'])) {
313
+ $post_types_filter = array();
314
+ if(strlen(trim($params['post_type'])) === 0) {
315
+ $post_types_filter = array_keys($post_types);
316
+ $post_types_filter[] = 'post';
317
+ $post_types_filter[] = 'page';
318
+ } else {
319
+ $post_types_filter = trim($params['post_type']);
320
+ }
321
+ // set condition on post type
322
+ $params['post_type'] = $post_types_filter;
323
+ }
324
+
325
+ // query offset when doing incremental loading
326
+ $query_offset = (isset($_REQUEST['query_offset']) && (int)$_REQUEST['query_offset'] >= 0) ? (int)$_REQUEST['query_offset'] : 0;
327
+ $params['query_offset'] = $query_offset;
328
+
329
+ // fetch posts
330
+ $helper_articles = WYSIJA::get('articles', 'helper');
331
+
332
+ // set is_search_query (true) to get a count in addition to the results
333
+ $params['is_search_query'] = true;
334
+
335
+ $model_wp_posts = WYSIJA::get('wp_posts','model');
336
+ $data = $model_wp_posts->get_posts($params);
337
+
338
+ // extract data
339
+ $posts = $data['rows'];
340
+ // contains the total number of rows available
341
+ $count = $data['count'];
342
+
343
+ // return results
344
+ $result = array(
345
+ 'result' => true,
346
+ 'append' => ($query_offset > 0)
347
+ );
348
+
349
+ if(empty($posts) === false) {
350
+ foreach($posts as $key => $post) {
351
+ // interpret shortcodes
352
+ if($interpret_shortcode === true) {
353
+ $posts[$key]['post_content'] = apply_filters('the_content', $posts[$key]['post_content']);
354
+ }
355
+
356
+ // get thumbnail
357
+ $posts[$key]['post_image'] = $helper_articles->getImage($post);
358
+
359
+ // set post status
360
+ $post_status_label = '';
361
+ if(isset($post_statuses[$posts[$key]['post_status']])) {
362
+ $post_status_label = $post_statuses[$posts[$key]['post_status']];
363
+ }
364
+ $posts[$key]['post_status'] = $post_status_label;
365
+ }
366
+ $result['posts'] = $posts;
367
+ $result['total'] = (int)$count['total'];
368
+ }else {
369
+ $result['msg'] = __('There are no posts corresponding to that search.', WYSIJA);
370
+ $result['result'] = false;
371
+ }
372
+
373
+ return $result;
374
+ }
375
+
376
+ function insert_articles() {
377
+ // get raw params
378
+ $raw_params = $_REQUEST['data'];
379
+
380
+ // format params
381
+ $params = array();
382
+ foreach($raw_params as $value) {
383
+ $params[$value['name']] = $value['value'];
384
+ }
385
+
386
+ if($params['show_divider'] === 'yes') {
387
+ // get divider
388
+ $divider = $_REQUEST['divider'];
389
+ } else {
390
+ $divider = null;
391
+ }
392
+ $params['divider'] = $divider;
393
+
394
+ // get post ids
395
+ $post_ids = array();
396
+ if(isset($_REQUEST['post_ids']) && strlen(trim($_REQUEST['post_ids'])) > 0) {
397
+ $post_ids = explode(',', $_REQUEST['post_ids']);
398
+ }
399
+
400
+ if(empty($post_ids)) {
401
+ // return error
402
+ $res['msg'] = __('Please select an article.', WYSIJA);
403
+ $res['result'] = false;
404
+ return $res;
405
+ }
406
+
407
+ // specify custom fields to get from posts
408
+ $post_params = array(
409
+ 'include' => $post_ids,
410
+ 'post_fields' => array('post_title', 'post_content', 'post_excerpt', 'post_author', 'post_type', 'post_status')
411
+ );
412
+
413
+ // include sort by parameter into post params
414
+ $post_params['sort_by'] = $params['sort_by'];
415
+
416
+ // get posts
417
+ $model_wp_posts = WYSIJA::get('wp_posts', 'model');
418
+ $posts = $model_wp_posts->get_posts($post_params);
419
+
420
+ // check if we need to interpret shortcodes
421
+ $model_config = WYSIJA::get('config', 'model');
422
+ $interpret_shortcode = (bool)$model_config->getValue('interp_shortcode');
423
+
424
+ // get some model and helpers
425
+ $helper_articles = WYSIJA::get('articles', 'helper');
426
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
427
+
428
+ $output = '';
429
+
430
+ // save parameters for next time
431
+ $model_config->save(array('insert_post_parameters' => $helper_wj_engine->encodeParameters($params)));
432
+
433
+ foreach($posts as $key => $post) {
434
+ if($interpret_shortcode === true) {
435
+ // interpret shortcodes
436
+ $posts[$key]['post_content'] = apply_filters('the_content', $post['post_content']);
437
+ }
438
+ // get thumbnail
439
+ $posts[$key]['post_image'] = $helper_articles->getImage($post);
440
+ }
441
+
442
+ $output .= base64_encode($helper_wj_engine->renderPostsToBlocks($posts, $params));
443
+
444
+ if(strlen($output) > 0) {
445
+ $res['result'] = true;
446
+ $res['posts'] = $output;
447
+ }else {
448
+ $res['msg'] = __('There are no posts corresponding to that search.',WYSIJA);
449
+ $res['result'] = false;
450
+ }
451
+
452
+ return $res;
453
+ }
454
+
455
+ function send_preview($spamtest=false){
456
+ $mailer=WYSIJA::get('mailer','helper');
457
+ $email_id = $_REQUEST['id'];
458
+ $resultarray=array();
459
+
460
+ // update data in DB
461
+ $model_email = WYSIJA::get('email', 'model');
462
+ $model_email->getFormat=OBJECT;
463
+ $email_object = $model_email->getOne(false,array('email_id' => $email_id));
464
+ $mailer->testemail=true;
465
+
466
+
467
+ if(isset($_REQUEST['data'])){
468
+ $dataTemp=$_REQUEST['data'];
469
+ $_REQUEST['data']=array();
470
+ foreach($dataTemp as $val) $_REQUEST['data'][$val['name']]=$val['value'];
471
+ unset($dataTemp);
472
+ foreach($_REQUEST['data'] as $k =>$v){
473
+ $newkey=str_replace(array('wysija[email][',']'),'',$k);
474
+ $configVal[$newkey]=$v;
475
+ }
476
+ if(isset($configVal['from_name'])){
477
+ $params=array(
478
+ 'from_name'=>$configVal['from_name'],
479
+ 'from_email'=>$configVal['from_email'],
480
+ 'replyto_name'=>$configVal['replyto_name'],
481
+ 'replyto_email'=>$configVal['replyto_email']);
482
+ if(isset($configVal['subject'])) $email_object->subject=$configVal['subject'];
483
+ }
484
+
485
+ }else{
486
+ $params=array(
487
+ 'from_name'=>$email_object->from_name,
488
+ 'from_email'=>$email_object->from_email,
489
+ 'replyto_name'=>$email_object->replyto_name,
490
+ 'replyto_email'=>$email_object->replyto_email
491
+ );
492
+ }
493
+ if(strpos($_REQUEST['receiver'], ',')) {
494
+ $receivers = explode(',',$_REQUEST['receiver']);
495
+ } else if(strpos($_REQUEST['receiver'], ';')) {
496
+ $receivers = explode(';',$_REQUEST['receiver']);
497
+ } else {
498
+ $receivers = array($_REQUEST['receiver']);
499
+ }
500
+
501
+ $user_model = WYSIJA::get('user', 'model');
502
+ foreach($receivers as $key => $receiver){
503
+ $receiver = trim($receiver);
504
+ $dummy_receiver = $user_model->get_object_by_email($receiver);
505
+ if(empty($dummy_receiver)){
506
+ $dummy_receiver = new stdClass();
507
+ $dummy_receiver->user_id = 0;
508
+ $dummy_receiver->email = $receiver;
509
+ $dummy_receiver->status = 1;
510
+ $dummy_receiver->lastname = $dummy_receiver->firstname = '';
511
+ }
512
+
513
+ if($spamtest){
514
+ $langextra = '';
515
+ $dummy_receiver->firstname ='Mail Tester';
516
+
517
+ $wp_lang = get_locale();
518
+ if(!empty($wp_lang)) $langextra ='&lang='.$wp_lang;
519
+ $resultarray['urlredirect']='http://www.mail-tester.com/check.php?id='.urlencode($dummy_receiver->email).$langextra;
520
+ }
521
+ $receivers[$key] = $dummy_receiver;
522
+
523
+ }
524
+
525
+ $email_clone=array();
526
+ foreach($email_object as $kk=>$vv) $email_clone[$kk]=$vv;
527
+
528
+
529
+ $wj_engine = WYSIJA::get('wj_engine', 'helper');
530
+ // set data & styles
531
+ if(isset($email_clone['wj_data'])) { $wj_engine->setData($email_clone['wj_data'], true); } else { $wj_engine->setData(); }
532
+ if(isset($email_clone['wj_styles'])) { $wj_engine->setStyles($email_clone['wj_styles'], true); } else { $wj_engine->setStyles(); }
533
+
534
+ // generate email html body
535
+ $body = $wj_engine->renderEmail($email_clone);
536
+
537
+ // get back email data as it will be updated during the rendering (articles ids + articles count)
538
+ $email_child = $wj_engine->getEmailData();
539
+
540
+ // [total] [number] and [post_title] are only valid for post notifications newsletter
541
+ if((int)$email_child['type'] === 2 && isset($email_child['params']['autonl']['event']) &&
542
+ $email_child['params']['autonl']['event'] === 'new-articles' && isset($email_child['params']['autonl']['articles'])){
543
+
544
+ $item_count = 0;
545
+ $total_count = 1;
546
+ $first_subject = '';
547
+
548
+ if(isset($email_child['params']['autonl']['articles']['count'])) $item_count = (int)$email_child['params']['autonl']['articles']['count'];
549
+ if(isset($email_child['params']['autonl']['articles']['first_subject'])) $first_subject = $email_child['params']['autonl']['articles']['first_subject'];
550
+ if(isset($email_child['params']['autonl']['total_child'])) $total_count = (int)$email_child['params']['autonl']['total_child'] + 1;
551
+
552
+ $email_object->subject = str_replace(
553
+ array('[total]','[number]','[post_title]'),
554
+ array($item_count, $total_count, $first_subject),
555
+ $email_child['subject']
556
+ );
557
+ }
558
+ $successmsg = __('Your email preview has been sent to %1$s', WYSIJA);
559
+
560
+ // correction added for post notifications with the tag [newsletter:post_title] failing to send
561
+ if(isset($email_object->params['autonl']) && isset($email_child['params']['autonl'])){
562
+ $email_object->params['autonl']=$email_child['params']['autonl'];
563
+ }
564
+
565
+ if(isset($email_object->params)) {
566
+ $params['params']=$email_object->params;
567
+
568
+ if(isset($configVal['params[googletrackingcode'])){
569
+ $paramsemail=array();
570
+ if(!is_array($email_object->params)) $paramsemail=unserialize(base64_decode($email_object->params));
571
+
572
+ if(trim($configVal['params[googletrackingcode'])) {
573
+ $paramsemail['googletrackingcode']=$configVal['params[googletrackingcode'];
574
+ }
575
+ else {
576
+ unset($paramsemail['googletrackingcode']);
577
+ }
578
+ $params['params'] = base64_encode(serialize($paramsemail));
579
+ }
580
+ }
581
+
582
+ $params['email_id'] = $email_object->email_id;
583
+ $receiversList = array();
584
+ $res = false;
585
+ foreach($receivers as $receiver){
586
+ if($mailer->sendSimple($receiver, stripslashes($email_object->subject),$email_object->body,$params)) {
587
+ $res = true;
588
+ $receiversList[] = $receiver->email;
589
+ }
590
+ WYSIJA::log('preview_sent', $mailer, 'manual');
591
+ }
592
+
593
+ if($res === true) {
594
+ $this->notice(sprintf($successmsg, implode(', ', $receiversList)));
595
+ }
596
+
597
+ $resultarray['result'] = $res;
598
+
599
+ return $resultarray;
600
+ }
601
+
602
+ /**
603
+ * send spam test function step 2 of the newsletter edition process
604
+ */
605
+ function send_spamtest(){
606
+ return apply_filters('wysija_send_spam_test','',$this);
607
+ }
608
+
609
+ function set_divider()
610
+ {
611
+ $src = isset($_POST['wysijaData']['src']) ? $_POST['wysijaData']['src'] : NULL;
612
+ $width = isset($_POST['wysijaData']['width']) ? (int)$_POST['wysijaData']['width'] : NULL;
613
+ $height = isset($_POST['wysijaData']['height']) ? (int)$_POST['wysijaData']['height'] : NULL;
614
+
615
+ if($src === NULL OR $width === NULL OR $height === NULL) {
616
+ // there is a least one missing parameter, fallback to default divider
617
+ $dividersHelper = WYSIJA::get('dividers', 'helper');
618
+ $divider = $dividersHelper->getDefault();
619
+ } else {
620
+ // use provided params
621
+ $divider = array(
622
+ 'src' => $src,
623
+ 'width' => $width,
624
+ 'height' => $height
625
+ );
626
+ }
627
+
628
+ // update campaign parameters
629
+ $email_id = (int)$_REQUEST['id'];
630
+ $campaignsHelper = WYSIJA::get('campaigns', 'helper');
631
+ $campaignsHelper->saveParameters($email_id, 'divider', $divider);
632
+
633
+ // set params
634
+ $block = array_merge(array('no-block' => true, 'type' => 'divider'), $divider);
635
+
636
+ $helper_wj_engine=WYSIJA::get('wj_engine','helper');
637
+ return base64_encode($helper_wj_engine->renderEditorBlock($block));
638
+ }
639
+
640
+ function get_social_bookmarks() {
641
+ $size = isset($_POST['wysijaData']['size']) ? $_POST['wysijaData']['size'] : NULL;
642
+ $theme = isset($_POST['wysijaData']['theme']) ? $_POST['wysijaData']['theme'] : NULL;
643
+
644
+ $bookmarksHelper = WYSIJA::get('bookmarks', 'helper');
645
+ $bookmarks = $bookmarksHelper->getAll($size, $theme);
646
+ return json_encode(array('icons' => $bookmarks));
647
+ }
648
+
649
+ function generate_social_bookmarks() {
650
+
651
+ $size = 'medium';
652
+ $iconset = '01';
653
+
654
+ if(isset($_POST['wysijaData']) && !empty($_POST['wysijaData'])) {
655
+ $data = $_POST['wysijaData'];
656
+ $items = array();
657
+
658
+ foreach($data as $key => $values) {
659
+ if($values['name'] === 'bookmarks-size') {
660
+ // get size
661
+ $size = $values['value'];
662
+ } else if($values['name'] === 'bookmarks-theme') {
663
+ // get theme name
664
+ $theme = $values['value'];
665
+ } else if($values['name'] === 'bookmarks-iconset') {
666
+ // get iconset
667
+ $iconset = $values['value'];
668
+ if(strlen(trim($iconset)) === 0) {
669
+ $this->error('No iconset specified', false);
670
+ return false;
671
+ }
672
+ } else {
673
+ $keys = explode('-', $values['name']);
674
+ $network = $keys[1];
675
+ $property = $keys[2];
676
+ if(array_key_exists($network, $items)) {
677
+ $items[$network][$property] = $values['value'];
678
+ } else {
679
+ $items[$network] = array($property => $values['value']);
680
+ }
681
+ }
682
+ }
683
+ }
684
+
685
+ $urls = array();
686
+ // check data and remove network with an empty url
687
+ foreach($items as $network => $item) {
688
+ if(strlen(trim($item['url'])) === 0) {
689
+ // empty url
690
+ unset($items[$network]);
691
+ } else {
692
+ // url specified
693
+ $urls[$network] = $item['url'];
694
+ }
695
+ }
696
+
697
+ // check if there's at least one url left
698
+ if(empty($urls)) {
699
+ $this->error('No url specified', false);
700
+ return false;
701
+ }
702
+
703
+ // save url in config
704
+ $config=WYSIJA::get('config','model');
705
+ $config->save(array('social_bookmarks' => $urls));
706
+
707
+ // get iconset icons
708
+ $bookmarksHelper = WYSIJA::get('bookmarks', 'helper');
709
+
710
+ // if the iconset is 00, then it's the theme's bookmarks
711
+ if($iconset === '00') {
712
+ $icons = $bookmarksHelper->getAllByTheme($theme);
713
+ } else {
714
+ // otherwise it's a basic iconset
715
+ $icons = $bookmarksHelper->getAllByIconset($size, $iconset);
716
+ }
717
+
718
+
719
+ // format data
720
+ $block = array(
721
+ 'position' => 1,
722
+ 'type' => 'gallery',
723
+ 'items' => array(),
724
+ 'alignment' => 'center'
725
+ );
726
+
727
+ $width = 0;
728
+ foreach($items as $key => $item) {
729
+ $block['items'][] = array_merge($item, $icons[$key], array('alt' => ucfirst($key)));
730
+ $width += (int)$icons[$key]['width'];
731
+ }
732
+ // add margin between icons
733
+ $width += (count($block['items']) - 1) * 10;
734
+ // set optimal width
735
+ $block['width'] = max(0, min($width, 564));
736
+
737
+ $helper_wj_engine=WYSIJA::get('wj_engine','helper');
738
+ return base64_encode($helper_wj_engine->renderEditorBlock($block));
739
+ }
740
+
741
+ function install_theme() {
742
+ if( isset($_REQUEST['theme_id'])){
743
+ global $wp_version;
744
+ //check if theme is premium if you have the premium licence
745
+ if(isset($_REQUEST['premium']) && $_REQUEST['premium']){
746
+ $getpremiumtheme=apply_filters('wysija_install_theme_premium', false);
747
+
748
+ if(!$getpremiumtheme){
749
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
750
+ $themes = $helper_wj_engine->renderThemes();
751
+ return array('result'=>false, 'themes' => $themes);
752
+ }
753
+ }
754
+
755
+ $helperToolbox = WYSIJA::get('toolbox','helper');
756
+ $domain_name = $helperToolbox->_make_domain_name(admin_url('admin.php'));
757
+
758
+ $request = 'http://api.mailpoet.com/download/zip/'.$_REQUEST['theme_id'].'?domain='.$domain_name;
759
+
760
+ $args = array(
761
+ 'timeout' => 30,
762
+ 'body' => array( ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
763
  'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
764
+ );
765
+ $raw_response = wp_remote_post( $request, $args );
766
+
767
+ if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ){
768
+ if(method_exists($raw_response, 'get_error_messages')){
769
+ $this->error($raw_response->get_error_messages());
770
+ }
771
+ $ZipfileResult = false;
772
+ }else{
773
+ $ZipfileResult = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) );
774
+ }
775
+
776
+ if($ZipfileResult === false){
777
+ $result = false;
778
+ $this->error(__('We were unable to contact the API, the site may be down. Please try again later.',WYSIJA),true);
779
+ }else{
780
+ $themesHelp=WYSIJA::get('themes','helper');
781
+ $result = $themesHelp->installTheme($ZipfileResult);
782
+
783
+ // refresh themes list
784
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
785
+ $themes = $helper_wj_engine->renderThemes();
786
+ }
787
+ }else{
788
+ $result = false;
789
+ $themes = '';
790
+ $this->notice('missing info');
791
+ }
792
+
793
+ return array('result' => $result, 'themes' => $themes);
794
+ }
795
+
796
+ function refresh_themes() {
797
+ // refresh themes list
798
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
799
+ return array('result'=>true, 'themes' => $helper_wj_engine->renderThemes());
800
+ }
801
+
802
+ function generate_auto_post() {
803
+ // get params and generate html
804
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
805
+ $helper_articles = WYSIJA::get('articles', 'helper');
806
+
807
+ // get parameters
808
+ $block_params = array();
809
+ if(isset($_POST['wysijaData'])) {
810
+ // store category ids (TBR)
811
+ $category_ids = array();
812
+
813
+ foreach($_POST['wysijaData'] as $pairs) {
814
+ // special cases
815
+ switch($pairs['name']) {
816
+ case 'author_label':
817
+ case 'category_label':
818
+ case 'readmore':
819
+ case 'nopost_message':
820
+ $block_params[] = array('key' => $pairs['name'], 'value' => base64_encode(stripslashes($pairs['value'])));
821
+ break;
822
+ case 'category_ids':
823
+ $category_ids[] = (int)$pairs['value'];
824
+ break;
825
+ default:
826
+ $block_params[] = array('key' => $pairs['name'], 'value' => $pairs['value']);
827
+ }
828
+ }
829
+
830
+ // make sure we have only unique ids in categories
831
+ $block_params[] = array('key' => 'category_ids', 'value' => join(',', array_unique($category_ids)));
832
+ }
833
+
834
+ if(empty($block_params)) {
835
+ // an error occurred, do something!
836
+ return false;
837
+ } else {
838
+ $data = array(
839
+ 'type' => 'auto-post',
840
+ 'params' => $block_params
841
+ );
842
+ return base64_encode($helper_wj_engine->renderEditorBlock($data));
843
+ }
844
+ }
845
+
846
+ function load_auto_post() {
847
+ $params = array();
848
+
849
+ if(isset($_POST['wysijaData'])) {
850
+
851
+ $pairs = explode('&', $_POST['wysijaData']);
852
+
853
+ foreach($pairs as $pair) {
854
+ list($key, $value) = explode('=', $pair);
855
+ switch($key) {
856
+ case 'autopost_count':
857
+ $params[$key] = (int)$value;
858
+ break;
859
+ case 'readmore':
860
+ case 'author_label':
861
+ case 'category_label':
862
+ case 'nopost_message':
863
+ $params[$key] = base64_decode($value);
864
+ break;
865
+ case 'exclude':
866
+ $params[$key] = explode(',', $value);
867
+ break;
868
+ default:
869
+ $params[$key] = $value;
870
+ }
871
+ }
872
+ }
873
+
874
+ if(empty($params)) {
875
+ // an error occurred, do something!
876
+ return false;
877
+ } else {
878
+
879
+ // get email params
880
+ $email_id = (int)$_REQUEST['id'];
881
+ $model_email = WYSIJA::get('email', 'model');
882
+ $email = $model_email->getOne(array('params','sent_at','campaign_id'), array('email_id' => $email_id));
883
+
884
+ $helper_articles = WYSIJA::get('articles', 'helper');
885
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
886
+
887
+ // see if posts have already been sent
888
+ if(!empty($email['params']['autonl']['articles']['ids'])) {
889
+ if(!isset($params['exclude'])) { $params['exclude'] = array(); }
890
+
891
+ $params['exclude'] = array_unique(array_merge($email['params']['autonl']['articles']['ids'], $params['exclude']));
892
+ }
893
+
894
+ //we set the post_date to filter articles only older than that one
895
+ if(isset($email['params']['autonl']['firstSend'])){
896
+ $params['post_date'] = $email['params']['autonl']['firstSend'];
897
+ }
898
+
899
+ // if immediate let it know to the get post
900
+ if(isset($email['params']['autonl']['articles']['immediatepostid'])){
901
+ $params['include'] = $email['params']['autonl']['articles']['immediatepostid'];
902
+ $params['post_limit'] = 1;
903
+ }else{
904
+ //we set the post_date to filter articles only older than the last time we sent articles
905
+ if(isset($email['params']['autonl']['lastSend'])){
906
+ $params['post_date'] = $email['params']['autonl']['lastSend'];
907
+ }else{
908
+ //get the latest child newsletter sent_at value
909
+ $mEmail=WYSIJA::get('email','model');
910
+ $mEmail->reset();
911
+ $mEmail->orderBy('email_id','DESC');
912
+ $lastEmailSent=$mEmail->getOne(false,array('campaign_id'=>$email['campaign_id'],'type'=>'1'));
913
+
914
+ if(!empty($lastEmailSent)) $params['post_date'] = $lastEmailSent['sent_at'];
915
+ }
916
+ }
917
+
918
+ // get posts
919
+ $params['post_fields'] = array('post_title', 'post_content', 'post_excerpt', 'post_author');
920
+ $model_wp_posts = WYSIJA::get('wp_posts','model');
921
+ $posts = $model_wp_posts->get_posts($params);
922
+
923
+ if(empty($posts)) {
924
+ // nothing to display
925
+ $posts = array();
926
+ } else {
927
+ // used to keep track of post ids present in the auto post
928
+ $post_ids = array();
929
+
930
+ // cleanup post and get image
931
+ foreach($posts as $key => $post) {
932
+ if($params['image_alignment'] !== 'none') {
933
+ // attempt to get post image
934
+ $posts[$key]['post_image'] = $helper_articles->getImage($post);
935
+ }
936
+
937
+ // store article id
938
+ $post_ids[] = $post['ID'];
939
+ }
940
+ // store article ids
941
+ $params['post_ids'] = join(',', $post_ids);
942
+ }
943
+
944
+ // get divider if necessary (for immediate post notification, the "show_divider" parameter is not available)
945
+ if(isset($params['show_divider']) && $params['show_divider'] === 'yes') {
946
+ if(isset($email['params']['divider'])) {
947
+ $params['divider'] = $email['params']['divider'];
948
+ } else {
949
+ $helper_dividers = WYSIJA::get('dividers', 'helper');
950
+ $params['divider'] = $helper_dividers->getDefault();
951
+ }
952
+ }
953
+
954
+ return base64_encode($helper_wj_engine->renderEditorAutoPost($posts, $params));
955
+ }
956
+ }
957
  }
controllers/ajax/statistics.php CHANGED
@@ -1,95 +1,86 @@
1
  <?php
 
2
  defined('WYSIJA') or die('Restricted access');
3
 
4
  require_once(WYSIJA_CORE.'module'.DS.'statistics.php'); // @todo
5
 
6
- class WYSIJA_control_back_statistics extends WYSIJA_control
7
- {
8
 
9
- /**
10
- * Main model of this controller
11
- * @var string
12
- */
13
- public $model = 'statistics';
14
 
15
- /**
16
- * Main view of this controller
17
- * @var string
18
- */
19
- public $view = 'statistics';
20
 
21
- /**
22
- * Render a hook of a specific module
23
- * @return string
24
- */
25
- public function get_block()
26
- {
27
- if (empty($_REQUEST['block']))
28
- return '';
29
- $module = $_REQUEST['block'];
30
- $hook_name = 'hook_stats';
31
- return apply_filters('custom_module_hook', '', $module, $hook_name, $this->get_post_params());
32
- }
33
 
34
- protected function get_post_params()
35
- {
36
- $params = array( );
37
- $order_by = !empty($_REQUEST['filter']['orderBy']) ? $_REQUEST['filter']['orderBy'] : null;
38
- switch (strtolower($order_by))
39
- {
40
- case 'sent':
41
- $order_by = WYSIJA_module_statistics::ORDER_BY_SENT;
42
- break;
43
- case 'open':
44
- $order_by = WYSIJA_module_statistics::ORDER_BY_OPEN;
45
- break;
46
- case 'click':
47
- $order_by = WYSIJA_module_statistics::ORDER_BY_CLICK;
48
- break;
49
- case 'unsubscribe':
50
- $order_by = WYSIJA_module_statistics::ORDER_BY_UNSUBSCRIBE;
51
- break;
52
- default:
53
- $order_by = null;
54
- break;
55
- }
56
- $order_direction = !empty($_REQUEST['filter']['orderDirection']) ? $_REQUEST['filter']['orderDirection'] : null;
57
- switch (strtolower($order_direction))
58
- {
59
- case 'asc':
60
- $order_direction = WYSIJA_module_statistics::ORDER_DIRECTION_ASC;
61
- break;
62
- case 'desc':
63
- default:
64
- $order_direction = WYSIJA_module_statistics::ORDER_DIRECTION_DESC;
65
- break;
66
- }
67
- $params['top'] = !empty($_REQUEST['filter']['itemPerPage']) ? (int)$_REQUEST['filter']['itemPerPage'] : WYSIJA_module_statistics::DEFAULT_TOP_RECORDS;
68
- $params['from'] = !empty($_REQUEST['filter']['from']) ? $_REQUEST['filter']['from'] : null;
69
- $params['to'] = !empty($_REQUEST['filter']['to']) ? $_REQUEST['filter']['to'] : null;
70
- $params['order_by'] = $order_by;
71
- $params['order_direction'] = $order_direction;
72
 
73
- // this doesn't work when php is less than 5.3, this is the case on my host (ben) which is very popular in France, SPain and UK
74
- // we cannot use functions from php 5.3
75
- if (function_exists('date_diff'))
76
- {
77
- $this->data['date_interval'] = date_diff(date_create($params['from']), date_create($params['to']));
78
- }
79
- else
80
- {
81
- $duration = strtotime($params['to']) - strtotime($params['from']);
82
- $helper_toolbox = WYSIJA::get('toolbox', 'helper');
83
- $this->data['date_interval'] = (object)$helper_toolbox->convert_seconds_to_array($duration, false);
84
- }
85
- $params['group_by'] = ( $this->data['date_interval']->days == 0 || $this->data['date_interval']->days > WYSIJA_module_statistics::SWITCHING_DATE_TO_MONTH_THRESHOLD) ?
86
- WYSIJA_module_statistics::GROUP_BY_MONTH :
87
- WYSIJA_module_statistics::GROUP_BY_DATE; // $date_interval->days == 0, means, no begin date, no end date
88
 
89
- // Hack!
90
- $_REQUEST['limit_pp'] = $params['top'];// Pagination, mark current selected value
91
 
92
- return $params;
93
- }
94
 
95
  }
1
  <?php
2
+
3
  defined('WYSIJA') or die('Restricted access');
4
 
5
  require_once(WYSIJA_CORE.'module'.DS.'statistics.php'); // @todo
6
 
7
+ class WYSIJA_control_back_statistics extends WYSIJA_control {
 
8
 
9
+ /**
10
+ * Main model of this controller
11
+ * @var string
12
+ */
13
+ public $model = 'statistics';
14
 
15
+ /**
16
+ * Main view of this controller
17
+ * @var string
18
+ */
19
+ public $view = 'statistics';
20
 
21
+ /**
22
+ * Render a hook of a specific module
23
+ * @return string
24
+ */
25
+ public function get_block() {
26
+ if (empty($_REQUEST['block']))
27
+ return '';
28
+ $module = $_REQUEST['block'];
29
+ $hook_name = 'hook_stats';
30
+ return apply_filters('custom_module_hook', '', $module, $hook_name, $this->get_post_params());
31
+ }
 
32
 
33
+ protected function get_post_params() {
34
+ $params = array();
35
+ $order_by = !empty($_REQUEST['filter']['orderBy']) ? $_REQUEST['filter']['orderBy'] : null;
36
+ switch (strtolower($order_by)) {
37
+ case 'sent':
38
+ $order_by = WYSIJA_module_statistics::ORDER_BY_SENT;
39
+ break;
40
+ case 'open':
41
+ $order_by = WYSIJA_module_statistics::ORDER_BY_OPEN;
42
+ break;
43
+ case 'click':
44
+ $order_by = WYSIJA_module_statistics::ORDER_BY_CLICK;
45
+ break;
46
+ case 'unsubscribe':
47
+ $order_by = WYSIJA_module_statistics::ORDER_BY_UNSUBSCRIBE;
48
+ break;
49
+ default:
50
+ $order_by = null;
51
+ break;
52
+ }
53
+ $order_direction = !empty($_REQUEST['filter']['orderDirection']) ? $_REQUEST['filter']['orderDirection'] : null;
54
+ switch (strtolower($order_direction)) {
55
+ case 'asc':
56
+ $order_direction = WYSIJA_module_statistics::ORDER_DIRECTION_ASC;
57
+ break;
58
+ case 'desc':
59
+ default:
60
+ $order_direction = WYSIJA_module_statistics::ORDER_DIRECTION_DESC;
61
+ break;
62
+ }
63
+ $params['top'] = !empty($_REQUEST['filter']['itemPerPage']) ? (int) $_REQUEST['filter']['itemPerPage'] : WYSIJA_module_statistics::DEFAULT_TOP_RECORDS;
64
+ $params['from'] = !empty($_REQUEST['filter']['from']) ? $_REQUEST['filter']['from'] : null;
65
+ $params['to'] = !empty($_REQUEST['filter']['to']) ? $_REQUEST['filter']['to'] : null;
66
+ $params['order_by'] = $order_by;
67
+ $params['order_direction'] = $order_direction;
 
 
 
68
 
69
+ // this doesn't work when php is less than 5.3, this is the case on my host (ben) which is very popular in France, SPain and UK
70
+ // we cannot use functions from php 5.3
71
+ if(function_exists('date_diff')){
72
+ $this->data['date_interval'] = date_diff(date_create($params['from']), date_create($params['to']));
73
+ }else{
74
+ $duration = strtotime($params['to']) - strtotime($params['from']);
75
+ $helper_toolbox = WYSIJA::get('toolbox' , 'helper');
76
+ $this->data['date_interval'] = (object)$helper_toolbox->convert_seconds_to_array($duration , false);
77
+ }
78
+ $params['group_by'] = ( $this->data['date_interval']->days == 0 || $this->data['date_interval']->days > WYSIJA_module_statistics::SWITCHING_DATE_TO_MONTH_THRESHOLD) ?
79
+ WYSIJA_module_statistics::GROUP_BY_MONTH :
80
+ WYSIJA_module_statistics::GROUP_BY_DATE; // $date_interval->days == 0, means, no begin date, no end date
81
+ return $params;
82
+ }
 
83
 
 
 
84
 
 
 
85
 
86
  }
controllers/ajax/tmce.php CHANGED
@@ -1,139 +1,140 @@
1
- <?php
2
- defined('WYSIJA') or die('Restricted access');
3
- class WYSIJA_control_back_tmce extends WYSIJA_control{
4
-
5
- function WYSIJA_control_back_tmce(){
6
- parent::WYSIJA_control();
7
- $this->viewObj=WYSIJA::get('tmce','view');
8
- }
9
-
10
- function subscribersAdd(){
11
- $this->viewObj->title=__('Insert Total of Subscribers',WYSIJA);
12
- $data = array();
13
- $data['lists'] = WYSIJA::get('list','model')->getLists();
14
- foreach ($data['lists'] as $k => $list){
15
- if (empty($list['is_enabled']) OR empty($list['is_public'])) unset($data['lists'][$k]);
16
- }
17
- $data['confirm_dbleoptin'] = WYSIJA::get('config','model')->getValue('confirm_dbleoptin');
18
-
19
- $this->viewObj->subscribersAdd($data);
20
- exit;
21
- }
22
-
23
- function subscribersEdit(){
24
-
25
- }
26
-
27
- function registerAdd(){
28
- $this->viewObj->title=__('Insert Subscription Form',WYSIJA);
29
-
30
- $this->viewObj->registerAdd($this->getData());
31
- exit;
32
- }
33
-
34
- function registerEdit(){
35
- $this->viewObj->title=__('Insert Subscription Form',WYSIJA);
36
-
37
- $this->viewObj->registerAdd($this->getData(),true);
38
- exit;
39
- }
40
-
41
-
42
- function getData(){
43
- $data_widget=array();
44
-
45
- // if this parameter is passed that means we have an old widget let's import it and select
46
- if(isset($_REQUEST['widget-data64'])){
47
- $data_widget=unserialize(base64_decode($_REQUEST['widget-data64']));
48
- $post=get_post($_REQUEST['post_id']);
49
-
50
- // we need a title to identify the form
51
- $data_widget['title'] = 'Form on '.$post->post_type.': '.$post->post_title;
52
-
53
- $model_forms = WYSIJA::get('forms', 'model');
54
- $model_forms->reset();
55
- $form = $model_forms->getOne(false,array('name' => $data_widget['title']));
56
-
57
- // this form doesn't exist yet in the new format so let's try to import it
58
- if(empty($form)){
59
- $helper_update=WYSIJA::get('update','helper');
60
-
61
- $form_id = $helper_update->convert_widget_to_form($data_widget);
62
- if($form_id!==false) {
63
- $data_widget['default_form'] = $form_id;
64
- }
65
- }
66
- }
67
-
68
- if(isset($_POST['widget-wysija'])){
69
- $data_widget=array('widget_id'=>$_POST['widget_id'],'preview'=>true);
70
- $custom_fields=array();
71
-
72
- foreach($_POST['widget-wysija'] as $arra){
73
- foreach($arra as $k => $v) {
74
- switch($k){
75
- case 'lists':
76
- if(isset($data_widget[$k])) $data_widget[$k][]=$v[0];
77
- else $data_widget[$k]=array($v[0]);
78
- break;
79
- case 'lists_name':
80
- foreach($v as $kv=>$vv){
81
- if(isset($data_widget[$k])) $data_widget[$k][$kv]=$vv;
82
- else $data_widget[$k]=array($kv=>$vv);
83
- }
84
-
85
- break;
86
- case 'customfields':
87
-
88
- $found=false;
89
- foreach($custom_fields as $keycol => $params){
90
- if(isset($v[$keycol])){
91
- $custom_fields[$keycol]= array_merge($custom_fields[$keycol],$v[$keycol]);
92
- $found=true;
93
- }
94
- }
95
-
96
- if(!$found) $custom_fields=array_merge($custom_fields,$v);
97
- break;
98
-
99
- default:
100
- $data_widget[$k]=stripslashes($v);
101
- }
102
-
103
- }
104
- }
105
-
106
-
107
- $count=count($custom_fields);
108
- if($count>1){
109
- foreach($custom_fields as $keycol=>$paraval){
110
- if($keycol!='email' && !isset($paraval['column_name'])) unset($custom_fields[$keycol]);
111
- }
112
- }
113
-
114
- $count=count($custom_fields);
115
- if($count>0){
116
- if(!isset($custom_fields['email'])){
117
- $custom_fields['email']['column_name']='email';
118
- $custom_fields['email']['label']=__('Email',WYSIJA);
119
- }
120
- }
121
-
122
- $count=count($custom_fields);
123
- if($count==1 && isset($custom_fields['email'])){
124
-
125
- $custom_fields=array();
126
- }
127
-
128
- if($custom_fields) $data_widget['customfields']=$custom_fields;
129
-
130
- }
131
-
132
- if(!isset($data_widget['customfields']) && isset($data_widget['labelswithin']) && $data_widget['labelswithin']=='labels_within'){
133
- $data_widget['customfields']=array('email'=>array('label'=>__('Email',WYSIJA)));
134
- }
135
-
136
- return $data_widget;
137
- }
138
-
 
139
  }
1
+ <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
+ class WYSIJA_control_back_tmce extends WYSIJA_control{
4
+
5
+ function WYSIJA_control_back_tmce(){
6
+ if(!WYSIJA::current_user_can('wysija_subscriwidget')) die('Action is forbidden.');
7
+ parent::WYSIJA_control();
8
+ $this->viewObj=WYSIJA::get('tmce','view');
9
+ }
10
+
11
+ function subscribersAdd(){
12
+ $this->viewObj->title=__('Insert Total of Subscribers',WYSIJA);
13
+ $data = array();
14
+ $data['lists'] = WYSIJA::get('list','model')->getLists();
15
+ foreach ($data['lists'] as $k => $list){
16
+ if (empty($list['is_enabled']) OR empty($list['is_public'])) unset($data['lists'][$k]);
17
+ }
18
+ $data['confirm_dbleoptin'] = WYSIJA::get('config','model')->getValue('confirm_dbleoptin');
19
+
20
+ $this->viewObj->subscribersAdd($data);
21
+ exit;
22
+ }
23
+
24
+ function subscribersEdit(){
25
+
26
+ }
27
+
28
+ function registerAdd(){
29
+ $this->viewObj->title=__('Insert Subscription Form',WYSIJA);
30
+
31
+ $this->viewObj->registerAdd($this->getData());
32
+ exit;
33
+ }
34
+
35
+ function registerEdit(){
36
+ $this->viewObj->title=__('Insert Subscription Form',WYSIJA);
37
+
38
+ $this->viewObj->registerAdd($this->getData(),true);
39
+ exit;
40
+ }
41
+
42
+
43
+ function getData(){
44
+ $data_widget=array();
45
+
46
+ // if this parameter is passed that means we have an old widget let's import it and select
47
+ if(isset($_REQUEST['widget-data64'])){
48
+ $data_widget=unserialize(base64_decode($_REQUEST['widget-data64']));
49
+ $post=get_post($_REQUEST['post_id']);
50
+
51
+ // we need a title to identify the form
52
+ $data_widget['title'] = 'Form on '.$post->post_type.': '.$post->post_title;
53
+
54
+ $model_forms = WYSIJA::get('forms', 'model');
55
+ $model_forms->reset();
56
+ $form = $model_forms->getOne(false,array('name' => $data_widget['title']));
57
+
58
+ // this form doesn't exist yet in the new format so let's try to import it
59
+ if(empty($form)){
60
+ $helper_update=WYSIJA::get('update','helper');
61
+
62
+ $form_id = $helper_update->convert_widget_to_form($data_widget);
63
+ if($form_id!==false) {
64
+ $data_widget['default_form'] = $form_id;
65
+ }
66
+ }
67
+ }
68
+
69
+ if(isset($_POST['widget-wysija'])){
70
+ $data_widget=array('widget_id'=>$_POST['widget_id'],'preview'=>true);
71
+ $custom_fields=array();
72
+
73
+ foreach($_POST['widget-wysija'] as $arra){
74
+ foreach($arra as $k => $v) {
75
+ switch($k){
76
+ case 'lists':
77
+ if(isset($data_widget[$k])) $data_widget[$k][]=$v[0];
78
+ else $data_widget[$k]=array($v[0]);
79
+ break;
80
+ case 'lists_name':
81
+ foreach($v as $kv=>$vv){
82
+ if(isset($data_widget[$k])) $data_widget[$k][$kv]=$vv;
83
+ else $data_widget[$k]=array($kv=>$vv);
84
+ }
85
+
86
+ break;
87
+ case 'customfields':
88
+
89
+ $found=false;
90
+ foreach($custom_fields as $keycol => $params){
91
+ if(isset($v[$keycol])){
92
+ $custom_fields[$keycol]= array_merge($custom_fields[$keycol],$v[$keycol]);
93
+ $found=true;
94
+ }
95
+ }
96
+
97
+ if(!$found) $custom_fields=array_merge($custom_fields,$v);
98
+ break;
99
+
100
+ default:
101
+ $data_widget[$k]=stripslashes($v);
102
+ }
103
+
104
+ }
105
+ }
106
+
107
+
108
+ $count=count($custom_fields);
109
+ if($count>1){
110
+ foreach($custom_fields as $keycol=>$paraval){
111
+ if($keycol!='email' && !isset($paraval['column_name'])) unset($custom_fields[$keycol]);
112
+ }
113
+ }
114
+
115
+ $count=count($custom_fields);
116
+ if($count>0){
117
+ if(!isset($custom_fields['email'])){
118
+ $custom_fields['email']['column_name']='email';
119
+ $custom_fields['email']['label']=__('Email',WYSIJA);
120
+ }
121
+ }
122
+
123
+ $count=count($custom_fields);
124
+ if($count==1 && isset($custom_fields['email'])){
125
+
126
+ $custom_fields=array();
127
+ }
128
+
129
+ if($custom_fields) $data_widget['customfields']=$custom_fields;
130
+
131
+ }
132
+
133
+ if(!isset($data_widget['customfields']) && isset($data_widget['labelswithin']) && $data_widget['labelswithin']=='labels_within'){
134
+ $data_widget['customfields']=array('email'=>array('label'=>__('Email',WYSIJA)));
135
+ }
136
+
137
+ return $data_widget;
138
+ }
139
+
140
  }
controllers/back.php CHANGED
@@ -544,7 +544,7 @@ class WYSIJA_control_back extends WYSIJA_control{
544
  remove_action('admin_enqueue_scripts', 'wp_auth_check_load');
545
 
546
  // add popup css
547
- wp_enqueue_style('custom_popup_css', WYSIJA_URL.'css/adminPopup.css', array(), WYSIJA::get_version(), 'screen');
548
 
549
  global $viewMedia;
550
  $viewMedia=$this->viewObj;
544
  remove_action('admin_enqueue_scripts', 'wp_auth_check_load');
545
 
546
  // add popup css
547
+ wp_enqueue_style('custom_popup_css', WYSIJA_URL.'css/adminPopup.css');
548
 
549
  global $viewMedia;
550
  $viewMedia=$this->viewObj;
controllers/back/campaigns.php CHANGED
@@ -5,2755 +5,2741 @@ defined('WYSIJA') or die('Restricted access');
5
 
6
  class WYSIJA_control_back_campaigns extends WYSIJA_control_back {
7
 
8
- var $model = 'campaign';
9
- var $view = 'campaigns';
10
- var $list_columns = array('campaign_id', 'name', 'description');
11
- var $searchable = array('name', 'subject');
12
- var $filters = array();
13
- var $base_url = 'admin.php';
14
-
15
- function WYSIJA_control_back_campaigns() {
16
-
17
- }
18
-
19
- function installation(){
20
-
21
- $start_time = time();
22
- $check_max_execution_time = get_option( 'mpoet_check_max_execution_time' );
23
- $ini_max_execution_time = ini_get( 'max_execution_time' );
24
-
25
- // 1 - we haven't run the max execution time extension test yet, let's do it
26
- // this test should be run in the background, it may take more than 5 minutes to validate
27
- if( empty( $check_max_execution_time ) ){
28
-
29
- // we set the max_execution_time to infinite
30
- @ini_set( 'max_execution_time' , 0 );
31
- // we keep running the script even if the user abort his request
32
- @ignore_user_abort( true );
33
-
34
- $reset_max_execution_time = ini_get( 'max_execution_time' );
35
-
36
- // FAILURE some servers the "max execution time" returned is Array we make sure our value is numeric
37
- if( !is_numeric( $ini_max_execution_time ) ){
38
- WYSIJA::update_option( 'mpoet_check_max_execution_time' , $ini_max_execution_time-1 );
39
- return;
40
- }
41
-
42
- // FAILURE this server doesn't allow us to set the max_execution_time
43
- if( $reset_max_execution_time == $ini_max_execution_time ){
44
- WYSIJA::update_option( 'mpoet_check_max_execution_time' , $ini_max_execution_time-1 );
45
- return;
46
- }
47
-
48
- // we set a FAILURE value to our flag so we know if the process crash while executing
49
- WYSIJA::update_option( 'mpoet_check_max_execution_time' , $ini_max_execution_time );
50
-
51
- // the common default timeout value is 300, so if by default the timelimit is 0 (which might have been set by another application)
52
- // we default it to 300 known as a common default value and we run the extension test
53
- if( $ini_max_execution_time == 0 ) $ini_max_execution_time = 300;
54
-
55
- // we run asleep script during the initial max execution time to a larger value
56
- $total_time_to_run_script = $ini_max_execution_time + 20;
57
- $sleeping_intervals = 5;
58
- $duration_so_far = 0;
59
-
60
- // we sleep until the extended total timeout value is reached or it breaks before but we have the value we need
61
- while($total_time_to_run_script >0){
62
- $total_time_to_run_script = $total_time_to_run_script - $sleeping_intervals;
63
- sleep( $sleeping_intervals );
64
-
65
- $duration_so_far = time() - $start_time;
66
- WYSIJA::update_option( 'mpoet_check_max_execution_time' , $duration_so_far );
67
- }
68
-
69
- // SUCCESS the scripts didn't die we set our flag in the db so that we know the test is a success
70
- WYSIJA::update_option( 'mpoet_check_max_execution_time' , $duration_so_far );
71
-
72
- }else{
73
- // 2 - the max execution time extension test has been run, this is the results we get
74
- if( $check_max_execution_time > $ini_max_execution_time ){
75
- echo 'max_execution_time('.$ini_max_execution_time.') can be extended('.$check_max_execution_time.')';
76
- }else{
77
- echo 'max_execution_time('.$ini_max_execution_time.') cannot be extended( max value : '.$check_max_execution_time.')';
78
- }
79
- }
80
- exit;
81
- }
82
-
83
- /**
84
- * Welcome page first time install
85
- * @return boolean
86
- */
87
- function welcome_new() {
88
- $this->title = $this->viewObj->title = __('Welcome Page!', WYSIJA);
89
- $this->jsTrans['instalwjp'] = __('Installing MailPoet Newsletter Premium plugin', WYSIJA);
90
- $helper_readme = WYSIJA::get('readme', 'helper');
91
- $helper_readme->scan();
92
- $this->data = array();
93
- $this->data['abouttext'] = __('A Brand New MailPoet. Let the Fun Begin.', WYSIJA);
94
-
95
- $model_config = WYSIJA::get('config', 'model');
96
- $is_multisite = is_multisite();
97
- $is_network_admin = WYSIJA::current_user_can('manage_network');
98
- if ($is_multisite && $is_network_admin) {
99
- $model_config->save(array('ms_wysija_whats_new' => WYSIJA::get_version()));
100
- } else {
101
- $model_config->save(array('wysija_whats_new' => WYSIJA::get_version()));
102
- }
103
-
104
- //add a new language code with a new video
105
- $video_language=array();
106
- //$video_language['en_EN'] = '<iframe width="853" height="480" src="http://www.youtube.com/embed/pYzaHDTg5Jk" frameborder="0" allowfullscreen></iframe>';
107
- $video_language['en_EN'] = '<iframe src="//player.vimeo.com/video/81479899" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
108
- //$video_language['fr_FR'] = '<iframe width="853" height="480" src="http://www.youtube.com/embed/W5EyW5w7aWQ" frameborder="0" allowfullscreen></iframe>';
109
- // $video_language['sv_SE']='<iframe width="853" height="480" src="http://www.youtube.com/embed/O8_t_dekx74" frameborder="0" allowfullscreen></iframe>';
110
- //$video_language['ar']='<iframe width="853" height="480" src="http://www.youtube.com/embed/cyDHlX_qgOo" frameborder="0" allowfullscreen></iframe>';
111
-
112
- $wp_lang = get_locale();
113
- if (!empty($wp_lang) && isset($video_language[$wp_lang])) {
114
- $welcome_video_link = $video_language[$wp_lang];
115
- } else {
116
- $welcome_video_link = $video_language['en_EN'];
117
- }
118
-
119
- $this->data['sections'][] = array(
120
- 'title' => __('Hey, we\'re curious! How did you find out about us?', WYSIJA) . '<span id="poll_result"></span>',
121
- 'format' => 'normal',
122
- 'paragraphs' => array(
123
- '<ul class="welcome_poll">
124
- <li>
125
- <input type="radio" id="how_did_you_find_us_1" value="repository" name="how_did_you_find_us">
126
- <label value="lab1" for="how_did_you_find_us_1">' . __('WordPress.org plugin repository', WYSIJA) . '</label>
127
- </li>
128
- <li>
129
- <input type="radio" id="how_did_you_find_us_2" value="search_engine" name="how_did_you_find_us">
130
- <label value="lab2" for="how_did_you_find_us_2">' . __('Google or other search engine', WYSIJA) . '</label>
131
- </li>
132
- <li>
133
- <input type="radio" id="how_did_you_find_us_3" value="friend" name="how_did_you_find_us">
134
- <label value="lab3" for="how_did_you_find_us_3">' . __('Friend recommendation', WYSIJA) . '</label>
135
- </li>
136
- <li>
137
- <input type="radio" id="how_did_you_find_us_4" value="url" name="how_did_you_find_us">
138
- <label value="lab4" for="how_did_you_find_us_4">' . __('Blog post, online review, forum:', WYSIJA) . '</label>
139
- <input type="text" id="how_did_you_find_us_4_url" name="how_did_you_find_us_url" placeholder="' . __('Please enter the address where you\'ve found out about us', WYSIJA) . '">
140
- </li>
141
- </ul>'
142
- )
143
- );
144
-
145
- $this->data['sections'][]=array(
146
- 'title'=>__('First Time? See it in Action',WYSIJA),
147
- 'format'=>'normal',
148
- 'paragraphs'=>array(
149
- __('You can start by watching this video by one of our users.',WYSIJA),
150
- $welcome_video_link
151
- )
152
- );
153
-
154
- // Check if user is already sharing data, and hide the share link.
155
- if (!$model_config->getValue('analytics')) {
156
- $share_section = array(
157
- 'title' => __('Share your data', WYSIJA),
158
- 'content' => str_replace(
159
- array('[link]', '[/link]', '[ajaxlink]', '[/ajaxlink]'), array('<a title="Anonymous Data" target="_blank" href="http://support.mailpoet.com/knowledgebase/share-your-data/?utm_source=wpadmin&utm_campaign=welcome_page">', '</a>', '<a id="share_analytics" href="javascript:;">', '</a>'), __("We know too little about our users. We're looking for [link]anonymous data[/link] to build a better plugin. [ajaxlink]Yes, count me in![/ajaxlink]", WYSIJA))
160
- );
161
- } else {
162
- $share_section = array(
163
- 'title' => __('Share your data', WYSIJA),
164
- 'content' => str_replace(
165
- array('[link]', '[/link]'), array('<a title="Anonymous Data" target="_blank" href="http://support.mailpoet.com/knowledgebase/share-your-data/?utm_source=wpadmin&utm_campaign=welcome_page">', '</a>', '<a id="share_analytics" href="javascript:;">', '</a>'), __("We know too little about our users. We're looking for [link]anonymous data[/link] to build a better plugin. Thanks, you're already sharing!", WYSIJA))
166
- );
167
- }
168
-
169
- $this->data['sections'][] = array(
170
- 'title' => __('What You Can Do', WYSIJA),
171
- 'cols' => array(
172
- array(
173
- 'title' => __('5 minute newbie guide', WYSIJA),
174
- 'content' => __('Your MailPoet comes with an example newsletter. You\'ll see it when you close this welcome page. Edit it to start playing with it.', WYSIJA)
175
- ),
176
- $share_section,
177
- array(
178
- 'title' => __('Help yourself. Or let us help you.', WYSIJA),
179
- 'content' => str_replace(
180
- array('[link]', '[/link]'), array('<a href="http://support.mailpoet.com/" target="_blank" title="On our blog!">', '</a>'), __('We got documentation and a ticket system on [link]support.mailpoet.com[/link]. We answer within 24h.', WYSIJA))
181
- )
182
- ),
183
- 'format' => 'three-col',
184
- );
185
-
186
- $this->viewObj->skip_header = true;
187
-
188
- return true;
189
- }
190
-
191
- /**
192
- * Welcome page for updaters
193
- * @return boolean
194
- */
195
- function whats_new() {
196
-
197
- $this->title = $this->viewObj->title = __('What\'s new?', WYSIJA);
198
- $this->jsTrans['instalwjp'] = __('Installing MailPoet Newsletter Premium plugin', WYSIJA);
199
- wp_enqueue_style('wysija-admin-css-premium', WYSIJA_URL.'css/admin-premium.css',array(),WYSIJA::get_version());
200
-
201
- $this->viewObj->skip_header = true;
202
- return true;
203
- }
204
-
205
-
206
-
207
- /* START prem check hook */
208
-
209
- // when curl or any php remote function not available mailpoet.com returns lcheck to that function
210
- function licok() {
211
- parent::WYSIJA_control_back();
212
- $dt = get_option('wysijey');
213
-
214
- if (isset($_REQUEST['xtz']) && $dt === $_REQUEST['xtz']) {
215
- $dataconf = array('premium_key' => base64_encode(get_option('home') . time()), 'premium_val' => time());
216
- $this->notice(__('Premium version is valid for your site.', WYSIJA));
217
- } else {
218
- $dataconf = array('premium_key' => '', 'premium_val' => '');
219
-
220
- $helper_licence = WYSIJA::get('licence', 'helper');
221
- $url_premium = 'http://www.mailpoet.com/checkout/?wysijadomain=' . $dt . '&nc=1&utm_source=wpadmin&utm_campaign=error_licence_activation';
222
-
223
- $this->error(str_replace(array('[link]', '[/link]'), array('<a href="' . $url_premium . '" target="_blank">', '</a>'), __('Premium licence does not exist for your site. Purchase it [link]here[/link].', WYSIJA)), 1);
224
- }
225
- WYSIJA::update_option('wysicheck', false);
226
- $modelConf = WYSIJA::get('config', 'model');
227
- $modelConf->save($dataconf);
228
-
229
- $this->redirect('admin.php?page=wysija_config#tab-premium');
230
- }
231
-
232
- /* END prem check hook */
233
-
234
- function validateLic() {
235
- $helpLic = WYSIJA::get('licence', 'helper');
236
- $res = $helpLic->check();
237
-
238
- $this->redirect();
239
- }
240
-
241
- /**
242
- * this function is triggered when sending manually the emails with the "Don't wait and send right now" button
243
- * @param type $dataPost
244
- */
245
- function manual_send($dataPost = false) {
246
- $modelQ = WYSIJA::get('queue', 'model');
247
- $config = WYSIJA::get('config', 'model');
248
- if ((int) $config->getValue('total_subscribers') < 2000) {
249
- if ($modelQ->count() > 0) {
250
- $helperQ = WYSIJA::get('queue', 'helper');
251
- $emailid = false;
252
- if ($_REQUEST['emailid']) {
253
- $emailid = $_REQUEST['emailid'];
254
- }
255
- $helperQ->process($emailid);
256
- } else {
257
- echo '<strong style="font-family: Arial; font-weight: bold; font-size: 12px;">' . __('Queue is empty!', WYSIJA) . '</strong>';
258
- }
259
- exit;
260
- } else {
261
- //deprecated
262
- do_action('wysija_send_test_editor');
263
-
264
- do_action('wysija_manual_send');
265
- }
266
-
267
- exit;
268
- }
269
-
270
- /**
271
- * test the bounce handling maybe this should move somewhere else like config controller
272
- * @return boolean
273
- */
274
- function test_bounce() {
275
- // bounce handling
276
- $helper_bounce = WYSIJA::get('bounce', 'helper');
277
-
278
- // in a multisite case we process first the bounce recording into the bounce table
279
- if (is_multisite()) {
280
- $helper_bounce->record_bounce_ms();
281
-
282
- // then we take actions from what has been returned by the bounce
283
- $helper_bounce->process_bounce_ms();
284
- } else {
285
- $helper_bounce->process_bounce();
286
- }
287
- exit;
288
- }
289
-
290
- function add($dataPost = false) {
291
- $this->title = sprintf(__('Step %1$s', WYSIJA), 1);
292
- $this->js[] = 'wysija-validator';
293
-
294
- $this->js[] = 'wysija-edit-autonl';
295
- $this->js['admin-campaigns-edit'] = 'admin-campaigns-edit';
296
- $this->jsTrans['descauto'] = str_replace(array('[newsletter:number]', '[newsletter:total]', '[newsletter:post_title]'), array('<b>[newsletter:number]</b>', '<b>[newsletter:total]</b>', '<b>[newsletter:post_title]</b>'), __('Insert [newsletter:total] to show number of posts, [newsletter:post_title] to show the latest post\'s title & [newsletter:number] to display the issue number.', WYSIJA));
297
- $this->jsTrans['descstandard'] = __('The first thing your subscribers see. Be creative and increase your open rate!', WYSIJA);
298
- $this->immediateWarning();
299
- $this->viewObj->title = __('First step: main details', WYSIJA);
300
- $this->viewShow = 'add';
301
- $this->data = array();
302
- $this->data['campaign'] = array('name' => '', 'description' => '');
303
- $modelConfig = WYSIJA::get('config', 'model');
304
- $this->data['email'] = array('subject' => '', 'from_email' => $modelConfig->getValue('from_email'), 'from_name' => $modelConfig->getValue('from_name'));
305
- $this->data['lists'] = $this->__getLists(false, true, true);
306
-
307
- $this->dataAutoNl();
308
- $this->jsLoc['admin-campaigns-edit']['autofields'] = $this->data['autonl']['fields'];
309
- }
310
-
311
- /**
312
- * get the fields and fields value necessary when dealing with automatic newsletters
313
- */
314
- function dataAutoNl() {
315
- $dataFrequencyNoImmediate = $dataFrequency = array('daily' => __('once a day at...', WYSIJA),
316
- 'weekly' => __('weekly on...', WYSIJA),
317
- 'monthly' => __('monthly on the...', WYSIJA),
318
- 'monthlyevery' => __('monthly every...', WYSIJA),
319
- 'immediate' => __('immediately.', WYSIJA));
320
-
321
- unset($dataFrequencyNoImmediate['immediate']);
322
-
323
- $times = array();
324
- $time = strtotime('00:00:00');
325
- $toolboxH = WYSIJA::get('toolbox', 'helper');
326
- $times['00:00:00'] = $toolboxH->localtime($time);
327
-
328
- for ($i = 1; $i < 24; $i++) {
329
- $time = strtotime('+ 1hour', $time);
330
- $key = date('H:i:s', $time);
331
- $times[$key] = $toolboxH->localtime($time);
332
- }
333
-
334
- $daysvalues = $toolboxH->getday();
335
-
336
- $numberweeks = $toolboxH->getweeksnumber();
337
- $daynumbers = $toolboxH->getdaynumber();
338
-
339
-
340
- $dataLists = array();
341
-
342
- foreach ($this->data['lists'] as $datal) {
343
- if ($datal['is_enabled'])
344
- $dataLists[$datal['list_id']] = $datal['name'];
345
- }
346
-
347
- // Get all available roles
348
- $wptoolsH = WYSIJA::get('wp_tools', 'helper');
349
- $roles = $wptoolsH->wp_get_all_roles();
350
- $available_roles = array('any' => __('in any WordPress role', WYSIJA));
351
- foreach ($roles as $role => $name) {
352
- $available_roles[$role] = $name;
353
- }
354
-
355
- $this->data['autonl']['fields'] = array(
356
- 'event' => array(
357
- 'values' => array(
358
- 'new-articles' => __('When there\'s new content...', WYSIJA),
359
- 'subs-2-nl' => __('When someone subscribes to the list...', WYSIJA),
360
- 'new-user' => __('When a new WordPress user is added to your site...', WYSIJA),
361
- ),
362
- 'valueshow' => array(
363
- 'new-articles' => array('when-article'),
364
- 'subs-2-nl' => array('subscribetolist', 'numberafter', 'numberofwhat', 'unique_send'),
365
- 'new-user' => array('roles', 'numberafter', 'numberofwhat', 'unique_send'),
366
- ),
367
- 'style' => 'width:300px;'
368
- ),
369
- 'when-article' => array(
370
- 'values' => $dataFrequency,
371
- 'valueshow' => array(
372
- 'daily' => array('time'),
373
- 'weekly' => array('dayname', 'time'),
374
- 'monthly' => array('daynumber', 'time'),
375
- 'monthlyevery' => array('dayevery', 'dayname', 'time'),
376
- )
377
- ),
378
- 'subscribetolist' => array(
379
- 'values' => $dataLists,
380
- 'style' => 'width:300px;'
381
- ),
382
- 'roles' => array(
383
- 'values' => $available_roles
384
- ),
385
- 'numberafter' => array(
386
- 'type' => 'input',
387
- 'style' => 'width:35px;',
388
- 'class' => 'validate[required,custom[integer],min[1]]',
389
- ),
390
- 'numberofwhat' => array(
391
- 'values' => array(
392
- 'immediate' => __('immediately.', WYSIJA),
393
- 'hours' => __('hour(s) after.', WYSIJA),
394
- 'days' => __('day(s) after.', WYSIJA),
395
- 'weeks' => __('week(s) after.', WYSIJA)
396
- ),
397
- 'valuesunit' => array(
398
- 'immediate' => __('immediately', WYSIJA),
399
- 'hours' => __('hour(s)', WYSIJA),
400
- 'days' => __('day(s)', WYSIJA),
401
- 'weeks' => __('week(s)', WYSIJA)
402
- ),
403
- ),
404
- 'dayevery' => array(
405
- 'values' => $numberweeks,
406
- ),
407
- 'dayname' => array(
408
- 'values' => $daysvalues,
409
- ),
410
- 'daynumber' => array(
411
- 'values' => $daynumbers,
412
- ),
413
- 'time' => array(
414
- 'values' => $times,
415
- ),
416
- /* 'unique_send'=>array(
417
- 'label_before'=>__('Send this email only once.',WYSIJA),
418
- 'type'=>'checkbox'
419
- ), */
420
- );
421
- $helpersEvent = WYSIJA::get('autonews', 'helper');
422
- $extraEvents = $helpersEvent->events();
423
-
424
- /* if there are plugin to add autonewsletter event they are adding their customized field over here */
425
- if ($extraEvents) {
426
- foreach ($extraEvents as $k => $v) {
427
-
428
- $this->data['autonl']['fields']['event']['values'][$k] = $v['title'];
429
- foreach ($v['fields'] as $fieldCKEY => $fieldCVAL) {
430
- if (isset($this->data['autonl']['fields'][$fieldCKEY]))
431
- continue;
432
- }
433
- $this->data['autonl']['fields']['event']['valueshow'][$k] = array_keys($v['fields']);
434
- }
435
- }
436
- }
437
-
438
- function __getLists($enabled = true, $count = false, $notgetalllistid = false) {
439
- $modelList = WYSIJA::get('list', 'model');
440
- //get lists which have users and are enabled */
441
- if ($enabled)
442
- $enabledstrg = ' is_enabled>0 and';
443
- else
444
- $enabledstrg = '';
445
-
446
- $extrasql = '';
447
- if (!$notgetalllistid)
448
- $extrasql = 'WHERE list_id in (SELECT distinct(list_id) from [wysija]user_list )';
449
- $query = 'SELECT * FROM [wysija]list ' . $extrasql;
450
- $listres = $modelList->query('get_res', $query);
451
-
452
- if ($count) {
453
- $mConfig = WYSIJA::get('config', 'model');
454
- $condit = '>=';
455
- if ($mConfig->getValue('confirm_dbleoptin'))
456
- $condit = '>';
457
- $qry1 = "SELECT count(distinct A.user_id) as nbsub,A.list_id FROM `[wysija]user_list` as A LEFT JOIN `[wysija]user` as B on A.user_id=B.user_id WHERE B.status $condit 0 and A.sub_date>0 and A.unsub_date=0 GROUP BY list_id";
458
-
459
- $total = $modelList->getResults($qry1);
460
-
461
- foreach ($total as $tot) {
462
- foreach ($listres as $key => $res) {
463
- if ($tot['list_id'] == $res['list_id'])
464
- $listres[$key]['count'] = $tot['nbsub'];
465
- }
466
- }
467
- }
468
- foreach ($listres as $key => $res) {
469
- if (!isset($res['count']))
470
- $listres[$key]['count'] = 0;
471
- }
472
- return $listres;
473
- }
474
-
475
- function edit($dataPost = false) {
476
- if (!$this->_checkEmailExists($_REQUEST['id']))
477
- return;
478
- $this->add();
479
-
480
- $modelEmail = WYSIJA::get('email', 'model');
481
-
482
- $this->data['email'] = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
483
-
484
- if ($this->data['email']['status'] > 0) {
485
- $this->redirect();
486
- }
487
- $this->title = sprintf(__('Step %1$s', WYSIJA), 1) . ' | ' . $this->data['email']['subject'];
488
- $modelCamp = WYSIJA::get('campaign', 'model');
489
- $this->data['campaign'] = $modelCamp->getOne(false, array('campaign_id' => $this->data['email']['campaign_id']));
490
-
491
- $modelCL = WYSIJA::get('campaign_list', 'model');
492
- $this->data['campaign_list'] = $modelCL->get(false, array('campaign_id' => $this->data['email']['campaign_id']));
493
- }
494
-
495
- function editTemplate() {
496
- // make sure the editor content is not cached
497
- header('Cache-Control: no-cache, max-age=0, must-revalidate, no-store'); // HTTP/1.1
498
- header('Expires: Fri, 9 Mar 1984 00:00:00 GMT');
499
-
500
- if (!$this->_checkEmailExists($_REQUEST['id']))
501
- return;
502
- $this->viewShow = 'editTemplate';
503
-
504
- wp_enqueue_style('thickbox');
505
-
506
- $wjEngine = WYSIJA::get('wj_engine', 'helper');
507
- /* WJ editor translations */
508
- $this->jsTrans = array_merge($this->jsTrans, $wjEngine->getTranslations(), $wjEngine->getApplicationData());
509
-
510
- $this->jsTrans['savingnl'] = __('Saving newsletter...', WYSIJA);
511
- $this->jsTrans['errorsavingnl'] = __('Error Saving newsletter...', WYSIJA);
512
- $this->jsTrans['savednl'] = __('Newsletter has been saved.', WYSIJA);
513
- $this->jsTrans['previewemail'] = __('Sending preview...', WYSIJA);
514
- $this->jsTrans['spamtestresult'] = __('Spam test results', WYSIJA);
515
-
516
- /* WJ editor JS */
517
- $this->js[] = 'wysija-editor';
518
- $this->js[] = 'wysija-admin-ajax-proto';
519
- $this->js[] = 'wysija-admin-ajax';
520
- $this->js[] = 'wysija-base-script-64';
521
- $this->js[] = 'media-upload';
522
- $this->js['admin-campaigns-editDetails'] = 'admin-campaigns-editDetails';
523
- $modelEmail = WYSIJA::get('email', 'model');
524
- $this->data = array();
525
- $this->data['email'] = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
526
-
527
- $this->checkIsEditable();
528
-
529
- $this->viewObj->title = sprintf(__('Second step: "%1$s"', WYSIJA), $this->data['email']['subject']);
530
- $this->title = sprintf(__('Step %1$s', WYSIJA), 2) . " | " . $this->data['email']['subject'];
531
-
532
- // check if html source is enabled in the config (this will add the "html source" button in tinymce)
533
- $model_config = WYSIJA::get('config', 'model');
534
- $this->jsTrans['html_source_enabled'] = (int) $model_config->getValue('html_source');
535
- }
536
-
537
- function checkIsEditable() {
538
- if (
539
- !($this->data['email'] == 2 || isset($this->data['email']['params']['schedule']['isscheduled'])) && $this->data['email']['status'] > 0
540
- ) {
541
- $this->redirect();
542
- }
543
- }
544
-
545
- function pause() {
546
- /* pause the campaign entry */
547
- if (isset($_REQUEST['id']) && $_REQUEST['id']) {
548
- $modelEmail = WYSIJA::get('email', 'model');
549
- $myemail = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
550
- $modelEmail->reset();
551
- $modelEmail->columns['modified_at']['autoup'] = 1;
552
- $modelEmail->update(array('status' => -1), array('email_id' => $_REQUEST['id']));
553
-
554
- if ($myemail['type'] == 2) {
555
- return $this->redirect('admin.php?page=wysija_campaigns&id=' . $myemail['email_id'] . '&action=edit');
556
- } else {
557
- $this->notice(__('Sending is now paused.', WYSIJA));
558
- }
559
- }
560
-
561
- $this->redirect();
562
- }
563
-
564
- function resume() {
565
- /* pause the campaign entry */
566
- if (isset($_REQUEST['id']) && $_REQUEST['id']) {
567
- $modelEmail = WYSIJA::get('email', 'model');
568
- $modelEmail->columns['modified_at']['autoup'] = 1;
569
- $modelEmail->update(array('status' => 99), array('email_id' => $_REQUEST['id']));
570
- $this->notice(__('Sending has resumed.', WYSIJA));
571
- }
572
-
573
- $this->redirect();
574
- }
575
-
576
- function duplicate() {
577
-
578
- /* 1 - copy the campaign entry */
579
-
580
- $model = WYSIJA::get('campaign', 'model');
581
- $query = 'INSERT INTO `[wysija]campaign` (`name`,`description`)
582
- SELECT concat("' . stripslashes(__('Copy of ', WYSIJA)) . '",`name`),`description` FROM [wysija]campaign
583
- WHERE campaign_id=' . (int) $_REQUEST['id'];
584
- $campaignid = $model->query($query);
585
-
586
- /* 2 - copy the email entry */
587
- $query = 'INSERT INTO `[wysija]email` (`campaign_id`,`subject`,`body`,`type`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,`status`,`created_at`,`modified_at`)
588
- SELECT ' . $campaignid . ', concat("' . stripslashes(__('Copy of ', WYSIJA)) . '",`subject`),`body`,`type`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,0,' . time() . ',' . time() . ' FROM [wysija]email
589
- WHERE email_id=' . (int) $_REQUEST['email_id'];
590
- $emailid = $model->query($query);
591
-
592
- //let's reset the count of total childs for auto newsletter
593
- $mEmail = WYSIJA::get('email', 'model');
594
- $emailData = $mEmail->getOne(false, array('email_id' => $emailid));
595
-
596
- if ($emailData['type'] == 2) {
597
- $paramsReseted = $emailData['params'];
598
- if (isset($paramsReseted['autonl']['total_child']))
599
- $paramsReseted['autonl']['total_child'] = 0;
600
- if (isset($paramsReseted['autonl']['nextSend']))
601
- $paramsReseted['autonl']['nextSend'] = 0;
602
- if (isset($paramsReseted['autonl']['firstSend']))
603
- unset($paramsReseted['autonl']['firstSend']);
604
- if (isset($paramsReseted['autonl']['lastSend']))
605
- unset($paramsReseted['autonl']['lastSend']);
606
- if (isset($paramsReseted['autonl']['articles']['ids']))
607
- unset($paramsReseted['autonl']['articles']['ids']);
608
-
609
-
610
- $mEmail->update(array('params' => $paramsReseted), array('email_id' => $emailid));
611
- }
612
-
613
- /* 3 - copy the campaign_list entry */
614
- $query = "INSERT INTO `[wysija]campaign_list` (`campaign_id`,`list_id`,`filter`)
615
- SELECT $campaignid,`list_id`,`filter` FROM [wysija]campaign_list
616
- WHERE campaign_id=" . (int) $_REQUEST['id'];
617
- $model->query($query);
618
-
619
- $this->notice(__('The newsletter has been duplicated.', WYSIJA));
620
-
621
- $this->redirect('admin.php?page=wysija_campaigns&id=' . $emailid . '&action=edit');
622
- }
623
-
624
- function duplicateEmail() {
625
- if (!$this->_checkEmailExists($_REQUEST['id']))
626
- return;
627
-
628
- $model = WYSIJA::get('campaign', 'model');
629
- /* 2 - copy the email entry */
630
- $query = 'INSERT INTO `[wysija]email` (`campaign_id`,`subject`,`body`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,`status`,`created_at`,`modified_at`)
631
- SELECT `campaign_id`, concat("' . stripslashes(__("Copy of ", WYSIJA)) . '",`subject`),`body`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,0,' . time() . ',' . time() . ' FROM [wysija]email
632
- WHERE email_id=' . (int) $_REQUEST['id'];
633
- $emailid = $model->query($query);
634
-
635
- $this->notice(__('The newsletter has been duplicated.', WYSIJA));
636
-
637
- $this->redirect('admin.php?page=wysija_campaigns&id=' . $emailid . '&action=edit');
638
- }
639
-
640
- function immediateWarning() {
641
- $model_config = WYSIJA::get('config', 'model');
642
- $is_multisite = is_multisite();
643
-
644
- //$is_multisite=true;//PROD comment that line
645
- if ($is_multisite && $model_config->getValue('sending_method') == 'network') {
646
- $sending_emails_each = $model_config->getValue('ms_sending_emails_each');
647
- $number = $model_config->getValue('ms_sending_emails_number');
648
- } else {
649
- $sending_emails_each = $model_config->getValue('sending_emails_each');
650
- $number = $model_config->getValue('sending_emails_number');
651
- }
652
-
653
- $formsHelp = WYSIJA::get('forms', 'helper');
654
-
655
- $timespan = $formsHelp->eachValuesSec[$sending_emails_each];
656
- $tb = WYSIJA::get('toolbox', 'helper');
657
-
658
- $this->immediatewarning = str_replace(
659
- array('[link]', '[/link]', '[settings]'), array('<a href="#">', '</a>', sprintf(__('%1$s emails every %2$s', WYSIJA), $number, trim($tb->duration_string($timespan, true)))), __('Your sending settings ([settings]) can\'t send that quickly to [number] subscribers. Expect delivery delays. [link]Read more[/link]', WYSIJA));
660
- $this->viewObj->immediatewarning = '<span class="warning-msg" id="immediatewarning">' . $this->immediatewarning . '</span>';
661
-
662
- $this->jsTrans['immediatewarning'] = $this->immediatewarning;
663
-
664
- //how many emails can be sent in 12 hours
665
- //if the frequency is less than 12hours
666
- if ($timespan < 43200) {
667
- $ratio = floor(43200 / $timespan);
668
- $this->jsTrans['possibleemails'] = $ratio * $number;
669
- } else {
670
- if ($timespan == 43200) {
671
- $this->jsTrans['possibleemails'] = $number;
672
- } else {
673
- $ratio = floor($timespan / 43200);
674
- $this->jsTrans['possibleemails'] = $number / $ratio;
675
- }
676
- }
677
- }
678
-
679
- function editDetails() {
680
- if (!$this->_checkEmailExists($_REQUEST['id']))
681
- return;
682
- $this->viewObj->title = __('Final step: last details', WYSIJA);
683
- $this->viewShow = 'editDetails';
684
- $this->js[] = 'wysija-validator';
685
- $this->jsTrans['previewemail'] = __('Sending preview...', WYSIJA);
686
- $this->jsTrans['pickadate'] = __('Pick a date', WYSIJA);
687
- $this->jsTrans['saveclose'] = __('Save & close', WYSIJA);
688
- $this->jsTrans['sendlater'] = __('Send later', WYSIJA);
689
-
690
- $this->jsTrans['schedule'] = __('Schedule', WYSIJA);
691
-
692
- $this->jsTrans['emailCheck'] = WJ_Utils::get_tip_data();
693
-
694
-
695
- $this->js[] = 'jquery-ui-datepicker';
696
- $this->js[] = 'wysija-tooltip';
697
-
698
- $model_list = WYSIJA::get('list', 'model');
699
- $model_list->limitON = false;
700
- $this->data = array();
701
- $this->data['lists'] = $this->__getLists(false, true, true);
702
-
703
- $model_email = WYSIJA::get('email', 'model');
704
- $this->data['email'] = $model_email->getOne(false, array('email_id' => $_REQUEST['id']));
705
-
706
- // The first newsletter, we don't have replyto_email and replyto_name
707
- if (empty($this->data['email']['replyto_email']) || empty($this->data['email']['replyto_name'])) {
708
- $current_user = wp_get_current_user();
709
- $this->data['email']['replyto_email'] = $current_user->data->user_email;
710
- $this->data['email']['replyto_name'] = $current_user->data->display_name;
711
- }
712
-
713
-
714
- if ((int) $this->data['email']['type'] == 2) {
715
- $this->js['wysija-edit-autonl'] = 'wysija-edit-autonl';
716
- $this->jsTrans['autonl'] = true;
717
- $this->immediateWarning();
718
- $this->jsTrans['send'] = __('Activate now', WYSIJA);
719
- } else {
720
- $this->jsTrans['autonl'] = true;
721
- $this->viewObj->immediatewarning = '';
722
- $this->jsTrans['send'] = __('Send', WYSIJA);
723
- }
724
-
725
- if ((int) $this->data['email']['type'] == 1) {
726
- $this->jsTrans['alertsend'] = __('You are about to send this newsletter. Please confirm.', WYSIJA);
727
- } else {
728
- if (isset($this->data['email']['params']['autonl']['event']) && $this->data['email']['params']['autonl']['event'] == 'subs-2-nl') {
729
- $this->data['autoresponder'] = 1;
730
- foreach ($this->data['lists'] as $list) {
731
- if ($list['list_id'] == $this->data['email']['params']['autonl']['subscribetolist']) {
732
- break;
733
- }
734
- }
735
-
736
- $this->jsTrans['ignoreprevious'] = sprintf(__('Are you sure you want to ignore the %1$s subscribers of the list %2$s?', WYSIJA), '"' . $list['count'] . '"', '"' . $list['name'] . '"');
737
- }
738
- }
739
-
740
- $this->checkIsEditable();
741
-
742
- $this->title = sprintf(__('Step %1$s', WYSIJA), 3) . " | " . $this->data['email']['subject'];
743
- $this->dataAutoNl();
744
-
745
- $this->jsLoc['wysija-edit-autonl']['autofields'] = $this->data['autonl']['fields'];
746
-
747
- $modelCL = WYSIJA::get('campaign_list', 'model');
748
- $this->data['campaign_list'] = $modelCL->get(false, array('campaign_id' => $this->data['email']['campaign_id']));
749
- }
750
-
751
- function delete() {
752
- $this->requireSecurity();
753
-
754
- $campaign_ids = array();
755
- if(isset($_REQUEST['id'])) $campaign_ids[] = $_REQUEST['id'];
756
- if(isset($_REQUEST['campaign']['campaign_id'])) $campaign_ids[] = $_REQUEST['campaign']['campaign_id'];
757
- if(isset($_REQUEST['wysija']['campaign']['campaign_id'][0])){
758
- $campaign_ids = array_merge($campaign_ids, $_REQUEST['wysija']['campaign']['campaign_id']);
759
- }
760
-
761
- if (!empty($campaign_ids)) {
762
- foreach($campaign_ids as $campaign_id){
763
- if($campaign_id > 0){
764
- $model_campaign = WYSIJA::get('campaign', 'model');
765
- $model_campaign->delete(array('campaign_id' => $campaign_id));
766
-
767
- $model_campaign_list = WYSIJA::get('campaign_list', 'model');
768
- $model_campaign_list->delete(array('campaign_id' => $campaign_id));
769
-
770
- $modelEmail = WYSIJA::get('email', 'model');
771
- $modelEmail->delete(array('campaign_id' => $campaign_id));
772
- }
773
- }
774
-
775
- $this->notice(_n(__('Newsletter deleted.', WYSIJA), __('Newsletters deleted.', WYSIJA), count($campaign_ids), WYSIJA));
776
- } else {
777
- $this->notice(__('Newsletter can\'t be deleted.', WYSIJA));
778
- }
779
-
780
- // retrieve saved filter
781
- if (!empty($_REQUEST['action']))
782
- unset($_REQUEST['action']);
783
- if (!empty($_REQUEST['id']))
784
- unset($_REQUEST['id']);
785
- if (!empty($_REQUEST['_wpnonce']))
786
- unset($_REQUEST['_wpnonce']);
787
- $redirect = $this->base_url . '?' . http_build_query($_REQUEST);
788
- $this->redirect($redirect);
789
- }
790
-
791
- /**
792
- *
793
- * this function is to delete an email that belongs to a campaign
794
- * when we have a post notification all emails belong to the same campaign
795
- * we don't want to delete an entire campaign when we delete a single email
796
- */
797
- function deleteEmail(){
798
- $this->requireSecurity();
799
- if(!$this->_checkEmailExists($_REQUEST['id'])) return;
800
-
801
- if(isset($_REQUEST['id'])){
802
- $modelEmail=WYSIJA::get('email','model');
803
- $modelEmail->delete(array('email_id'=>$_REQUEST['id']));
804
- $this->notice(__('Newsletter deleted.',WYSIJA));
805
- }else{
806
- $this->notice(__('Newsletter can\'t be deleted.',WYSIJA));
807
- }
808
-
809
- $this->redirect();
810
- }
811
-
812
- function savecamp() {
813
- $this->redirectAfterSave = false;
814
-
815
- /* update email */
816
- $data = array();
817
-
818
- // in case the newsletter already exists
819
- if (isset($_REQUEST['id'])) {
820
- $modelEmail = WYSIJA::get('email', 'model');
821
- $modelEmail->fieldValid = false;
822
- $emaildataarr = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
823
-
824
- $model_campaign = WYSIJA::get('campaign', 'model');
825
- $model_campaign->update(array('name' => $_POST['wysija']['email']['subject'], 'description' => ''), array('campaign_id' => $emaildataarr['campaign_id']));
826
-
827
- $campaign_id = $emaildataarr['campaign_id'];
828
- $email_id = $emaildataarr['email_id'];
829
- $dataEmail = array(
830
- 'campaign_id' => $campaign_id,
831
- 'subject' => $_POST['wysija']['email']['subject'],
832
- 'type' => $_POST['wysija']['email']['type']);
833
-
834
- if((int)$dataEmail['type'] === 2) {
835
- // set autonl params
836
- $dataEmail['params'] = array('autonl' => $_POST['wysija']['email']['params']['autonl']);
837
-
838
- // WTF?
839
- if(!isset($newparams['autonl']['unique_send'])) {
840
- unset($dataEmail['params']['autonl']['unique_send']);
841
- } else {
842
- $dataEmail['params']['autonl']['unique_send'] = true;
843
- }
844
- }
845
-
846
- // check if the newsletter used to be an automatic newsletter (if )
847
- if((int)$dataEmail['type'] === 1 && (int)$emaildataarr['type'] === 2) {
848
- // make sure we remove any kind of auto-post block
849
- $helper_autonews = WYSIJA::get('autonews', 'helper');
850
- $updated_email_data = $helper_autonews->remove_autopost_blocks($emaildataarr['wj_data']);
851
- if($updated_email_data !== false) {
852
- // if the email data has been changed, make sure to update it in the DB
853
- $dataEmail['wj_data'] = $updated_email_data;
854
- }
855
- }
856
-
857
- $modelEmail->columns['modified_at']['autoup'] = 1;
858
- $modelEmail->debugupdate = true;
859
- $dataEmail['email_id'] = $_REQUEST['id'];
860
-
861
- if(isset($_REQUEST['save-reactivate'])) {
862
- //if the button save and reactivate has been clicked then we reactivate and redirect to the newsletter page
863
- $dataEmail['status'] = 99;
864
- $_REQUEST['return'] = 1;
865
- }
866
-
867
- $data['email']['email_id'] = $modelEmail->update($dataEmail, array('email_id' => (int)$_REQUEST['id']));
868
- } else {
869
- // get default theme
870
- $model_config = WYSIJA::get('config', 'model');
871
- $default_theme = $model_config->getValue('newsletter_default_theme', 'default');
872
-
873
- $helper_themes = WYSIJA::get('themes', 'helper');
874
- $theme_data = $helper_themes->getData($default_theme);
875
-
876
- // get campaign data
877
- $model_campaign = WYSIJA::get('campaign', 'model');
878
- $campaign_id = $model_campaign->insert(array('name' => $_POST['wysija']['email']['subject'], 'description' => ''));
879
-
880
- $modelEmail = WYSIJA::get('email', 'model');
881
- $modelEmail->fieldValid = false;
882
- $emaildata = array(
883
- 'campaign_id' => $campaign_id,
884
- 'subject' => $_POST['wysija']['email']['subject'],
885
- 'type' => (int) $_POST['wysija']['email']['type']
886
- );
887
-
888
-
889
- // create autonl parameters if necessary
890
- if ((int) $_POST['wysija']['email']['type'] === 2 && isset($_POST['wysija']['email']['params']['autonl'])) {
891
- $emaildata['params'] = array('autonl' => $_POST['wysija']['email']['params']['autonl']);
892
- }
893
-
894
- // create sample data depending on newsletter's type
895
- if ((int) $_POST['wysija']['email']['type'] === 2 && $_POST['wysija']['email']['params']['autonl']['event'] === 'new-articles') {
896
-
897
- // if immediate, post_limit is set to 1
898
- if ($emaildata['params']['autonl']['when-article'] === 'immediate') {
899
- $autopostParams = array(
900
- array('key' => 'category_ids', 'value' => null),
901
- array('key' => 'title_tag', 'value' => 'h2'),
902
- array('key' => 'title_alignment', 'value' => 'left'),
903
- array('key' => 'title_position', 'value' => 'inside'),
904
- array('key' => 'image_alignment', 'value' => 'alternate'),
905
- array('key' => 'image_width', 'value' => 325),
906
- array('key' => 'post_content', 'value' => 'excerpt'),
907
- array('key' => 'readmore', 'value' => base64_encode(__('Read more.', WYSIJA))),
908
- array('key' => 'show_divider', 'value' => 'yes'),
909
- array('key' => 'post_limit', 'value' => 1),
910
- array('key' => 'post_type', 'value' => 'post'),
911
- array('key' => 'author_show', 'value' => 'no'),
912
- array('key' => 'author_label', 'value' => base64_encode(__('Author:', WYSIJA))),
913
- array('key' => 'category_show', 'value' => 'no'),
914
- array('key' => 'category_label', 'value' => base64_encode(__('Categories:', WYSIJA))),
915
- array('key' => 'nopost_message', 'value' => base64_encode(__('Latest content already sent.', WYSIJA))),
916
- array('key' => 'bgcolor1', 'value' => null),
917
- array('key' => 'bgcolor2', 'value' => null),
918
- array('key' => 'sort_by', 'value' => 'newest')
919
- );
920
- } else {
921
- $autopostParams = array(
922
- array('key' => 'category_ids', 'value' => null),
923
- array('key' => 'title_tag', 'value' => 'h2'),
924
- array('key' => 'title_alignment', 'value' => 'left'),
925
- array('key' => 'title_position', 'value' => 'inside'),
926
- array('key' => 'image_alignment', 'value' => 'alternate'),
927
- array('key' => 'image_width', 'value' => 325),
928
- array('key' => 'post_content', 'value' => 'excerpt'),
929
- array('key' => 'readmore', 'value' => base64_encode(__('Read more.', WYSIJA))),
930
- array('key' => 'show_divider', 'value' => 'yes'),
931
- array('key' => 'post_limit', 'value' => 2),
932
- array('key' => 'post_type', 'value' => 'post'),
933
- array('key' => 'author_show', 'value' => 'no'),
934
- array('key' => 'author_label', 'value' => base64_encode(__('Author:', WYSIJA))),
935
- array('key' => 'category_show', 'value' => 'no'),
936
- array('key' => 'category_label', 'value' => base64_encode(__('Categories:', WYSIJA))),
937
- array('key' => 'nopost_message', 'value' => base64_encode(__('Latest content already sent.', WYSIJA))),
938
- array('key' => 'bgcolor1', 'value' => null),
939
- array('key' => 'bgcolor2', 'value' => null),
940
- array('key' => 'sort_by', 'value' => 'newest')
941
- );
942
- }
943
-
944
- // sample data for post notifications
945
- $newwjdata = array(
946
- 'version' => WYSIJA::get_version(),
947
- 'header' => array(
948
- 'text' => NULL,
949
- 'image' => array(
950
- 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
951
- 'width' => 600,
952
- 'height' => 86,
953
- 'alignment' => 'center',
954
- 'static' => true,
955
- ),
956
- 'alignment' => 'center',
957
- 'static' => true,
958
- 'type' => 'header'
959
- ),
960
- 'body' => array(
961
- 'block-1' => array(
962
- 'text' => array(
963
- 'value' => '<h3 class="align-right">' . sprintf(__("The posts below were added with the widget %sAutomatic latest content%s", WYSIJA), '<strong>', '</strong>') . '</h3>'
964
- ),
965
- 'image' => array(
966
- 'src' => WYSIJA_EDITOR_IMG . 'default-newsletter/autonewsletter/arrow-up.png',
967
- 'width' => 45,
968
- 'height' => 45,
969
- 'alignment' => 'right',
970
- 'static' => false
971
- ),
972
- 'alignment' => 'right',
973
- 'static' => false,
974
- 'position' => '1',
975
- 'type' => 'content'
976
- ),
977
- 'block-2' => array(
978
- 'text' => array(
979
- 'value' => '<h3>' . sprintf(__('%sTo edit%s, mouse over to show edit button below.', WYSIJA), '<strong>', '</strong>') . '</h3>'
980
- ),
981
- 'image' => array(
982
- 'src' => WYSIJA_EDITOR_IMG . 'default-newsletter/autonewsletter/arrow-down.png',
983
- 'width' => 150,
984
- 'height' => 53,
985
- 'alignment' => 'left',
986
- 'static' => false
987
- ),
988
- 'alignment' => 'left',
989
- 'static' => false,
990
- 'position' => '2',
991
- 'type' => 'content'
992
- ),
993
- 'block-3' => array(
994
- 'params' => $autopostParams,
995
- 'position' => '3',
996
- 'type' => 'auto-post'
997
- )
998
- ),
999
- 'footer' => array(
1000
- 'text' => NULL,
1001
- 'image' => array(
1002
- 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
1003
- 'width' => 600,
1004
- 'height' => 86,
1005
- 'alignment' => 'center',
1006
- 'static' => true,
1007
- ),
1008
- 'alignment' => 'center',
1009
- 'static' => true,
1010
- 'type' => 'footer'
1011
- )
1012
- );
1013
- } else {
1014
- if(!isset($emaildata['params'])) {
1015
- $emaildata['params'] = array();
1016
- }
1017
-
1018
- $emaildata['params']['quickselection'] = array(
1019
- 'wp-301' => array(
1020
- 'identifier' => 'wp-301',
1021
- 'width' => 281,
1022
- 'height' => 190,
1023
- 'url' => WYSIJA_EDITOR_IMG . 'default-newsletter/newsletter/pigeon.png',
1024
- 'thumb_url' => WYSIJA_EDITOR_IMG . 'default-newsletter/newsletter/pigeon-150x150.png'
1025
- )
1026
- );
1027
-
1028
- if($theme_data['divider'] === null) {
1029
- // default theme does not exist anymore or there is no divider associated to the theme
1030
- // we need to get the default divider in this case
1031
- $helper_dividers = WYSIJA::get('dividers', 'helper');
1032
- $default_divider = $helper_dividers->getDefault();
1033
- } else {
1034
- // set default divider
1035
- $default_divider = $theme_data['divider'];
1036
- }
1037
- // set default divider in email parameters
1038
- $emaildata['params']['divider'] = $default_divider;
1039
-
1040
- // get bookmarks from iconset 2
1041
- $helper_bookmarks = WYSIJA::get('bookmarks', 'helper');
1042
- $bookmarks = $helper_bookmarks->getAllByIconset('medium', '02');
1043
-
1044
- // sample data for regular newsletter
1045
- $newwjdata = array(
1046
- 'version' => WYSIJA::get_version(),
1047
- 'header' => array(
1048
- 'text' => null,
1049
- 'image' => array(
1050
- // 'src' => WYSIJA_EDITOR_IMG.'default-newsletter/newsletter/header.png',
1051
- 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
1052
- 'width' => 600,
1053
- 'height' => 86,
1054
- 'alignment' => 'center',
1055
- 'static' => true
1056
- ),
1057
- 'alignment' => 'center',
1058
- 'static' => true,
1059
- 'type' => 'header'
1060
- ),
1061
- 'body' => array(
1062
- 'block-1' => array(
1063
- 'text' => array(
1064
- 'value' => '<h2><strong>' . __('Step 1:', WYSIJA) . '</strong> ' . __('hey, click on this text!', WYSIJA) . '</h2>' . '<p>' . __('To edit, simply click on this block of text.', WYSIJA) . '</p>'
1065
- ),
1066
- 'image' => null,
1067
- 'alignment' => 'left',
1068
- 'static' => false,
1069
- 'position' => 1,
1070
- 'type' => 'content'
1071
- ),
1072
- 'block-2' => array_merge(array(
1073
- 'position' => 2,
1074
- 'type' => 'divider'
1075
- ),
1076
- $default_divider
1077
- ),
1078
- 'block-3' => array(
1079
- 'text' => array(
1080
- 'value' => '<h2><strong>' . __('Step 2:', WYSIJA) . '</strong> ' . __('play with this image', WYSIJA) . '</h2>'
1081
- ),
1082
- 'image' => null,
1083
- 'alignment' => 'left',
1084
- 'static' => false,
1085
- 'position' => 3,
1086
- 'type' => 'content'
1087
- ),
1088
- 'block-4' => array(
1089
- 'text' => array(
1090
- 'value' => '<p>' . __('Position your mouse over the image to the left.', WYSIJA) . '</p>'
1091
- ),
1092
- 'image' => array(
1093
- 'src' => WYSIJA_EDITOR_IMG . 'default-newsletter/newsletter/pigeon.png',
1094
- 'width' => 281,
1095
- 'height' => 190,
1096
- 'alignment' => 'left',
1097
- 'static' => false
1098
- ),
1099
- 'alignment' => 'left',
1100
- 'static' => false,
1101
- 'position' => 4,
1102
- 'type' => 'content'
1103
- ),
1104
- 'block-5' => array_merge(array(
1105
- 'position' => 5,
1106
- 'type' => 'divider'
1107
- ), $default_divider
1108
- ),
1109
- 'block-6' => array(
1110
- 'text' => array(
1111
- 'value' => '<h2><strong>' . __('Step 3:', WYSIJA) . '</strong> ' . __('drop content here', WYSIJA) . '</h2>' .
1112
- '<p>' . sprintf(__('Drag and drop %1$stext, posts, dividers.%2$s Look on the right!', WYSIJA), '<strong>', '</strong>') . '</p>' .
1113
- '<p>' . sprintf(__('You can even %1$ssocial bookmarks%2$s like these:', WYSIJA), '<strong>', '</strong>') . '</p>'
1114
- ),
1115
- 'image' => null,
1116
- 'alignment' => 'left',
1117
- 'static' => false,
1118
- 'position' => 6,
1119
- 'type' => 'content'
1120
- ),
1121
- 'block-7' => array(
1122
- 'width' => 184,
1123
- 'alignment' => 'center',
1124
- 'items' => array(
1125
- array_merge(array(
1126
- 'url' => 'http://www.facebook.com/mailpoetplugin',
1127
- 'alt' => 'Facebook',
1128
- 'cellWidth' => 61,
1129
- 'cellHeight' => 32
1130
- ), $bookmarks['facebook']),
1131
- array_merge(array(
1132
- 'url' => 'http://www.twitter.com/mail_poet',
1133
- 'alt' => 'Twitter',
1134
- 'cellWidth' => 61,
1135
- 'cellHeight' => 32
1136
- ), $bookmarks['twitter']),
1137
- array_merge(array(
1138
- 'url' => 'https://plus.google.com/+Mailpoet',
1139
- 'alt' => 'Google',
1140
- 'cellWidth' => 61,
1141
- 'cellHeight' => 32
1142
- ), $bookmarks['google'])
1143
- ),
1144
- 'position' => 7,
1145
- 'type' => 'gallery'
1146
- ),
1147
- 'block-8' => array_merge(array(
1148
- 'position' => 8,
1149
- 'type' => 'divider'
1150
- ), $default_divider
1151
- ),
1152
- 'block-9' => array(
1153
- 'text' => array(
1154
- 'value' => '<h2><strong>' . __('Step 4:', WYSIJA) . '</strong> ' . __('and the footer?', WYSIJA) . '</h2>' .
1155
- '<p>' . sprintf(__('Change the footer\'s content in MailPoet\'s %1$sSettings%2$s page.', WYSIJA), '<strong>', '</strong>') . '</p>'
1156
- ),
1157
- 'image' => null,
1158
- 'alignment' => 'left',
1159
- 'static' => false,
1160
- 'position' => 9,
1161
- 'type' => 'content'
1162
- )
1163
- ),
1164
- 'footer' => array(
1165
- 'text' => NULL,
1166
- 'image' => array(
1167
- // 'src' => WYSIJA_EDITOR_IMG.'default-newsletter/newsletter/footer.png',
1168
- 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
1169
- 'width' => 600,
1170
- 'height' => 86,
1171
- 'alignment' => 'center',
1172
- 'static' => true,
1173
- ),
1174
- 'alignment' => 'center',
1175
- 'static' => true,
1176
- 'type' => 'footer'
1177
- )
1178
- );
1179
- }
1180
-
1181
- // set default styles
1182
- $helper_engine = WYSIJA::get('wj_engine', 'helper');
1183
- $styles = $helper_engine->getDefaultStyles();
1184
- // end - set default styles
1185
-
1186
- // set theme specific data
1187
- if($theme_data['header'] !== null) {
1188
- $newwjdata['header'] = $theme_data['header'];
1189
- }
1190
- if($theme_data['footer'] !== null) {
1191
- $newwjdata['footer'] = $theme_data['footer'];
1192
- }
1193
- if($theme_data['divider'] !== null) {
1194
- $newwjdata['widgets'] = array('divider' => $theme_data['divider']);
1195
- }
1196
- // end - set theme specific data
1197
-
1198
- $emaildata['wj_data'] = base64_encode(serialize($newwjdata));
1199
- $emaildata['wj_styles'] = base64_encode(serialize($styles));
1200
-
1201
- $email_id = $data['email']['email_id'] = $modelEmail->insert($emaildata);
1202
-
1203
- $this->notice(__('Newsletter successfully created.', WYSIJA));
1204
- }
1205
-
1206
- $this->_saveLists($campaign_id, true);
1207
-
1208
- if (isset($_REQUEST['return']))
1209
- $this->redirect();
1210
- else {
1211
- $this->redirect('admin.php?page=wysija_campaigns&action=editTemplate&id=' . $email_id);
1212
- }
1213
- }
1214
-
1215
- function saveemail() {
1216
- $this->redirectAfterSave = false;
1217
- //$this->requireSecurity();
1218
- $modelEmail = WYSIJA::get("email", "model");
1219
- $modelEmail->fieldValid = false;
1220
- $emaildataarr = $modelEmail->getOne(array('email_id' => $_REQUEST['id']));
1221
-
1222
- if (isset($_REQUEST['save-reactivate'])) {
1223
- //if the button save and reactivate has been clicked then we reactivate and redirect to the newsletter page
1224
- $dataEmail['status'] = 99;
1225
- $_REQUEST['return'] = 1;
1226
- }
1227
-
1228
- if (isset($_REQUEST['return']))
1229
- $this->redirect();
1230
- else {
1231
- $this->redirect('admin.php?page=wysija_campaigns&action=editDetails&id=' . $emaildataarr['email_id']);
1232
- }
1233
- }
1234
-
1235
- function savelast() {
1236
- $this->redirectAfterSave = false;
1237
- $post_notification = false;
1238
- $this->requireSecurity();
1239
-
1240
- if (!isset($_POST['wysija']['email']['from_name']) || !isset($_POST['wysija']['email']['from_email']) || !isset($_POST['wysija']['email']['replyto_name']) || !isset($_POST['wysija']['email']['replyto_email'])) {
1241
- $this->error(__('Information is missing.', WYSIJA));
1242
- return $this->editDetails();
1243
- }
1244
- if (isset($_REQUEST['wysija']['email']['params']['googletrackingcode']) && $_REQUEST['wysija']['email']['params']['googletrackingcode'] &&
1245
- (!is_string($_REQUEST['wysija']['email']['params']['googletrackingcode']) OR
1246
- preg_match('#[^a-z0-9_\-\s]#i', $_REQUEST['wysija']['email']['params']['googletrackingcode']) !== 0 )) {
1247
- //force to simple text
1248
- $_REQUEST['wysija']['email']['params']['googletrackingcode'] = preg_replace('#[^a-z0-9_\-\s]#i', '_', $_REQUEST['wysija']['email']['params']['googletrackingcode']);
1249
- $this->error(__('Your Google Campaign can only contain latin characters, numbers, spaces and hyphens!', WYSIJA), 1);
1250
- return $this->editDetails();
1251
- }
1252
-
1253
- $update_email = array(
1254
- 'email_id' => $_POST['wysija']['email']['email_id'],
1255
- 'from_name' => $_POST['wysija']['email']['from_name'],
1256
- 'from_email' => $_POST['wysija']['email']['from_email'],
1257
- 'replyto_name' => $_POST['wysija']['email']['replyto_name'],
1258
- 'replyto_email' => $_POST['wysija']['email']['replyto_email'],
1259
- 'subject' => $_POST['wysija']['email']['subject'],
1260
- );
1261
- $model_email = WYSIJA::get('email', 'model');
1262
- if (isset($_POST['wysija']['email']['params']))
1263
- $update_email['params'] = $_POST['wysija']['email']['params'];
1264
-
1265
- //insert into campaigns lists
1266
- $this->_saveLists($_POST['wysija']['campaign']['campaign_id']);
1267
- $email_data = $model_email->getOne($_POST['wysija']['email']['email_id']);
1268
-
1269
- // if we just save the draf we don't go through the big sending process setup
1270
- if (isset($_POST['submit-draft']) || isset($_POST['submit-pause']) || (isset($_REQUEST['wj_redir']) && $_REQUEST['wj_redir'] == 'savelastback')) {
1271
- if (isset($_POST['wysija']['email']['params']['schedule']['isscheduled']))
1272
- $this->notice(__('Newsletter has been scheduled.', WYSIJA));
1273
- else
1274
- $this->notice(__('Newsletter has been saved as a draft.', WYSIJA));
1275
- }else {
1276
- // we update the param attribute with what's has been posted
1277
- foreach ($update_email as $ki => $vi) {
1278
- if ($ki == 'params') {
1279
- foreach ($vi as $parake => $paraval) {
1280
- $email_data['params'][$parake] = $paraval;
1281
- }
1282
- $update_email[$ki] = $email_data[$ki];
1283
- }
1284
- else
1285
- $email_data[$ki] = $vi;
1286
- }
1287
-
1288
- // if the checkbox to ignore retroactivity is here we just tell the class
1289
- if (isset($_POST['wysija']['email']['ignore_subscribers'])) {
1290
- $model_email->retro_active_autoresponders = false;
1291
- }
1292
-
1293
- // activate or send the email depending on the typ
1294
- $model_email->send_activate($email_data);
1295
- }
1296
-
1297
- // update email
1298
- $update_email['type'] = $email_data['type'];
1299
-
1300
- if ($post_notification) {
1301
- $helper_autonews = WYSIJA::get('autonews', 'helper');
1302
- $update_email['params']['autonl']['nextSend'] = $helper_autonews->getNextSend($update_email);
1303
- }
1304
-
1305
- $model_email->reset();
1306
- $model_email->columns['modified_at']['autoup'] = 1;
1307
-
1308
- // update some fields of the email
1309
- $model_email->update($update_email);
1310
-
1311
- // update the campaign subject which ispretty much useless but good to keep in sync with the email
1312
- $model_campaign = WYSIJA::get('campaign', 'model');
1313
- $model_campaign->reset();
1314
- $update_campaign = array('campaign_id' => $_REQUEST['id'], 'name' => $_POST['wysija']['email']['subject']);
1315
- $model_campaign->update($update_campaign);
1316
-
1317
- if (isset($_REQUEST['wj_redir']) && $_REQUEST['wj_redir'] == 'savelastback') {
1318
- return $this->redirect('admin.php?page=wysija_campaigns&action=editTemplate&id=' . $_POST['wysija']['email']['email_id']);
1319
- }
1320
- else
1321
- return $this->redirect();
1322
- }
1323
-
1324
- function _saveLists($campaignId, $flagup = false) {
1325
- //record the list that we have in that campaign
1326
- $modelCampL = WYSIJA::get('campaign_list', 'model');
1327
- if ($flagup || (int) $campaignId > 0) {
1328
- $modelCampL->delete(array('equal' => array('campaign_id' => $campaignId)));
1329
- $modelCampL->reset();
1330
- }
1331
-
1332
- if (isset($_POST['wysija']['campaign_list']['list_id'])) {
1333
- //$modelCampL=WYSIJA::get("campaign_list","model");
1334
- foreach ($_POST['wysija']['campaign_list']['list_id'] as $listid) {
1335
- $modelCampL->insert(array('campaign_id' => $campaignId, "list_id" => $listid));
1336
- }
1337
- }
1338
- }
1339
-
1340
- function _addLinkFilter($status, $type = 'status') {
1341
- switch ($type) {
1342
- case 'status':
1343
- switch ($status) {
1344
- case 'draft':
1345
- $this->filters['equal'] = array('status' => 0);
1346
- break;
1347
- case 'sending':
1348
- $this->filters['equal'] = array('status' => 99);
1349
- break;
1350
- case 'sent':
1351
- $this->filters['equal'] = array('status' => 2);
1352
- break;
1353
- case 'paused':
1354
- $this->filters['equal'] = array('status' => -1);
1355
- break;
1356
- case 'scheduled':
1357
- $this->filters['equal'] = array('status' => 4);
1358
- break;
1359
- }
1360
- break;
1361
- case 'type':
1362
- switch ($status) {
1363
- case 'regular':
1364
- $this->filters['equal'] = array('type' => 1);
1365
- break;
1366
- case 'autonl':
1367
- $this->filters['equal'] = array('type' => 2);
1368
- break;
1369
- }
1370
- break;
1371
- }
1372
- }
1373
-
1374
- /**
1375
- * Get all campaigns, based on the filters
1376
- */
1377
- protected function get_campaigns() {
1378
- $order_by = ' ORDER BY ';
1379
-
1380
- if (isset($_REQUEST['orderby'])) {
1381
- if (!is_string($_REQUEST['orderby']) OR preg_match('|[^a-z0-9#_.-]|i', $_REQUEST['orderby']) !== 0) {
1382
- $_REQUEST['orderby'] = '';
1383
- }
1384
- if (!in_array(strtoupper($_REQUEST['ordert']), array('DESC', 'ASC')))
1385
- $_REQUEST['ordert'] = 'DESC';
1386
- $order_by.=$_REQUEST['orderby'] . ' ' . $_REQUEST['ordert'];
1387
- }else {
1388
- $order_by.='FIELD(B.status, 99,3,1,0,2), ';
1389
- $order_by.='B.status desc, ';
1390
- $order_by.='B.modified_at desc, ';
1391
- $order_by.='B.sent_at desc, ';
1392
- $order_by.='B.type desc, ';
1393
- $order_by.='A.' . $this->modelObj->getPk() . ' DESC';
1394
- }
1395
-
1396
- $query = '
1397
- SELECT
1398
- A.`campaign_id`,
1399
- A.`name` as `campaign_name`,
1400
- B.`subject` as `name`,
1401
- A.`description`,
1402
- B.`params`,
1403
- B.`type`,
1404
- B.`number_sent`,
1405
- B.`number_opened`,
1406
- B.`number_clicked`,
1407
- B.`number_unsub`,
1408
- (B.`number_sent` +
1409
- B.`number_opened` +
1410
- B.`number_clicked` +
1411
- B.`number_unsub` +
1412
- B.`number_bounce` +
1413
- B.`number_forward`
1414
- ) AS `number_total`,
1415
- B.`status`,
1416
- B.`created_at`,
1417
- B.`modified_at`,
1418
- B.`sent_at`,
1419
- B.`email_id`
1420
- FROM
1421
- `[wysija]' . $this->modelObj->table_name . '` AS A
1422
- LEFT JOIN
1423
- `[wysija]email` AS B on A.`campaign_id` = B.`campaign_id`
1424
- LEFT JOIN
1425
- `[wysija]campaign_list` AS C on A.`campaign_id` = C.`campaign_id`';
1426
- $campaigns = $this->modelObj->getResults($query . $this->modelObj->makeWhere() . ' GROUP BY B.email_id' . $order_by . $this->modelObj->setLimit());
1427
-
1428
- // calculate percetange of open / click / unsubscribe
1429
- $helper_numbers = WYSIJA::get('numbers', 'helper');
1430
- foreach ($campaigns as &$campaign) {
1431
- // open rate, based on sent number
1432
- $campaign['rate_opened'] = $helper_numbers->calculate_percetage($campaign['number_opened'], $campaign['number_total'], 1);
1433
- // click rate, based on opened number
1434
- $campaign['rate_clicked'] = $helper_numbers->calculate_percetage($campaign['number_clicked'], $campaign['number_total'], 1);
1435
- // unsubscribe rate, based on opened number
1436
- $campaign['rate_unsub'] = $helper_numbers->calculate_percetage($campaign['number_unsub'], $campaign['number_total'], 1);
1437
- }
1438
- return $campaigns;
1439
- }
1440
-
1441
- /**
1442
- * Get the first campaign in history
1443
- */
1444
- protected function get_oldest_compaign() {
1445
- $query = '
1446
- SELECT
1447
- MIN(B.created_at) as datemin
1448
- FROM `[wysija]' . $this->modelObj->table_name . '` as A
1449
- LEFT JOIN
1450
- `[wysija]email` AS B on A.campaign_id = B.campaign_id
1451
- LEFT JOIN
1452
- `[wysija]campaign_list` as C on A.campaign_id = C.campaign_id';
1453
-
1454
- return $this->modelObj->query('get_row', $query . $this->modelObj->makeWhere());
1455
- }
1456
-
1457
- /**
1458
- * Count ALL emails of each email-status
1459
- * @todo: move to model
1460
- */
1461
- protected function count_emails_by_status() {
1462
- $query = '
1463
- SELECT
1464
- COUNT(`email_id`) AS `campaigns`,
1465
- `status`
1466
- FROM
1467
- `[wysija]email`
1468
- WHERE
1469
- `campaign_id` > 0
1470
- GROUP BY `status`';
1471
-
1472
- $countss = $this->modelObj->query('get_res', $query);
1473
- $counts = array();
1474
- $total = 0;
1475
-
1476
- foreach ($countss as $count) {
1477
- switch ($count['status']) {
1478
- case '0':
1479
- $type = 'draft';
1480
- break;
1481
- case '1':
1482
- case '3':
1483
- case '99':
1484
- $type = 'sending';
1485
- break;
1486
- case '2':
1487
- $type = 'sent';
1488
- break;
1489
- case '-1':
1490
- $type = 'paused';
1491
- break;
1492
- case '4':
1493
- $type = 'scheduled';
1494
- break;
1495
- }
1496
- $total = $total + $count['campaigns'];
1497
- $counts['status-' . $type] = $count['campaigns'];
1498
- }
1499
- return $counts;
1500
- }
1501
-
1502
- /**
1503
- * Count emails which matched the filters
1504
- */
1505
- protected function count_emails() {
1506
- $query = '
1507
- SELECT
1508
- COUNT(DISTINCT B.`email_id`) AS `campaigns`
1509
- FROM
1510
- `[wysija]' . $this->modelObj->table_name . '` AS A
1511
- LEFT JOIN
1512
- `[wysija]email` AS B ON A.`campaign_id` = B.`campaign_id`
1513
- LEFT JOIN
1514
- `[wysija]campaign_list` AS C ON A.`campaign_id` = C.`campaign_id`';
1515
- return $this->modelObj->count($query . $this->modelObj->makeWhere(), 'campaigns');
1516
- }
1517
-
1518
- /**
1519
- * Count ALL emails of each type of email
1520
- */
1521
- protected function count_emails_by_type() {
1522
- $query = '
1523
- SELECT
1524
- COUNT(`email_id`) AS `campaigns`,
1525
- `type`
1526
- FROM
1527
- `[wysija]email`
1528
- WHERE
1529
- `campaign_id` > 0
1530
- GROUP BY `type`';
1531
- $countss = $this->modelObj->query('get_res', $query, ARRAY_A);
1532
- $counts = array();
1533
- foreach ($countss as $count) {
1534
- switch ($count['type']) {
1535
- case '1':
1536
- $type = 'regular';
1537
- break;
1538
- case '2':
1539
- $type = 'autonl';
1540
- break;
1541
- }
1542
- $counts['type-' . $type] = $count['campaigns'];
1543
- }
1544
- return $counts;
1545
- }
1546
-
1547
- /**
1548
- * Get all existing lists
1549
- */
1550
- protected function get_lists() {
1551
- $model_list = WYSIJA::get('list', 'model');
1552
- $query = '
1553
- SELECT
1554
- A.`list_id`,
1555
- A.`name`,
1556
- A.`is_enabled`,
1557
- COUNT( B.`campaign_id` ) AS `users`
1558
- FROM
1559
- `[wysija]' . $model_list->table_name . '` as A
1560
- LEFT JOIN
1561
- `[wysija]campaign_list` AS B on A.`list_id` = B.`list_id`
1562
- GROUP BY A.`list_id`';
1563
- $result = $model_list->getResults($query);
1564
- $lists = array();
1565
- foreach ($result as $list_obj) {
1566
- $lists[$list_obj['list_id']] = $list_obj;
1567
- }
1568
- return $lists;
1569
- }
1570
-
1571
- function defaultDisplay() {
1572
- $this->data['base_url'] = $this->base_url . '?' . http_build_query($_REQUEST); // saved filter
1573
- $this->title = __('Newsletters', WYSIJA);
1574
- $this->viewShow = $this->action = 'main';
1575
- $this->js[] = 'wysija-admin-list';
1576
- $this->jsTrans["selecmiss"] = __('Please select a newsletter.', WYSIJA);
1577
- $this->jsTrans['suredelete'] = __('Delete this newsletter for ever?', WYSIJA);
1578
- $this->jsTrans['suredelete_bulk'] = __('Delete these newsletters for ever?', WYSIJA);
1579
- $this->jsTrans['processqueue'] = __('Sending batch of emails...', WYSIJA);
1580
- $this->jsTrans['viewnews'] = __('View newsletter', WYSIJA);
1581
- $this->jsTrans['confirmpauseedit'] = __('The newsletter will be deactivated, you will need to reactivate it once you\'re over editing it. Do you want to proceed?', WYSIJA);
1582
-
1583
-
1584
- //get the filters
1585
- if (isset($_REQUEST['search']) && $_REQUEST['search']) {
1586
- $this->filters['like'] = array();
1587
- foreach ($this->searchable as $field)
1588
- $this->filters['like'][$field] = $_REQUEST['search'];
1589
- }
1590
-
1591
- if (isset($_REQUEST['filter-list']) && $_REQUEST['filter-list']) {
1592
- $this->filters['equal'] = array('C.list_id' => $_REQUEST['filter-list']);
1593
- }
1594
-
1595
- if (isset($_REQUEST['filter-date']) && $_REQUEST['filter-date']) {
1596
- $this->filters['greater_eq'] = array('created_at' => $_REQUEST['filter-date']);
1597
- $this->filters['less_eq'] = array('created_at' => strtotime('+1 month', $_REQUEST['filter-date']));
1598
- }
1599
-
1600
- $this->filters['is'] = array('type' => 'IS NOT NULL');
1601
-
1602
-
1603
- if (isset($_REQUEST['link_filter']) && $_REQUEST['link_filter']) {
1604
- $linkfilters = explode('-', $_REQUEST['link_filter']);
1605
-
1606
- if (count($linkfilters) > 1) {
1607
- $this->_addLinkFilter($linkfilters[1], $linkfilters[0]);
1608
- } else {
1609
- $this->_addLinkFilter($_REQUEST['link_filter']);
1610
- }
1611
- }
1612
-
1613
- $this->modelObj->noCheck = true;
1614
- $this->modelObj->reset();
1615
- if ($this->filters)
1616
- $this->modelObj->setConditions($this->filters);
1617
-
1618
-
1619
- // Count emails by status and type
1620
- $emails_by_status = $this->count_emails_by_status();
1621
- $emails_by_type = $this->count_emails_by_type();
1622
- $counts = array_merge($emails_by_status, $emails_by_type);
1623
- $counts['all'] = array_sum($emails_by_status);
1624
-
1625
- // collect data
1626
- $this->data['campaigns'] = $this->get_campaigns();
1627
- $this->data['datemin'] = $this->get_oldest_compaign();
1628
- $lists = $this->get_lists(); // $lists is in use later within this scope
1629
- $this->data['lists'] = $lists;
1630
-
1631
- // for paging
1632
- $this->modelObj->countRows = $this->filters ? $this->count_emails () : $counts['all'];
1633
-
1634
-
1635
- // count queue
1636
- $email_ids = array();
1637
- foreach ($this->data['campaigns'] as $emailcamp) {
1638
- if (in_array($emailcamp['status'], array(1, 3, 99)))
1639
- $email_ids[] = $emailcamp['email_id'];
1640
- }
1641
- $model_queue = WYSIJA::get('queue', 'model');
1642
- $model_queue->setConditions(array("email_id" => $email_ids));
1643
- $model_queue->groupBy('email_id');
1644
- $queue = $model_queue->count();
1645
- if ($queue) {
1646
- $this->viewObj->queuedemails = $queue;
1647
- }
1648
-
1649
- $this->modelObj->reset();
1650
-
1651
- //make a loop from the first created to now and increment an array of months
1652
- $now = time();
1653
- $this->data['dates'] = array();
1654
-
1655
- if ((int) $this->data['datemin']['datemin'] > 1) {
1656
- setlocale(LC_TIME, 'en_US');
1657
- $formtlettres = "1 " . date('F', $this->data['datemin']['datemin']) . ' ' . date("Y", $this->data['datemin']['datemin']);
1658
- $month_start = strtotime($formtlettres);
1659
-
1660
- if ($month_start > 0) {
1661
- for ($i = $month_start; $i < $now; $i = strtotime('+1 month', $i)) {
1662
- $this->data['dates'][$i] = date_i18n('F Y', $i); //date('F Y',$i);
1663
- }
1664
- }
1665
- }
1666
-
1667
-
1668
-
1669
- $campaign_ids_sent = $campaign_ids = array();
1670
- foreach ($this->data['campaigns'] as &$campaign) {
1671
- $campaign_ids[] = $campaign['campaign_id'];
1672
- $modelEmail = WYSIJA::get('email', 'model');
1673
- $modelEmail->getParams($campaign);
1674
- if (in_array((int) $campaign['status'], array(-1, 1, 2, 3, 99)))
1675
- $campaign_ids_sent[] = $campaign['campaign_id'];
1676
- }
1677
-
1678
- // 3 - campaign_list request & count request for queue */
1679
- if ($campaign_ids) {
1680
- $modeluList = WYSIJA::get('campaign_list', 'model');
1681
- $userlists = $modeluList->get(array('list_id', 'campaign_id'), array('campaign_id' => $campaign_ids));
1682
-
1683
- if ($campaign_ids_sent) {
1684
- $modeluList = WYSIJA::get("email_user_stat", "model");
1685
- $statstotal = $modeluList->getResults("SELECT COUNT(A.user_id) as count,B.email_id FROM `[wysija]queue` as A
1686
- JOIN `[wysija]email` as B on A.email_id=B.email_id
1687
- WHERE B.campaign_id IN (" . implode(",", $campaign_ids_sent) . ") group by B.email_id");
1688
-
1689
- $senttotalgroupedby = $modeluList->getResults("SELECT COUNT(A.user_id) as count,B.campaign_id,B.email_id,B.type,B.status,A.status as statususer FROM `[wysija]" . $modeluList->table_name . "` as A
1690
- JOIN `[wysija]email` as B on A.email_id=B.email_id
1691
- WHERE B.campaign_id IN (" . implode(",", $campaign_ids_sent) . ") group by A.status,B.email_id"); //,A.status
1692
-
1693
-
1694
- $updateEmail = array();
1695
- $columnnamestatus = array(0 => "number_sent", 1 => "number_opened", 2 => "number_clicked", 3 => "number_unsub", -1 => "number_bounce");
1696
- foreach ($senttotalgroupedby as $sentbystatus) {
1697
- if ($sentbystatus['statususer'] != "-2")
1698
- $updateEmail[$sentbystatus['email_id']][$columnnamestatus[$sentbystatus['statususer']]] = $sentbystatus['count'];
1699
- if (isset($senttotal[$sentbystatus['email_id']])) {
1700
- $senttotal[$sentbystatus['email_id']]['count'] = (int) $senttotal[$sentbystatus['email_id']]['count'] + (int) $sentbystatus['count'];
1701
- } else {
1702
- unset($sentbystatus['statususer']);
1703
- $senttotal[$sentbystatus['email_id']] = $sentbystatus;
1704
- }
1705
- }
1706
-
1707
- $modelEmail = WYSIJA::get('email', 'model');
1708
-
1709
- foreach ($updateEmail as $emailid => $update) {
1710
-
1711
- foreach ($columnnamestatus as $v) {
1712
- if (!isset($update[$v]))
1713
- $update[$v] = 0;
1714
- }
1715
-
1716
- $modelEmail->update($update, array('email_id' => $emailid));
1717
- $modelEmail->reset();
1718
- }
1719
-
1720
-
1721
- /**/
1722
- $modelC = WYSIJA::get('config', 'model');
1723
- $running = false;
1724
-
1725
- $is_multisite = is_multisite();
1726
-
1727
- //$is_multisite=true;//PROD comment that line
1728
- if ($is_multisite && $modelC->getValue('sending_method') == 'network') {
1729
- $sending_emails_each = $modelC->getValue('ms_sending_emails_each');
1730
- } else {
1731
- $sending_emails_each = $modelC->getValue('sending_emails_each');
1732
- }
1733
-
1734
- if ($modelC->getValue('cron_manual')) {
1735
- $formsHelp = WYSIJA::get('forms', 'helper');
1736
- $queue_frequency = $formsHelp->eachValuesSec[$sending_emails_each];
1737
- $queue_scheduled = WYSIJA::get_cron_schedule('queue');
1738
-
1739
- $next_scheduled_queue = $queue_scheduled['next_schedule'];
1740
- $running = $queue_scheduled['running'];
1741
-
1742
- if ($running) {
1743
- $helperToolbox = WYSIJA::get('toolbox', 'helper');
1744
- $running = time() - $running;
1745
- $running = $helperToolbox->duration_string($running, true, 4);
1746
- }
1747
- } else {
1748
- $schedules = wp_get_schedules();
1749
- $queue_frequency = $schedules[wp_get_schedule('wysija_cron_queue')]['interval'];
1750
- $next_scheduled_queue = wp_next_scheduled('wysija_cron_queue');
1751
- }
1752
-
1753
-
1754
-
1755
- $status_sent_complete = array();
1756
- if (isset($senttotal) && $senttotal) {
1757
- foreach ($senttotal as $sentot) {
1758
- if ($sentot) {
1759
- $this->data['sent'][$sentot['email_id']]['total'] = $sentot['count'];
1760
- $this->data['sent'][$sentot['email_id']]['to'] = $sentot['count'];
1761
- } else {
1762
- $this->data['sent'][$sentot['email_id']]['total'] = $this->data['sent'][$sentot['email_id']]['to'] = 0;
1763
- }
1764
- $this->data['sent'][$sentot['email_id']]['status'] = $sentot['status'];
1765
- $this->data['sent'][$sentot['email_id']]['type'] = $sentot['type'];
1766
- $this->data['sent'][$sentot['email_id']]['left'] = (int) $this->data['sent'][$sentot['email_id']]['total'] - (int) $this->data['sent'][$sentot['email_id']]['to'];
1767
- }
1768
- }
1769
-
1770
- foreach ($statstotal as $sentot) {
1771
- if (!isset($this->data['sent'][$sentot['email_id']])) {
1772
- $this->data['sent'][$sentot['email_id']]['total'] = 0;
1773
- $this->data['sent'][$sentot['email_id']]['to'] = 0;
1774
- }
1775
- $this->data['sent'][$sentot['email_id']]['total'] = $this->data['sent'][$sentot['email_id']]['total'] + $sentot['count'];
1776
- $this->data['sent'][$sentot['email_id']]['left'] = (int) $this->data['sent'][$sentot['email_id']]['total'] - (int) $this->data['sent'][$sentot['email_id']]['to'];
1777
- }
1778
-
1779
- //$is_multisite=true;//PROD comment that line
1780
- if ($is_multisite && $modelC->getValue('sending_method') == 'network') {
1781
- $sending_emails_number = $modelC->getValue('ms_sending_emails_number');
1782
- } else {
1783
- $sending_emails_number = $modelC->getValue('sending_emails_number');
1784
- }
1785
-
1786
- if (isset($this->data['sent'])) {
1787
- foreach ($this->data['sent'] as $key => &$camp) {
1788
- if ($this->data['sent'][$key]['left'] > 0) {
1789
- $cronsneeded = ceil($this->data['sent'][$key]['left'] / $sending_emails_number);
1790
- $this->data['sent'][$key]['remaining_time'] = $cronsneeded * $queue_frequency;
1791
- $this->data['sent'][$key]['running_for'] = $running;
1792
- $this->data['sent'][$key]['next_batch'] = $next_scheduled_queue - time();
1793
- $this->data['sent'][$key]['remaining_time'] = $this->data['sent'][$key]['remaining_time'] - ($queue_frequency) + $this->data['sent'][$key]['next_batch'];
1794
- } else {
1795
- if ((in_array($this->data['sent'][$key]['status'], array(1, 3, 99))) && $this->data['sent'][$key]['type'] == 1)
1796
- $status_sent_complete[] = $key;
1797
- }
1798
- }
1799
- }
1800
-
1801
-
1802
- // status update to sent for the one that are sent
1803
- if (count($status_sent_complete) > 0) {
1804
- $modelEmail = WYSIJA::get('email', 'model');
1805
- $modelEmail->noCheck = true;
1806
- $modelEmail->reset();
1807
- $modelEmail->update(array('status' => 2), array('equal' => array('email_id' => $status_sent_complete)));
1808
- }
1809
- }
1810
- }
1811
-
1812
- $this->data['counts'] = array_reverse($counts);
1813
-
1814
- /* regrouping all the data in the same array */
1815
- foreach ($this->data['campaigns'] as &$campaign) {
1816
- /* default key while we don't have the data */
1817
- //TODO add data for stats about emails opened clicked etc
1818
- $campaign["emails"] = 0;
1819
- $campaign["opened"] = 0;
1820
- $campaign["clicked"] = 0;
1821
-
1822
- if ($userlists) {
1823
- foreach ($userlists as $key => $userlist) {
1824
- if ($campaign["campaign_id"] == $userlist["campaign_id"] && isset($lists[$userlist["list_id"]])) {
1825
- if (!isset($campaign["lists"]))
1826
- $campaign["lists"] = $lists[$userlist["list_id"]]["name"];
1827
- else
1828
- $campaign["lists"].=", " . $lists[$userlist["list_id"]]["name"];
1829
- }
1830
- }
1831
- }
1832
- if (isset($campaign["lists"]) && !$campaign["lists"])
1833
- unset($campaign["lists"]);
1834
-
1835
- if (((isset($campaign['params']['schedule']['isscheduled']) ||
1836
- ($campaign['type'] == 2 && isset($campaign['params']['autonl']['event']) && in_array($campaign['params']['autonl']['event'], array('new-articles'/* ,'subs-2-nl' */)))
1837
- ) && $campaign['status'] != 2 && !isset($campaign["lists"])) || ($campaign['type'] == 2 && isset($campaign['params']['autonl']['event']) && in_array($campaign['params']['autonl']['event'], array('subs-2-nl')) && $campaign['status'] != 2 && (!isset($campaign['params']['autonl']['subscribetolist']) || !isset($lists[$campaign['params']['autonl']['subscribetolist']]) ))
1838
- ) {
1839
- $campaign['classRow'] = " listmissing ";
1840
- $campaign['msgListEdit'] = '<strong>' . __('The list has been deleted.', WYSIJA) . '</strong>';
1841
- $campaign['msgSendSuspended'] = '<strong>' . __('Sending suspended.', WYSIJA) . '</strong>';
1842
- }
1843
- }
1844
-
1845
- $this->dataAutoNl();
1846
- if (!$this->data['campaigns']) {
1847
- $this->notice(__('There are no newsletters.', WYSIJA));
1848
- }
1849
- }
1850
-
1851
- function setviewStatsfilter() {
1852
- /* get the filters */
1853
- $this->searchable = array("email", "firstname", "lastname");
1854
- $this->filters = array();
1855
- if (isset($_REQUEST['search']) && $_REQUEST['search']) {
1856
- $this->filters["like"] = array();
1857
- foreach ($this->searchable as $field)
1858
- $this->filters["like"][$field] = $_REQUEST['search'];
1859
- }
1860
- $this->tableQuery = 'email_user_stat';
1861
- $this->statusemail = 'B.status as umstatus';
1862
- if (isset($_REQUEST['link_filter']) && $_REQUEST['link_filter']) {
1863
- switch ($_REQUEST['link_filter']) {
1864
- case 'inqueue':
1865
- $this->tableQuery = 'queue';
1866
- $this->statusemail = '-2 as umstatus';
1867
- break;
1868
- case 'sent':
1869
- $this->filters['equal'] = array('B.status' => 0);
1870
- break;
1871
- case 'bounced':
1872
- $this->filters['equal'] = array('B.status' => -1);
1873
- break;
1874
- case 'opened':
1875
- $this->filters['equal'] = array('B.status' => 1);
1876
- break;
1877
- case 'clicked':
1878
- $this->filters['equal'] = array('B.status' => 2);
1879
- break;
1880
- case 'unsubscribe':
1881
- $this->filters['equal'] = array('B.status' => 3);
1882
- break;
1883
- case 'notsent':
1884
- $this->filters['equal'] = array('B.status' => -2);
1885
- break;
1886
- }
1887
- }
1888
- // filter by url id
1889
- if (isset($_REQUEST['url_id']) && (int) $_REQUEST['url_id'] > 0) {
1890
- $this->tableQuery = 'email_user_url';
1891
- $this->filters['equal'] = array('B.url_id' => (int) $_REQUEST['url_id']);
1892
- $this->statusemail = '2 as umstatus'; //by default, when filter by url_id, all subscribers had clicked
1893
- }
1894
- }
1895
-
1896
- function viewstats() {
1897
- $this->js[] = 'wysija-admin-list';
1898
- $this->js[] = 'wysija-charts';
1899
- $this->viewShow = 'viewstats';
1900
-
1901
- $this->modelObj = WYSIJA::get("email", "model");
1902
- $this->modelObj->limitON = false;
1903
-
1904
- $email_object = $this->modelObj->getOne(false, array("email_id" => $_REQUEST['id']));
1905
- $this->viewObj->model = $this->modelObj;
1906
- $this->viewObj->namecampaign = $email_object['subject'];
1907
- $this->viewObj->title = sprintf(__('Stats : %1$s', WYSIJA), $email_object['subject']);
1908
-
1909
- $modelObjCamp = WYSIJA::get("campaign", "model");
1910
- $limit_pp = false;
1911
- if (isset($modelObjCamp->limit_pp))
1912
- $limit_pp = $modelObjCamp->limit_pp;
1913
- $modelObjCamp->limitON = false;
1914
- $campaign = $modelObjCamp->getOne(false, array("campaign_id" => $email_object['campaign_id']));
1915
-
1916
-
1917
- $this->setviewStatsfilter();
1918
-
1919
- $this->modelObj->reset();
1920
- $this->modelObj->noCheck = true;
1921
-
1922
- /* 0 - counting request */
1923
- $queryCmmonStart = 'SELECT count(distinct B.user_id) as users FROM `[wysija]user` as A';
1924
- $queryCmmonStart.=' LEFT JOIN `[wysija]' . $this->tableQuery . '` as B on A.user_id=B.user_id';
1925
-
1926
- /* all the counts query */
1927
- $query = "SELECT count(user_id) as users, status FROM `[wysija]email_user_stat` as A
1928
- WHERE A.email_id=" . $email_object['email_id'] . " GROUP BY status";
1929
- $countss = $this->modelObj->query("get_res", $query, ARRAY_A);
1930
-
1931
- /* we also count what is in the queue */
1932
- $query = "SELECT count(user_id) as users FROM `[wysija]queue` as A
1933
- WHERE A.email_id=" . $email_object['email_id'];
1934
- $countss[-2]['status'] = -3;
1935
- $countss[-2]['users'] = $this->modelObj->count($query, 'users');
1936
-
1937
- $counts = array();
1938
- $truetotal = $total = 0;
1939
-
1940
- foreach ($countss as $count) {
1941
- switch ($count['status']) {
1942
- case "-3":
1943
- $type = 'inqueue';
1944
- break;
1945
- case "-2":
1946
- $type = 'notsent';
1947
- break;
1948
- case "-1":
1949
- $type = 'bounced';
1950
- break;
1951
- case "0":
1952
- $type = 'sent';
1953
- break;
1954
- case "1":
1955
- $type = 'opened';
1956
- break;
1957
- case "2":
1958
- $type = 'clicked';
1959
- break;
1960
- case "3":
1961
- $type = 'unsubscribe';
1962
- break;
1963
- }
1964
- if ($count['status'] != "-2")
1965
- $total = $total + $count['users'];
1966
- $truetotal = $truetotal + $count['users'];
1967
- $counts[$type] = $count['users'];
1968
- }
1969
-
1970
- $counts['allsent'] = $total;
1971
- $counts['all'] = $truetotal;
1972
-
1973
- $this->modelObj->reset();
1974
- $this->filters['equal']["B.email_id"] = $email_object['email_id'];
1975
-
1976
- $this->modelObj->noCheck = true;
1977
- if ($this->filters)
1978
- $this->modelObj->setConditions($this->filters);
1979
-
1980
- //$this->modelObj->setConditions(array("equal"=>array("B.email_id"=>$emailObj['email_id'])));
1981
-
1982
- /* 1 - subscriber request */
1983
- $query = 'SELECT A.user_id, A.firstname, A.lastname,A.status as ustatus,' . $this->statusemail . ' , A.email, B.* FROM `[wysija]user` as A';
1984
- $query.=' LEFT JOIN `[wysija]' . $this->tableQuery . '` as B on A.user_id=B.user_id';
1985
- $queryFinal = $this->modelObj->makeWhere();
1986
-
1987
- /* without filter we already have the total number of subscribers */
1988
- if ($this->filters)
1989
- $this->modelObj->countRows = $this->modelObj->count($queryCmmonStart . $queryFinal, 'users');
1990
- else
1991
- $this->modelObj->countRows = $counts['all'];
1992
-
1993
- $orderby = " ORDER BY ";
1994
- /**
1995
- * Until now, we have
1996
- * - 3 possible values of $this->tableQuery (queue, email_user_url, email_user_stat), set by $this->setviewStatsfilter()
1997
- * - 2 possible values of $_REQUEST['orderby']
1998
- * => 3x2 = 6 cases
1999
- */
2000
- if (isset($_REQUEST['orderby'])) {
2001
- switch ($this->tableQuery) {
2002
- case 'email_user_url':
2003
- case 'email_user_stat':
2004
- $orderby .= 'B.' . $_REQUEST['orderby'] . " " . $_REQUEST['ordert'];
2005
- break;
2006
-
2007
- case 'queue':
2008
- default:
2009
- $orderby .= 'A.user_id DESC';
2010
- break;
2011
- }
2012
- } else {
2013
- switch ($this->tableQuery) {
2014
- case 'email_user_url':
2015
- $orderby .= 'B.clicked_at DESC, B.number_clicked DESC'; // by default, sort by last clicked and biggest hit
2016
- break;
2017
-
2018
- case 'email_user_stat':
2019
- $orderby .= 'B.opened_at DESC, B.status DESC'; // by default, sort by last open and its staus value
2020
- break;
2021
-
2022
- case 'queue':
2023
- default:
2024
- $orderby .= 'A.user_id DESC';
2025
- break;
2026
- }
2027
- }
2028
- $this->data['tableQuery'] = $this->tableQuery;
2029
- $this->modelObj->limitON = true;
2030
-
2031
- $subscribers = array();
2032
- $hook_params = array(
2033
- 'email_id' => $email_object['email_id'],
2034
- 'url_id' => isset($_REQUEST['url_id']) && $_REQUEST['url_id'] ? $_REQUEST['url_id'] : false,
2035
- 'subscribers' => &$subscribers
2036
- );
2037
- $this->data['subscribers'] = $this->modelObj->getResults($query . $queryFinal . " GROUP BY A.user_id" . $orderby . $this->modelObj->setLimit(0, (int)$limit_pp));
2038
- $this->modelObj->reset();
2039
-
2040
- /* make the data object for the listing view */
2041
- $modelList = WYSIJA::get("list", "model");
2042
-
2043
- /* 2 - list request */
2044
- $query = "SELECT A.list_id, A.name,A.is_enabled, count( B.user_id ) AS users FROM `[wysija]" . $modelList->table_name . "` as A";
2045
- $query.=" LEFT JOIN `[wysija]user_list` as B on A.list_id = B.list_id";
2046
- $query.=" GROUP BY A.list_id";
2047
- $listsDB = $modelList->getResults($query);
2048
-
2049
- $lists = array();
2050
- foreach ($listsDB as $listobj) {
2051
- $lists[$listobj["list_id"]] = $listobj;
2052
- }
2053
-
2054
- $listsDB = null;
2055
-
2056
- $user_ids = array();
2057
- foreach ($this->data['subscribers'] as $subscriber) {
2058
- $user_ids[] = $subscriber['user_id'];
2059
- }
2060
-
2061
- /* 3 - user_list request */
2062
- if ($user_ids) {
2063
- $modeluList = WYSIJA::get("user_list", "model");
2064
- $userlists = $modeluList->get(array("list_id", "user_id"), array("user_id" => $user_ids));
2065
- }
2066
-
2067
-
2068
- $this->data['lists'] = $lists;
2069
- $this->data['counts'] = array_reverse($counts);
2070
-
2071
- /* regrouping all the data in the same array */
2072
- foreach ($this->data['subscribers'] as $keysus => $subscriber) {
2073
- /* default key while we don't have the data */
2074
- //TODO add data for stats about emails opened clicked etc
2075
- $this->data['subscribers'][$keysus]["emails"] = 0;
2076
- $this->data['subscribers'][$keysus]["opened"] = 0;
2077
- $this->data['subscribers'][$keysus]["clicked"] = 0;
2078
-
2079
- if ($userlists) {
2080
- foreach ($userlists as $key => $userlist) {
2081
- if ($subscriber["user_id"] == $userlist["user_id"] && isset($lists[$userlist["list_id"]])) {
2082
- if (!isset($this->data['subscribers'][$keysus]["lists"]))
2083
- $this->data['subscribers'][$keysus]["lists"] = $lists[$userlist["list_id"]]["name"];
2084
- else
2085
- $this->data['subscribers'][$keysus]["lists"].=", " . $lists[$userlist["list_id"]]["name"];
2086
- }
2087
- }
2088
- }
2089
- }
2090
-
2091
- $this->data['email'] = $email_object;
2092
-
2093
- if (!$this->data['subscribers']) {
2094
- $this->notice(__("Your request can't retrieve any subscribers. Change your filters!", WYSIJA));
2095
- }
2096
-
2097
- // execute hooks
2098
- $hook_params = array(
2099
- 'email_id' => $_REQUEST['id'],
2100
- 'email_object' => $email_object,
2101
- 'url_id' => !empty($_REQUEST['url_id']) ? (int)$_REQUEST['url_id'] : null
2102
- );
2103
-
2104
- $this->data['hooks']['hook_newsletter_top'] = apply_filters('hook_newsletter_top', WYSIJA_module::execute_hook('hook_newsletter_top', $hook_params), $hook_params);
2105
- $this->data['hooks']['hook_newsletter_bottom'] = apply_filters('hook_newsletter_bottom', WYSIJA_module::execute_hook('hook_newsletter_bottom', $hook_params), $hook_params);
2106
- }
2107
-
2108
- function getListSubscriberQry($selectcolumns) {
2109
- $this->modelObj = WYSIJA::get("email", "model");
2110
- $this->emailObj = $this->modelObj->getOne(false, array('email_id' => $_REQUEST['id']));
2111
-
2112
- /* use the filter if there is */
2113
- $this->setviewStatsfilter();
2114
-
2115
- if ($selectcolumns == "B.user_id") {
2116
- //unset($this->filters["like"]);
2117
- }
2118
-
2119
- $this->filters['equal']["B.email_id"] = $this->emailObj['email_id'];
2120
- $this->modelObj->noCheck = true;
2121
- if ($this->filters)
2122
- $this->modelObj->setConditions($this->filters);
2123
-
2124
- /* select insert all the subscribers from that campaign into user_list */
2125
- if ($selectcolumns == "B.user_id") {
2126
- $query = "SELECT $selectcolumns FROM `[wysija]" . $this->tableQuery . "` as B";
2127
- $query.=$this->modelObj->makeWhere();
2128
- } else {
2129
- $query = "SELECT $selectcolumns FROM `[wysija]user` as A";
2130
- $query.=" LEFT JOIN `[wysija]" . $this->tableQuery . "` as B on A.user_id=B.user_id";
2131
- $query.=$this->modelObj->makeWhere();
2132
- }
2133
-
2134
- return $query;
2135
- }
2136
-
2137
- function createnewlist() {
2138
- /* get the email subject */
2139
- $emailModel = WYSIJA::get('email', 'model');
2140
- $email = $emailModel->getOne(array('subject'), array('email_id' => $_REQUEST['id']));
2141
-
2142
- $this->modelObj->reset();
2143
-
2144
- /* set the name of the new list */
2145
- $prefix = "";
2146
- if (isset($_REQUEST['link_filter']))
2147
- $prefix = ' (' . $this->viewObj->getTransStatusEmail($_REQUEST['link_filter']) . ')';
2148
- $listname = sprintf(__('Segment of %1$s', WYSIJA), $email['subject'] . $prefix);
2149
-
2150
- /* insert new list */
2151
- $modelL = WYSIJA::get('list', 'model');
2152
- $listid = $modelL->insert(array('is_enabled' => 1, 'name' => $listname, 'description' => __('List created based on a newsletter segment.', WYSIJA)));
2153
-
2154
- /* get list of subscribers filtered or not */
2155
- $query = $this->getListSubscriberQry($listid . ', A.user_id, ' . time() . ', 0');
2156
-
2157
- $query2 = 'INSERT INTO `[wysija]user_list` (`list_id`,`user_id`,`sub_date`,`unsub_date`) ' . $query;
2158
-
2159
- $this->modelObj->query($query2);
2160
-
2161
- $this->notice(sprintf(__('A new list "%1$s" has been created out of this segment.', WYSIJA), $listname));
2162
- $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2163
- }
2164
-
2165
- function unsubscribeall() {
2166
- // Update user_list, set unsubdate and sub_date
2167
- $query = $this->getListSubscriberQry('B.user_id');
2168
  $query1 = "
2169
- UPDATE `[wysija]user_list`
2170
- SET
2171
  `unsub_date` = ".time().",
2172
  `sub_date` = 0
2173
- WHERE
2174
  `user_id` IN ($query)
2175
  AND `list_id` NOT IN (SELECT `list_id` FROM `[wysija]list` WHERE `is_enabled` < 1)
2176
  ";
2177
- $this->modelObj->query($query1);
2178
-
2179
- // unsubscribe from user where select from email_user_stat
2180
- $query2 = "UPDATE `[wysija]user` SET `status`=-1 WHERE `user_id` IN ($query)";
2181
- $this->modelObj->query($query2);
2182
-
2183
- $this->notice(__('The segment has been unsubscribed from all the lists.', WYSIJA));
2184
- $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2185
- }
2186
-
2187
- function sendconfirmation() {
2188
- //delete from user_lists where select from email_user_stat
2189
- $query = $this->getListSubscriberQry('B.user_id ');
2190
-
2191
- $user_ids = $this->modelObj->query('get_res', $query);
2192
-
2193
- $uids = array();
2194
- foreach ($user_ids as $data) {
2195
- $uids[] = $data['user_id'];
2196
- }
2197
-
2198
- $helperUser = WYSIJA::get('user', 'helper');
2199
- $helperUser->sendConfirmationEmail($uids);
2200
- $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2201
- }
2202
-
2203
- function removequeue() {
2204
- /* delete from queue where select from email_user_stat */
2205
- $query = $this->getListSubscriberQry('B.user_id');
2206
- $query2 = "DELETE FROM `[wysija]queue` where user_id IN ($query) AND email_id=" . $this->emailObj['email_id'];
2207
- $this->modelObj->query($query2);
2208
-
2209
- $this->notice(__('The segment has been removed from the queue of this newsletter.', WYSIJA));
2210
- $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2211
- }
2212
-
2213
- function export() {
2214
- /* select from email_user_stat left join user */
2215
- $query = $this->getListSubscriberQry('B.user_id');
2216
- $result = $this->modelObj->query('get_res', $query);
2217
- $user_ids = array();
2218
- foreach ($result as $user)
2219
- $user_ids[] = $user['user_id'];
2220
-
2221
- $fileHelp = WYSIJA::get('file', 'helper');
2222
- $tempfilename = $fileHelp->temp(implode(',', $user_ids), 'export_userids', '.txt');
2223
-
2224
- //$this->redirect("admin.php?page=wysija_campaigns&action=viewstats&id=".$_REQUEST['id']."&user_ids=".serialize($result));
2225
- $this->redirect('admin.php?page=wysija_subscribers&action=exportcampaign&camp_id=' . $_REQUEST['id'] . '&file_name=' . base64_encode($tempfilename['path']));
2226
- }
2227
-
2228
- function unsubscribelist($data) {
2229
-
2230
- $modelL = WYSIJA::get('list', 'model');
2231
- $list = $modelL->getOne(false, array('list_id' => $data['listid']));
2232
- if ($list['is_enabled']) {
2233
- /* delete from user_lists where select from email_user_stat */
2234
- $query = $this->getListSubscriberQry("B.user_id");
2235
- $query2 = "DELETE FROM `[wysija]user_list` where user_id IN ($query) and list_id=" . $data['listid'];
2236
- $this->modelObj->query($query2);
2237
-
2238
- $this->notice(sprintf(__('The segment has been unsubscribed from the list "%1$s".', WYSIJA), $list['name']));
2239
- } else {
2240
- $this->notice(sprintf(__('The segment cannot be unsubscribed from an [IMPORT] list.', WYSIJA), $list['name']));
2241
- }
2242
-
2243
- $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2244
- }
2245
-
2246
- function articles() {
2247
- $this->iframeTabs = array('articles' => __("Post Selection", WYSIJA));
2248
-
2249
- // required js files
2250
- $this->js[] = 'wysija-admin-ajax';
2251
- $this->js[] = 'wysija-base-script-64';
2252
- $this->js[] = 'wysija-scriptaculous';
2253
- $this->js[] = 'wysija-colorpicker';
2254
-
2255
- // translations
2256
- $this->jsTrans['show_advanced'] = __('Display and insert options', WYSIJA);
2257
- $this->jsTrans['hide_advanced'] = __('Back to selection', WYSIJA);
2258
- $this->jsTrans['loading_results'] = __('Loading results...', WYSIJA);
2259
- $this->jsTrans['inserting_selection'] = __('Inserting selected articles...', WYSIJA);
2260
- $this->jsTrans['post_selected'] = __('selected', WYSIJA);
2261
-
2262
- // default tab in popup (this needs to be removed at some point)
2263
- $_GET['tab'] = 'articles';
2264
-
2265
- // get parameters
2266
- $params = array(
2267
- 'category_ids' => null,
2268
- 'category' => null,
2269
- 'title_tag' => 'h2',
2270
- 'title_alignment' => 'left',
2271
- 'title_position' => 'inside',
2272
- 'image_alignment' => 'alternate',
2273
- 'image_width' => 325,
2274
- 'post_content' => 'excerpt',
2275
- 'readmore' => __('Read more.', WYSIJA),
2276
- 'show_divider' => 'yes',
2277
- 'post_limit' => 5,
2278
- 'post_type' => 'post',
2279
- 'author_show' => 'no',
2280
- 'author_label' => __('Author:', WYSIJA),
2281
- 'category_show' => 'no',
2282
- 'category_label' => __('Categories:', WYSIJA),
2283
- 'nopost_message' => __('Latest content already sent.', WYSIJA),
2284
- 'bgcolor1' => null,
2285
- 'bgcolor2' => null,
2286
- 'sort_by' => 'newest'
2287
- );
2288
-
2289
- // check if GET parameters are specified
2290
- foreach($params as $key => $value) {
2291
- if(array_key_exists($key, $_GET)) {
2292
- switch($key) {
2293
- case 'autopost_count':
2294
- $params[$key] = (int)$_GET[$key];
2295
- break;
2296
- case 'readmore':
2297
- case 'nopost_message':
2298
- $params[$key] = base64_decode($_GET[$key]);
2299
- break;
2300
- default:
2301
- $params[$key] = $_GET[$key];
2302
- }
2303
- }
2304
- }
2305
-
2306
- $model_config = WYSIJA::get('config', 'model');
2307
- $insert_post_parameters = $model_config->getValue('insert_post_parameters');
2308
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
2309
-
2310
- if($insert_post_parameters !== false) {
2311
- // there are user params
2312
- $params = $helper_wj_engine->decodeParameters(array_merge($params, $insert_post_parameters));
2313
- }
2314
-
2315
- // get autopost count
2316
- $this->data['autopost_count'] = (array_key_exists('autopost_count', $_GET)) ? (int) $_GET['autopost_count'] : 0;
2317
-
2318
- // get autopost type (single or multiple)
2319
- $this->data['autopost_type'] = (array_key_exists('autopost_type', $_GET)) ? $_GET['autopost_type'] : 'multiple';
2320
-
2321
- // if only one group of post can be added, change default alignment to left
2322
- if($this->data['autopost_type'] === 'single' && $params['image_alignment'] === 'alternate') {
2323
- $params['image_alignment'] = 'left';
2324
- }
2325
-
2326
- // get post categories (even when there's no post)
2327
- $post_categories = get_categories(array('hide_empty' => 0));
2328
- $categories = array();
2329
- foreach ($post_categories as $category) {
2330
- $categories[] = array('id' => $category->cat_ID, 'name' => $category->name);
2331
- }
2332
- $this->data['categories'] = $categories;
2333
-
2334
- // max number of posts
2335
- $this->data['post_limits'] = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 50);
2336
-
2337
- $this->data['params'] = $params;
2338
-
2339
- return $this->popupContent();
2340
- }
2341
-
2342
- function themeupload() {
2343
- $helperNumbers = WYSIJA::get('numbers', 'helper');
2344
- $bytes = $helperNumbers->get_max_file_upload();
2345
-
2346
- if (isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH'] > $bytes['maxbytes']) {
2347
- if (isset($_FILES['my-theme']['name']) && $_FILES['my-theme']['name']) {
2348
- $filename = $_FILES['my-theme']['name'];
2349
- } else {
2350
- $filename = "";
2351
- }
2352
-
2353
- $this->error(sprintf(__('Upload error, file %1$s is too large! (MAX:%2$s)', WYSIJA), $filename, $bytes['maxmegas']), true);
2354
- $this->redirect('admin.php?page=wysija_campaigns&action=themes');
2355
-
2356
- return false;
2357
- }
2358
-
2359
-
2360
- $ZipfileResult = trim(file_get_contents($_FILES['my-theme']['tmp_name']));
2361
-
2362
- $themesHelp = WYSIJA::get('themes', 'helper');
2363
- $result = $themesHelp->installTheme($_FILES['my-theme']['tmp_name'], true);
2364
- $this->redirect('admin.php?page=wysija_campaigns&action=themes&reload=1');
2365
-
2366
- return true;
2367
- }
2368
-
2369
- function themes() {
2370
- $this->iframeTabs = array('themes' => __('Install Themes', WYSIJA));
2371
- $this->js[] = 'wysija-admin-ajax';
2372
- $this->js[] = 'wysija-base-script-64';
2373
- $this->jsTrans['viewinfos'] = __('Details & PSD', WYSIJA);
2374
- $this->jsTrans['viewback'] = __('<< Back', WYSIJA);
2375
- $this->jsTrans['install'] = __('Download', WYSIJA);
2376
- $this->jsTrans['reinstall'] = __('Reinstall', WYSIJA);
2377
- $this->jsTrans['premiumonly'] = __('Premium', WYSIJA);
2378
-
2379
- $model_config = WYSIJA::get('config', 'model');
2380
- //change the translation of the button when it's premium
2381
- if ($model_config->getValue('premium_key'))
2382
- $this->jsTrans['ispremium'] = 1;
2383
- else
2384
- $this->jsTrans['ispremium'] = 0;
2385
-
2386
- $this->jsTrans['premiumfiles'] = __('Photoshop file available as part of [link]Premium features[/link].', WYSIJA);
2387
-
2388
- $helper_licence = WYSIJA::get('licence', 'helper');
2389
- $url_checkout = $helper_licence->get_url_checkout('themes');
2390
- $this->jsTrans['premiumfiles'] = str_replace(array('[link]', '[/link]'), array('<a href="' . $url_checkout . '" target="_blank" >', '</a>'), $this->jsTrans['premiumfiles']);
2391
-
2392
- $this->jsTrans['showallthemes'] = __('Show all themes', WYSIJA);
2393
- $this->jsTrans['totalvotes'] = __('(%1$s votes)', WYSIJA);
2394
- $this->jsTrans['voterecorded'] = __("Your vote has been recorded.", WYSIJA);
2395
- $this->jsTrans['votenotrecorded'] = __("Your vote could not be recorded.", WYSIJA);
2396
- $this->jsTrans['reinstallwarning'] = __('Watch out! If you reinstall this theme all the files which are in the folder:/wp-content/uploads/wysija/themes/%1$s will be overwritten. Are you sure you want to reinstall?', WYSIJA);
2397
- $this->jsTrans['errorconnecting'] = __("We were unable to contact the API, the site may be down. Please try again later.", WYSIJA);
2398
-
2399
- $this->jsTrans['viewallthemes'] = __('View all themes by %1$s', WYSIJA);
2400
- $this->jsTrans['downloadpsd'] = __("Download original Photoshop file", WYSIJA);
2401
- $this->jsTrans['downloadzip'] = __("Download as .zip", WYSIJA);
2402
- $this->jsTrans['viewauthorsite'] = __("View author's website", WYSIJA);
2403
- $this->jsTrans['stars'] = __('Average rating: %1$s', WYSIJA);
2404
- $this->jsTrans['starsyr'] = __('My rating: %1$s', WYSIJA);
2405
- $this->jsTrans['downloads'] = __('Downloads: %1$s', WYSIJA);
2406
- $this->jsTrans['tags'] = __('Tags: %1$s', WYSIJA);
2407
- $this->jsTrans['lastupdated'] = __('Last updated: %1$s', WYSIJA);
2408
- $this->jsTrans['includes'] = __('Includes: %1$s', WYSIJA);
2409
-
2410
- $helper_themes = WYSIJA::get('themes', 'helper');
2411
-
2412
- $this->jsTrans['installedthemes'] = $helper_themes->getInstalled();
2413
-
2414
- $url = admin_url('admin.php');
2415
- $helper_toolbox = WYSIJA::get("toolbox", "helper");
2416
- $domain_name = $helper_toolbox->_make_domain_name($url);
2417
- $this->jsTrans['domainname'] = $domain_name;
2418
-
2419
- $_GET['tab'] = 'themes';
2420
-
2421
- return $this->popupContent();
2422
- }
2423
-
2424
- function bookmarks() {
2425
- $this->iframeTabs = array('bookmarks' => __('Bookmarks Selection', WYSIJA));
2426
- $this->js[] = 'wysija-admin-ajax';
2427
-
2428
- $_GET['tab'] = 'bookmarks';
2429
-
2430
- $networks = array(
2431
- 'facebook' => array(
2432
- 'label' => 'Facebook',
2433
- 'url' => null,
2434
- 'placeholder' => 'https://www.facebook.com/mailpoetplugin'
2435
- ),
2436
- 'twitter' => array(
2437
- 'label' => 'Twitter',
2438
- 'url' => null,
2439
- 'placeholder' => 'http://www.twitter.com/mail_poet'
2440
- ),
2441
- 'google' => array(
2442
- 'label' => 'Google+',
2443
- 'url' => null,
2444
- 'placeholder' => null
2445
- ),
2446
- 'linkedin' => array(
2447
- 'label' => 'LinkedIn',
2448
- 'url' => null,
2449
- 'placeholder' => null
2450
- )
2451
- );
2452
-
2453
- // get networks' url from config
2454
- $model_config = WYSIJA::get('config', 'model');
2455
- $urls = $model_config->getValue('social_bookmarks');
2456
-
2457
- // set url from config for each network if specified
2458
- foreach ($networks as $network => $values) {
2459
- if (isset($urls[$network]) and strlen(trim($urls[$network])) > 0) {
2460
- $networks[$network]['url'] = $urls[$network];
2461
- }
2462
- }
2463
-
2464
- $this->data['networks'] = $networks;
2465
- $this->data['size'] = 'medium';
2466
- $this->data['theme'] = isset($_REQUEST['theme']) ? $_REQUEST['theme'] : 'default';
2467
-
2468
- return $this->popupContent();
2469
- }
2470
-
2471
- function dividers() {
2472
- $this->iframeTabs = array('dividers' => __("Dividers Selection", WYSIJA));
2473
- $this->js[] = 'wysija-admin-ajax';
2474
- $this->js[] = 'wysija-base-script-64';
2475
-
2476
- $_GET['tab'] = 'dividers';
2477
-
2478
- $model_email = WYSIJA::get('email', 'model');
2479
- $this->data['email'] = $email = $model_email->getOne(false, array('email_id' => $_REQUEST['emailId']));
2480
-
2481
- // get dividers
2482
- $helper_dividers = WYSIJA::get('dividers', 'helper');
2483
- $dividers = $helper_dividers->getAll();
2484
-
2485
- // get theme divider if it's not the default theme
2486
- if (isset($email['params']['theme'])) {
2487
- $helper_themes = WYSIJA::get('themes', 'helper');
2488
- $themeDivider = $helper_themes->getDivider($email['params']['theme']);
2489
- if ($themeDivider !== NULL) {
2490
- array_unshift($dividers, $themeDivider);
2491
- }
2492
- }
2493
-
2494
- // get selected divider
2495
- if (isset($email['params']['divider'])) {
2496
- $selected_divider = $email['params']['divider'];
2497
- } else {
2498
- $helper_dividers = WYSIJA::get('dividers', 'helper');
2499
- $selected_divider = $helper_dividers->getDefault();
2500
- }
2501
-
2502
- // set selected divider in first position
2503
- array_unshift($dividers, $selected_divider);
2504
-
2505
- // remove selected divider if present in the list
2506
- for ($i = 1; $i < count($dividers); $i++) {
2507
- if ($dividers[$i]['src'] === $selected_divider['src']) {
2508
- unset($dividers[$i]);
2509
- break;
2510
- }
2511
- }
2512
-
2513
- $this->data['selected'] = $selected_divider;
2514
- $this->data['dividers'] = $dividers;
2515
- return $this->popupContent();
2516
- }
2517
-
2518
- function autopost() {
2519
- $this->iframeTabs = array('autopost' => __("Add / Edit group of posts", WYSIJA));
2520
- $this->js[] = 'wysija-admin-ajax';
2521
- $this->js[] = 'wysija-base64';
2522
- $this->js[] = 'wysija-scriptaculous';
2523
- $this->js[] = 'wysija-colorpicker';
2524
- $this->js[] = 'mailpoet-select2';
2525
-
2526
- // translations
2527
- $this->jsTrans['show_advanced'] = __('Show display options', WYSIJA);
2528
- $this->jsTrans['hide_advanced'] = __('Hide display options', WYSIJA);
2529
-
2530
- $_GET['tab'] = 'autopost';
2531
-
2532
- // get parameters
2533
- $params = array(
2534
- 'category_ids' => null,
2535
- 'category_condition' => 'include',
2536
- 'title_tag' => 'h2',
2537
- 'title_alignment' => 'left',
2538
- 'title_position' => 'inside',
2539
- 'image_alignment' => 'alternate',
2540
- 'image_width' => 325,
2541
- 'post_content' => 'excerpt',
2542
- 'readmore' => __('Read more.', WYSIJA),
2543
- 'show_divider' => 'yes',
2544
- 'post_limit' => 5,
2545
- 'post_type' => 'post',
2546
- 'author_show' => 'no',
2547
- 'author_label' => __('Author:', WYSIJA),
2548
- 'category_show' => 'no',
2549
- 'category_label' => __('Categories:', WYSIJA),
2550
- 'nopost_message' => __('Latest content already sent.', WYSIJA),
2551
- 'bgcolor1' => null,
2552
- 'bgcolor2' => null,
2553
- 'sort_by' => 'newest'
2554
- );
2555
-
2556
- // backwards compatibility since we replaced the 'cpt' parameter by 'post_type' in 2.6
2557
- if(isset($_GET['cpt']) && strlen(trim($_GET['cpt'])) > 0) {
2558
- $params['post_type'] = trim($_GET['cpt']);
2559
- }
2560
-
2561
- // check if GET parameters are specified
2562
- foreach ($params as $key => $value) {
2563
- if (array_key_exists($key, $_GET)) {
2564
- switch ($key) {
2565
- case 'autopost_count':
2566
- $params[$key] = (int)$_GET[$key];
2567
- break;
2568
- case 'author_label':
2569
- case 'category_label':
2570
- case 'readmore':
2571
- case 'nopost_message':
2572
- $params[$key] = base64_decode($_GET[$key]);
2573
- break;
2574
- default:
2575
- $params[$key] = trim($_GET[$key]);
2576
- }
2577
- }
2578
- }
2579
-
2580
- // get autopost count
2581
- $this->data['autopost_count'] = (array_key_exists('autopost_count', $_GET)) ? (int) $_GET['autopost_count'] : 0;
2582
-
2583
- // get autopost type (single or multiple)
2584
- $this->data['autopost_type'] = (array_key_exists('autopost_type', $_GET)) ? $_GET['autopost_type'] : 'multiple';
2585
-
2586
- // if only one group of post can be added, change default alignment to left
2587
- if ($this->data['autopost_type'] === 'single') {
2588
- if ($params['image_alignment'] === 'alternate')
2589
- $params['image_alignment'] = 'left';
2590
- }
2591
-
2592
- // we use that now, because categories from a post are different than categories from a CPT
2593
- // $helper_wp_tools = WYSIJA::get('wp_tools','helper');
2594
- // $this->data['categories'] = $helper_wp_tools->get_categories();
2595
-
2596
- // max number of posts
2597
- $this->data['post_limits'] = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 50);
2598
-
2599
- $this->data['params'] = $params;
2600
-
2601
- return $this->popupContent();
2602
- }
2603
-
2604
- function image_data() {
2605
- $this->data['url'] = (isset($_GET['url']) && $_GET['url'] !== '') ? trim(urldecode($_GET['url'])) : null;
2606
- $this->data['alt'] = (isset($_GET['alt'])) ? trim(urldecode($_GET['alt'])) : '';
2607
-
2608
- $this->iframeTabs = array('image_data' => __("Image Parameters", WYSIJA));
2609
- $_GET['tab'] = 'image_data';
2610
- return $this->popupContent();
2611
- }
2612
-
2613
- function medias() {
2614
- $this->popupContent();
2615
- }
2616
-
2617
- function special_wysija_browse() {
2618
- $this->_wysija_subaction();
2619
- $this->jsTrans['deleteimg'] = __('Delete image for all newsletters?', WYSIJA);
2620
- return wp_iframe(array($this->viewObj, 'popup_wysija_browse'), array());
2621
- }
2622
-
2623
- function special_wordp_browse() {
2624
- $this->_wysija_subaction();
2625
- $this->jsTrans['deleteimg'] = __('This image might be in an article. Delete anyway?', WYSIJA);
2626
- return wp_iframe(array($this->viewObj, 'popup_wp_browse'), array());
2627
- }
2628
-
2629
- function _wysija_subaction() {
2630
-
2631
- if (isset($_REQUEST['subaction'])) {
2632
- if ($_REQUEST['subaction'] === 'delete') {
2633
- if (isset($_REQUEST['imgid']) && (int) $_REQUEST['imgid'] > 0) {
2634
- /* delete the image with id imgid */
2635
- $res = wp_delete_attachment((int) $_REQUEST['imgid'], true);
2636
- if ($res) {
2637
- $this->notice(__('Image has been deleted.', WYSIJA));
2638
- }
2639
- }
2640
- }
2641
- }
2642
- return true;
2643
- }
2644
-
2645
- function special_new_wordp_upload() {
2646
-
2647
- //wp_enqueue_script('plupload-all');
2648
- wp_enqueue_script('wysija-plupload-handlers', WYSIJA_URL . 'js/jquery/pluploadHandler.js', array('plupload-all', 'jquery'));
2649
- $uploader_l10n = array(
2650
- 'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
2651
- 'file_exceeds_size_limit' => __('%s exceeds the maximum upload size for this site.'),
2652
- 'zero_byte_file' => __('This file is empty. Please try another.'),
2653
- 'invalid_filetype' => __('This file type is not allowed. Please try another.'),
2654
- 'not_an_image' => __('This file is not an image. Please try another.'),
2655
- 'image_memory_exceeded' => __('Memory exceeded. Please try another smaller file.'),
2656
- 'image_dimensions_exceeded' => __('This is larger than the maximum size. Please try another.'),
2657
- 'default_error' => __('An error occurred in the upload. Please try again later.'),
2658
- 'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
2659
- 'upload_limit_exceeded' => __('You may only upload 1 file.'),
2660
- 'http_error' => __('HTTP error.'),
2661
- 'upload_failed' => __('Upload failed.'),
2662
- 'big_upload_failed' => __('Please try uploading this file with the %1$sbrowser uploader%2$s.'),
2663
- 'big_upload_queued' => __('%s exceeds the maximum upload size for the multi-file uploader when used in your browser.'),
2664
- 'io_error' => __('IO error.'),
2665
- 'security_error' => __('Security error.'),
2666
- 'file_cancelled' => __('File canceled.'),
2667
- 'upload_stopped' => __('Upload stopped.'),
2668
- 'dismiss' => __('Dismiss'),
2669
- 'crunching' => __('Crunching&hellip;'),
2670
- 'deleted' => __('moved to the trash.'),
2671
- 'error_uploading' => __('&#8220;%s&#8221; has failed to upload.')
2672
- );
2673
-
2674
- wp_localize_script('wysija-plupload-handlers', 'pluploadL10n', $uploader_l10n);
2675
-
2676
- wp_enqueue_script('image-edit');
2677
- wp_enqueue_script('set-post-thumbnail');
2678
- wp_enqueue_style('imgareaselect');
2679
- wp_enqueue_script('media-gallery');
2680
-
2681
- /* wp_register_style('myplupload', '/adjust-this-url/myplupload.css');
2682
- wp_enqueue_style('myplupload'); */
2683
-
2684
-
2685
- $errors = array();
2686
- return wp_iframe(array($this->viewObj, 'popup_new_wp_upload'), $errors);
2687
- }
2688
-
2689
- function special_wordp_upload() {
2690
-
2691
- wp_enqueue_script('swfupload-all');
2692
- wp_enqueue_script('swfupload-handlers');
2693
- wp_enqueue_script('wysija-upload-handlers', WYSIJA_URL . "js/jquery/uploadHandlers.js");
2694
- wp_enqueue_script('image-edit');
2695
- wp_enqueue_script('set-post-thumbnail');
2696
- wp_enqueue_style('imgareaselect');
2697
-
2698
- $errors = array();
2699
- $id = 0;
2700
- if (isset($_GET['flash']))
2701
- $_GET['flash'] = 1;
2702
- if (isset($_POST['html-upload']) && !empty($_FILES)) {
2703
- // Upload File button was clicked
2704
- $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
2705
- unset($_FILES);
2706
- if (is_wp_error($id)) {
2707
- $errors['upload_error'] = $id;
2708
- $id = false;
2709
- }
2710
- }
2711
-
2712
- if (!empty($_POST['insertonlybutton'])) {
2713
- $href = $_POST['insertonly']['href'];
2714
- if (!empty($href) && !strpos($href, '://'))
2715
- $href = "http://$href";
2716
-
2717
- $title = esc_attr($_POST['insertonly']['title']);
2718
- if (empty($title))
2719
- $title = basename($href);
2720
- if (!empty($title) && !empty($href))
2721
- $html = "<a href='" . esc_url($href) . "' >$title</a>";
2722
- $html = apply_filters('file_send_to_editor_url', $html, esc_url_raw($href), $title);
2723
- return media_send_to_editor($html);
2724
- }
2725
-
2726
- if (!empty($_POST)) {
2727
- $return = media_upload_form_handler();
2728
-
2729
- if (is_string($return))
2730
- return $return;
2731
- if (is_array($return))
2732
- $errors = $return;
2733
- }
2734
-
2735
- if (isset($_POST['save'])) {
2736
- $errors['upload_notice'] = __('Saved.', WYSIJA);
2737
- return media_upload_gallery();
2738
- }
2739
-
2740
-
2741
- return wp_iframe(array($this->viewObj, 'popup_wp_upload'), $errors);
2742
- }
2743
-
2744
- function _checkEmailExists($emailId) {
2745
- $result = false;
2746
- $modelEmail = WYSIJA::get('email', 'model');
2747
-
2748
- if ($modelEmail->exists(array('email_id' => $emailId)))
2749
- $result = true;
2750
-
2751
- if (!$result) {
2752
- $this->error(__("The newsletter doesn't exist.", WYSIJA), 1);
2753
- $this->redirect('admin.php?page=wysija_campaigns');
2754
- }
2755
- else
2756
- return true;
2757
- }
2758
 
2759
  }
5
 
6
  class WYSIJA_control_back_campaigns extends WYSIJA_control_back {
7
 
8
+ var $model = 'campaign';
9
+ var $view = 'campaigns';
10
+ var $list_columns = array('campaign_id', 'name', 'description');
11
+ var $searchable = array('name', 'subject');
12
+ var $filters = array();
13
+ var $base_url = 'admin.php';
14
+
15
+ function WYSIJA_control_back_campaigns() {
16
+
17
+ }
18
+
19
+ function installation(){
20
+
21
+ $start_time = time();
22
+ $check_max_execution_time = get_option( 'mpoet_check_max_execution_time' );
23
+ $ini_max_execution_time = ini_get( 'max_execution_time' );
24
+
25
+ // 1 - we haven't run the max execution time extension test yet, let's do it
26
+ // this test should be run in the background, it may take more than 5 minutes to validate
27
+ if( empty( $check_max_execution_time ) ){
28
+
29
+ // we set the max_execution_time to infinite
30
+ @ini_set( 'max_execution_time' , 0 );
31
+ // we keep running the script even if the user abort his request
32
+ @ignore_user_abort( true );
33
+
34
+ $reset_max_execution_time = ini_get( 'max_execution_time' );
35
+
36
+ // FAILURE some servers the "max execution time" returned is Array we make sure our value is numeric
37
+ if( !is_numeric( $ini_max_execution_time ) ){
38
+ WYSIJA::update_option( 'mpoet_check_max_execution_time' , $ini_max_execution_time-1 );
39
+ return;
40
+ }
41
+
42
+ // FAILURE this server doesn't allow us to set the max_execution_time
43
+ if( $reset_max_execution_time == $ini_max_execution_time ){
44
+ WYSIJA::update_option( 'mpoet_check_max_execution_time' , $ini_max_execution_time-1 );
45
+ return;
46
+ }
47
+
48
+ // we set a FAILURE value to our flag so we know if the process crash while executing
49
+ WYSIJA::update_option( 'mpoet_check_max_execution_time' , $ini_max_execution_time );
50
+
51
+ // the common default timeout value is 300, so if by default the timelimit is 0 (which might have been set by another application)
52
+ // we default it to 300 known as a common default value and we run the extension test
53
+ if( $ini_max_execution_time == 0 ) $ini_max_execution_time = 300;
54
+
55
+ // we run asleep script during the initial max execution time to a larger value
56
+ $total_time_to_run_script = $ini_max_execution_time + 20;
57
+ $sleeping_intervals = 5;
58
+ $duration_so_far = 0;
59
+
60
+ // we sleep until the extended total timeout value is reached or it breaks before but we have the value we need
61
+ while($total_time_to_run_script >0){
62
+ $total_time_to_run_script = $total_time_to_run_script - $sleeping_intervals;
63
+ sleep( $sleeping_intervals );
64
+
65
+ $duration_so_far = time() - $start_time;
66
+ WYSIJA::update_option( 'mpoet_check_max_execution_time' , $duration_so_far );
67
+ }
68
+
69
+ // SUCCESS the scripts didn't die we set our flag in the db so that we know the test is a success
70
+ WYSIJA::update_option( 'mpoet_check_max_execution_time' , $duration_so_far );
71
+
72
+ }else{
73
+ // 2 - the max execution time extension test has been run, this is the results we get
74
+ if( $check_max_execution_time > $ini_max_execution_time ){
75
+ echo 'max_execution_time('.$ini_max_execution_time.') can be extended('.$check_max_execution_time.')';
76
+ }else{
77
+ echo 'max_execution_time('.$ini_max_execution_time.') cannot be extended( max value : '.$check_max_execution_time.')';
78
+ }
79
+ }
80
+ exit;
81
+ }
82
+
83
+ /**
84
+ * Welcome page first time install
85
+ * @return boolean
86
+ */
87
+ function welcome_new() {
88
+ $this->title = $this->viewObj->title = __('Welcome Page!', WYSIJA);
89
+ $this->jsTrans['instalwjp'] = __('Installing MailPoet Newsletter Premium plugin', WYSIJA);
90
+ $helper_readme = WYSIJA::get('readme', 'helper');
91
+ $helper_readme->scan();
92
+ $this->data = array();
93
+ $this->data['abouttext'] = __('A Brand New MailPoet. Let the Fun Begin.', WYSIJA);
94
+
95
+ $model_config = WYSIJA::get('config', 'model');
96
+ $is_multisite = is_multisite();
97
+ $is_network_admin = WYSIJA::current_user_can('manage_network');
98
+ if ($is_multisite && $is_network_admin) {
99
+ $model_config->save(array('ms_wysija_whats_new' => WYSIJA::get_version()));
100
+ } else {
101
+ $model_config->save(array('wysija_whats_new' => WYSIJA::get_version()));
102
+ }
103
+
104
+ //add a new language code with a new video
105
+ $video_language=array();
106
+ //$video_language['en_EN'] = '<iframe width="853" height="480" src="http://www.youtube.com/embed/pYzaHDTg5Jk" frameborder="0" allowfullscreen></iframe>';
107
+ $video_language['en_EN'] = '<iframe src="//player.vimeo.com/video/81479899" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
108
+ //$video_language['fr_FR'] = '<iframe width="853" height="480" src="http://www.youtube.com/embed/W5EyW5w7aWQ" frameborder="0" allowfullscreen></iframe>';
109
+ // $video_language['sv_SE']='<iframe width="853" height="480" src="http://www.youtube.com/embed/O8_t_dekx74" frameborder="0" allowfullscreen></iframe>';
110
+ //$video_language['ar']='<iframe width="853" height="480" src="http://www.youtube.com/embed/cyDHlX_qgOo" frameborder="0" allowfullscreen></iframe>';
111
+
112
+ $wp_lang = get_locale();
113
+ if (!empty($wp_lang) && isset($video_language[$wp_lang])) {
114
+ $welcome_video_link = $video_language[$wp_lang];
115
+ } else {
116
+ $welcome_video_link = $video_language['en_EN'];
117
+ }
118
+
119
+ $this->data['sections'][] = array(
120
+ 'title' => __('Hey, we\'re curious! How did you find out about us?', WYSIJA) . '<span id="poll_result"></span>',
121
+ 'format' => 'normal',
122
+ 'paragraphs' => array(
123
+ '<ul class="welcome_poll">
124
+ <li>
125
+ <input type="radio" id="how_did_you_find_us_1" value="repository" name="how_did_you_find_us">
126
+ <label value="lab1" for="how_did_you_find_us_1">' . __('WordPress.org plugin repository', WYSIJA) . '</label>
127
+ </li>
128
+ <li>
129
+ <input type="radio" id="how_did_you_find_us_2" value="search_engine" name="how_did_you_find_us">
130
+ <label value="lab2" for="how_did_you_find_us_2">' . __('Google or other search engine', WYSIJA) . '</label>
131
+ </li>
132
+ <li>
133
+ <input type="radio" id="how_did_you_find_us_3" value="friend" name="how_did_you_find_us">
134
+ <label value="lab3" for="how_did_you_find_us_3">' . __('Friend recommendation', WYSIJA) . '</label>
135
+ </li>
136
+ <li>
137
+ <input type="radio" id="how_did_you_find_us_4" value="url" name="how_did_you_find_us">
138
+ <label value="lab4" for="how_did_you_find_us_4">' . __('Blog post, online review, forum:', WYSIJA) . '</label>
139
+ <input type="text" id="how_did_you_find_us_4_url" name="how_did_you_find_us_url" placeholder="' . __('Please enter the address where you\'ve found out about us', WYSIJA) . '">
140
+ </li>
141
+ </ul>'
142
+ )
143
+ );
144
+
145
+ $this->data['sections'][]=array(
146
+ 'title'=>__('First Time? See it in Action',WYSIJA),
147
+ 'format'=>'normal',
148
+ 'paragraphs'=>array(
149
+ __('You can start by watching this video by one of our users.',WYSIJA),
150
+ $welcome_video_link
151
+ )
152
+ );
153
+
154
+ // Check if user is already sharing data, and hide the share link.
155
+ if (!$model_config->getValue('analytics')) {
156
+ $share_section = array(
157
+ 'title' => __('Share your data', WYSIJA),
158
+ 'content' => str_replace(
159
+ array('[link]', '[/link]', '[ajaxlink]', '[/ajaxlink]'), array('<a title="Anonymous Data" target="_blank" href="http://support.mailpoet.com/knowledgebase/share-your-data/?utm_source=wpadmin&utm_campaign=welcome_page">', '</a>', '<a id="share_analytics" href="javascript:;">', '</a>'), __("We know too little about our users. We're looking for [link]anonymous data[/link] to build a better plugin. [ajaxlink]Yes, count me in![/ajaxlink]", WYSIJA))
160
+ );
161
+ } else {
162
+ $share_section = array(
163
+ 'title' => __('Share your data', WYSIJA),
164
+ 'content' => str_replace(
165
+ array('[link]', '[/link]'), array('<a title="Anonymous Data" target="_blank" href="http://support.mailpoet.com/knowledgebase/share-your-data/?utm_source=wpadmin&utm_campaign=welcome_page">', '</a>', '<a id="share_analytics" href="javascript:;">', '</a>'), __("We know too little about our users. We're looking for [link]anonymous data[/link] to build a better plugin. Thanks, you're already sharing!", WYSIJA))
166
+ );
167
+ }
168
+
169
+ $this->data['sections'][] = array(
170
+ 'title' => __('What You Can Do', WYSIJA),
171
+ 'cols' => array(
172
+ array(
173
+ 'title' => __('5 minute newbie guide', WYSIJA),
174
+ 'content' => __('Your MailPoet comes with an example newsletter. You\'ll see it when you close this welcome page. Edit it to start playing with it.', WYSIJA)
175
+ ),
176
+ $share_section,
177
+ array(
178
+ 'title' => __('Help yourself. Or let us help you.', WYSIJA),
179
+ 'content' => str_replace(
180
+ array('[link]', '[/link]'), array('<a href="http://support.mailpoet.com/" target="_blank" title="On our blog!">', '</a>'), __('We got documentation and a ticket system on [link]support.mailpoet.com[/link]. We answer within 24h.', WYSIJA))
181
+ )
182
+ ),
183
+ 'format' => 'three-col',
184
+ );
185
+
186
+ $this->viewObj->skip_header = true;
187
+
188
+ return true;
189
+ }
190
+
191
+ /**
192
+ * Welcome page for updaters
193
+ * @return boolean
194
+ */
195
+ function whats_new() {
196
+
197
+ $this->title = $this->viewObj->title = __('What\'s new?', WYSIJA);
198
+ $this->jsTrans['instalwjp'] = __('Installing MailPoet Newsletter Premium plugin', WYSIJA);
199
+ wp_enqueue_style('wysija-admin-css-premium', WYSIJA_URL.'css/admin-premium.css',array(),WYSIJA::get_version());
200
+
201
+ $this->viewObj->skip_header = true;
202
+ return true;
203
+ }
204
+
205
+
206
+
207
+ /* START prem check hook */
208
+
209
+ // when curl or any php remote function not available mailpoet.com returns lcheck to that function
210
+ function licok() {
211
+ parent::WYSIJA_control_back();
212
+ $dt = get_option('wysijey');
213
+
214
+ if (isset($_REQUEST['xtz']) && $dt === $_REQUEST['xtz']) {
215
+ $dataconf = array('premium_key' => base64_encode(get_option('home') . time()), 'premium_val' => time());
216
+ $this->notice(__('Premium version is valid for your site.', WYSIJA));
217
+ } else {
218
+ $dataconf = array('premium_key' => '', 'premium_val' => '');
219
+
220
+ $helper_licence = WYSIJA::get('licence', 'helper');
221
+ $url_premium = 'http://www.mailpoet.com/checkout/?wysijadomain=' . $dt . '&nc=1&utm_source=wpadmin&utm_campaign=error_licence_activation';
222
+
223
+ $this->error(str_replace(array('[link]', '[/link]'), array('<a href="' . $url_premium . '" target="_blank">', '</a>'), __('Premium licence does not exist for your site. Purchase it [link]here[/link].', WYSIJA)), 1);
224
+ }
225
+ WYSIJA::update_option('wysicheck', false);
226
+ $modelConf = WYSIJA::get('config', 'model');
227
+ $modelConf->save($dataconf);
228
+
229
+ $this->redirect('admin.php?page=wysija_config#tab-premium');
230
+ }
231
+
232
+ /* END prem check hook */
233
+
234
+ function validateLic() {
235
+ $helpLic = WYSIJA::get('licence', 'helper');
236
+ $res = $helpLic->check();
237
+
238
+ $this->redirect();
239
+ }
240
+
241
+ /**
242
+ * this function is triggered when sending manually the emails with the "Don't wait and send right now" button
243
+ * @param type $dataPost
244
+ */
245
+ function manual_send($dataPost = false) {
246
+ $modelQ = WYSIJA::get('queue', 'model');
247
+ $config = WYSIJA::get('config', 'model');
248
+ if ((int) $config->getValue('total_subscribers') < 2000) {
249
+ if ($modelQ->count() > 0) {
250
+ $helperQ = WYSIJA::get('queue', 'helper');
251
+ $emailid = false;
252
+ if ($_REQUEST['emailid']) {
253
+ $emailid = $_REQUEST['emailid'];
254
+ }
255
+ $helperQ->process($emailid);
256
+ } else {
257
+ echo '<strong style="font-family: Arial; font-weight: bold; font-size: 12px;">' . __('Queue is empty!', WYSIJA) . '</strong>';
258
+ }
259
+ exit;
260
+ } else {
261
+ //deprecated
262
+ do_action('wysija_send_test_editor');
263
+
264
+ do_action('wysija_manual_send');
265
+ }
266
+
267
+ exit;
268
+ }
269
+
270
+ /**
271
+ * test the bounce handling maybe this should move somewhere else like config controller
272
+ * @return boolean
273
+ */
274
+ function test_bounce() {
275
+ // bounce handling
276
+ $helper_bounce = WYSIJA::get('bounce', 'helper');
277
+
278
+ // in a multisite case we process first the bounce recording into the bounce table
279
+ if (is_multisite()) {
280
+ $helper_bounce->record_bounce_ms();
281
+
282
+ // then we take actions from what has been returned by the bounce
283
+ $helper_bounce->process_bounce_ms();
284
+ } else {
285
+ $helper_bounce->process_bounce();
286
+ }
287
+ exit;
288
+ }
289
+
290
+ function add($dataPost = false) {
291
+ $this->title = sprintf(__('Step %1$s', WYSIJA), 1);
292
+ $this->js[] = 'wysija-validator';
293
+
294
+ $this->js[] = 'wysija-edit-autonl';
295
+ $this->js['admin-campaigns-edit'] = 'admin-campaigns-edit';
296
+ $this->jsTrans['descauto'] = str_replace(array('[newsletter:number]', '[newsletter:total]', '[newsletter:post_title]'), array('<b>[newsletter:number]</b>', '<b>[newsletter:total]</b>', '<b>[newsletter:post_title]</b>'), __('Insert [newsletter:total] to show number of posts, [newsletter:post_title] to show the latest post\'s title & [newsletter:number] to display the issue number.', WYSIJA));
297
+ $this->jsTrans['descstandard'] = __('The first thing your subscribers see. Be creative and increase your open rate!', WYSIJA);
298
+ $this->immediateWarning();
299
+ $this->viewObj->title = __('First step: main details', WYSIJA);
300
+ $this->viewShow = 'add';
301
+ $this->data = array();
302
+ $this->data['campaign'] = array('name' => '', 'description' => '');
303
+ $modelConfig = WYSIJA::get('config', 'model');
304
+ $this->data['email'] = array('subject' => '', 'from_email' => $modelConfig->getValue('from_email'), 'from_name' => $modelConfig->getValue('from_name'));
305
+ $this->data['lists'] = $this->__getLists(false, true, true);
306
+
307
+ $this->dataAutoNl();
308
+ $this->jsLoc['admin-campaigns-edit']['autofields'] = $this->data['autonl']['fields'];
309
+ }
310
+
311
+ /**
312
+ * get the fields and fields value necessary when dealing with automatic newsletters
313
+ */
314
+ function dataAutoNl() {
315
+ $dataFrequencyNoImmediate = $dataFrequency = array('daily' => __('once a day at...', WYSIJA),
316
+ 'weekly' => __('weekly on...', WYSIJA),
317
+ 'monthly' => __('monthly on the...', WYSIJA),
318
+ 'monthlyevery' => __('monthly every...', WYSIJA),
319
+ 'immediate' => __('immediately.', WYSIJA));
320
+
321
+ unset($dataFrequencyNoImmediate['immediate']);
322
+
323
+ $times = array();
324
+ $time = strtotime('00:00:00');
325
+ $toolboxH = WYSIJA::get('toolbox', 'helper');
326
+ $times['00:00:00'] = $toolboxH->localtime($time);
327
+
328
+ for ($i = 1; $i < 24; $i++) {
329
+ $time = strtotime('+ 1hour', $time);
330
+ $key = date('H:i:s', $time);
331
+ $times[$key] = $toolboxH->localtime($time);
332
+ }
333
+
334
+ $daysvalues = $toolboxH->getday();
335
+
336
+ $numberweeks = $toolboxH->getweeksnumber();
337
+ $daynumbers = $toolboxH->getdaynumber();
338
+
339
+
340
+ $dataLists = array();
341
+
342
+ foreach ($this->data['lists'] as $datal) {
343
+ if ($datal['is_enabled'])
344
+ $dataLists[$datal['list_id']] = $datal['name'];
345
+ }
346
+
347
+ // Get all available roles
348
+ $wptoolsH = WYSIJA::get('wp_tools', 'helper');
349
+ $roles = $wptoolsH->wp_get_all_roles();
350
+ $available_roles = array('any' => __('in any WordPress role', WYSIJA));
351
+ foreach ($roles as $role => $name) {
352
+ $available_roles[$role] = $name;
353
+ }
354
+
355
+ $this->data['autonl']['fields'] = array(
356
+ 'event' => array(
357
+ 'values' => array(
358
+ 'new-articles' => __('When there\'s new content...', WYSIJA),
359
+ 'subs-2-nl' => __('When someone subscribes to the list...', WYSIJA),
360
+ 'new-user' => __('When a new WordPress user is added to your site...', WYSIJA),
361
+ ),
362
+ 'valueshow' => array(
363
+ 'new-articles' => array('when-article'),
364
+ 'subs-2-nl' => array('subscribetolist', 'numberafter', 'numberofwhat', 'unique_send'),
365
+ 'new-user' => array('roles', 'numberafter', 'numberofwhat', 'unique_send'),
366
+ ),
367
+ 'style' => 'width:300px;'
368
+ ),
369
+ 'when-article' => array(
370
+ 'values' => $dataFrequency,
371
+ 'valueshow' => array(
372
+ 'daily' => array('time'),
373
+ 'weekly' => array('dayname', 'time'),
374
+ 'monthly' => array('daynumber', 'time'),
375
+ 'monthlyevery' => array('dayevery', 'dayname', 'time'),
376
+ )
377
+ ),
378
+ 'subscribetolist' => array(
379
+ 'values' => $dataLists,
380
+ 'style' => 'width:300px;'
381
+ ),
382
+ 'roles' => array(
383
+ 'values' => $available_roles
384
+ ),
385
+ 'numberafter' => array(
386
+ 'type' => 'input',
387
+ 'style' => 'width:35px;',
388
+ 'class' => 'validate[required,custom[integer],min[1]]',
389
+ ),
390
+ 'numberofwhat' => array(
391
+ 'values' => array(
392
+ 'immediate' => __('immediately.', WYSIJA),
393
+ 'hours' => __('hour(s) after.', WYSIJA),
394
+ 'days' => __('day(s) after.', WYSIJA),
395
+ 'weeks' => __('week(s) after.', WYSIJA)
396
+ ),
397
+ 'valuesunit' => array(
398
+ 'immediate' => __('immediately', WYSIJA),
399
+ 'hours' => __('hour(s)', WYSIJA),
400
+ 'days' => __('day(s)', WYSIJA),
401
+ 'weeks' => __('week(s)', WYSIJA)
402
+ ),
403
+ ),
404
+ 'dayevery' => array(
405
+ 'values' => $numberweeks,
406
+ ),
407
+ 'dayname' => array(
408
+ 'values' => $daysvalues,
409
+ ),
410
+ 'daynumber' => array(
411
+ 'values' => $daynumbers,
412
+ ),
413
+ 'time' => array(
414
+ 'values' => $times,
415
+ ),
416
+ /* 'unique_send'=>array(
417
+ 'label_before'=>__('Send this email only once.',WYSIJA),
418
+ 'type'=>'checkbox'
419
+ ), */
420
+ );
421
+ $helpersEvent = WYSIJA::get('autonews', 'helper');
422
+ $extraEvents = $helpersEvent->events();
423
+
424
+ /* if there are plugin to add autonewsletter event they are adding their customized field over here */
425
+ if ($extraEvents) {
426
+ foreach ($extraEvents as $k => $v) {
427
+
428
+ $this->data['autonl']['fields']['event']['values'][$k] = $v['title'];
429
+ foreach ($v['fields'] as $fieldCKEY => $fieldCVAL) {
430
+ if (isset($this->data['autonl']['fields'][$fieldCKEY]))
431
+ continue;
432
+ }
433
+ $this->data['autonl']['fields']['event']['valueshow'][$k] = array_keys($v['fields']);
434
+ }
435
+ }
436
+ }
437
+
438
+ function __getLists($enabled = true, $count = false, $notgetalllistid = false) {
439
+ $modelList = WYSIJA::get('list', 'model');
440
+ //get lists which have users and are enabled */
441
+ if ($enabled)
442
+ $enabledstrg = ' is_enabled>0 and';
443
+ else
444
+ $enabledstrg = '';
445
+
446
+ $extrasql = '';
447
+ if (!$notgetalllistid)
448
+ $extrasql = 'WHERE list_id in (SELECT distinct(list_id) from [wysija]user_list )';
449
+ $query = 'SELECT * FROM [wysija]list ' . $extrasql;
450
+ $listres = $modelList->query('get_res', $query);
451
+
452
+ if ($count) {
453
+ $mConfig = WYSIJA::get('config', 'model');
454
+ $condit = '>=';
455
+ if ($mConfig->getValue('confirm_dbleoptin'))
456
+ $condit = '>';
457
+ $qry1 = "SELECT count(distinct A.user_id) as nbsub,A.list_id FROM `[wysija]user_list` as A LEFT JOIN `[wysija]user` as B on A.user_id=B.user_id WHERE B.status $condit 0 and A.sub_date>0 and A.unsub_date=0 GROUP BY list_id";
458
+
459
+ $total = $modelList->getResults($qry1);
460
+
461
+ foreach ($total as $tot) {
462
+ foreach ($listres as $key => $res) {
463
+ if ($tot['list_id'] == $res['list_id'])
464
+ $listres[$key]['count'] = $tot['nbsub'];
465
+ }
466
+ }
467
+ }
468
+ foreach ($listres as $key => $res) {
469
+ if (!isset($res['count']))
470
+ $listres[$key]['count'] = 0;
471
+ }
472
+ return $listres;
473
+ }
474
+
475
+ function edit($dataPost = false) {
476
+ if (!$this->_checkEmailExists($_REQUEST['id']))
477
+ return;
478
+ $this->add();
479
+
480
+ $modelEmail = WYSIJA::get('email', 'model');
481
+
482
+ $this->data['email'] = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
483
+
484
+ if ($this->data['email']['status'] > 0) {
485
+ $this->redirect();
486
+ }
487
+ $this->title = sprintf(__('Step %1$s', WYSIJA), 1) . ' | ' . $this->data['email']['subject'];
488
+ $modelCamp = WYSIJA::get('campaign', 'model');
489
+ $this->data['campaign'] = $modelCamp->getOne(false, array('campaign_id' => $this->data['email']['campaign_id']));
490
+
491
+ $modelCL = WYSIJA::get('campaign_list', 'model');
492
+ $this->data['campaign_list'] = $modelCL->get(false, array('campaign_id' => $this->data['email']['campaign_id']));
493
+ }
494
+
495
+ function editTemplate() {
496
+ // make sure the editor content is not cached
497
+ header('Cache-Control: no-cache, max-age=0, must-revalidate, no-store'); // HTTP/1.1
498
+ header('Expires: Fri, 9 Mar 1984 00:00:00 GMT');
499
+
500
+ if (!$this->_checkEmailExists($_REQUEST['id']))
501
+ return;
502
+ $this->viewShow = 'editTemplate';
503
+
504
+ wp_enqueue_style('thickbox');
505
+
506
+ $wjEngine = WYSIJA::get('wj_engine', 'helper');
507
+ /* WJ editor translations */
508
+ $this->jsTrans = array_merge($this->jsTrans, $wjEngine->getTranslations(), $wjEngine->getApplicationData());
509
+
510
+ $this->jsTrans['savingnl'] = __('Saving newsletter...', WYSIJA);
511
+ $this->jsTrans['errorsavingnl'] = __('Error Saving newsletter...', WYSIJA);
512
+ $this->jsTrans['savednl'] = __('Newsletter has been saved.', WYSIJA);
513
+ $this->jsTrans['previewemail'] = __('Sending preview...', WYSIJA);
514
+ $this->jsTrans['spamtestresult'] = __('Spam test results', WYSIJA);
515
+
516
+ /* WJ editor JS */
517
+ $this->js[] = 'wysija-editor';
518
+ $this->js[] = 'wysija-admin-ajax-proto';
519
+ $this->js[] = 'wysija-admin-ajax';
520
+ $this->js[] = 'wysija-base-script-64';
521
+ $this->js[] = 'media-upload';
522
+ $this->js['admin-campaigns-editDetails'] = 'admin-campaigns-editDetails';
523
+ $modelEmail = WYSIJA::get('email', 'model');
524
+ $this->data = array();
525
+ $this->data['email'] = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
526
+
527
+ $this->checkIsEditable();
528
+
529
+ $this->viewObj->title = sprintf(__('Second step: "%1$s"', WYSIJA), $this->data['email']['subject']);
530
+ $this->title = sprintf(__('Step %1$s', WYSIJA), 2) . " | " . $this->data['email']['subject'];
531
+
532
+ // check if html source is enabled in the config (this will add the "html source" button in tinymce)
533
+ $model_config = WYSIJA::get('config', 'model');
534
+ $this->jsTrans['html_source_enabled'] = (int) $model_config->getValue('html_source');
535
+ }
536
+
537
+ function checkIsEditable() {
538
+ if (
539
+ !($this->data['email'] == 2 || isset($this->data['email']['params']['schedule']['isscheduled'])) && $this->data['email']['status'] > 0
540
+ ) {
541
+ $this->redirect();
542
+ }
543
+ }
544
+
545
+ function pause() {
546
+ /* pause the campaign entry */
547
+ if (isset($_REQUEST['id']) && $_REQUEST['id']) {
548
+ $modelEmail = WYSIJA::get('email', 'model');
549
+ $myemail = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
550
+ $modelEmail->reset();
551
+ $modelEmail->columns['modified_at']['autoup'] = 1;
552
+ $modelEmail->update(array('status' => -1), array('email_id' => $_REQUEST['id']));
553
+
554
+ if ($myemail['type'] == 2) {
555
+ return $this->redirect('admin.php?page=wysija_campaigns&id=' . $myemail['email_id'] . '&action=edit');
556
+ } else {
557
+ $this->notice(__('Sending is now paused.', WYSIJA));
558
+ }
559
+ }
560
+
561
+ $this->redirect();
562
+ }
563
+
564
+ function resume() {
565
+ /* pause the campaign entry */
566
+ if (isset($_REQUEST['id']) && $_REQUEST['id']) {
567
+ $modelEmail = WYSIJA::get('email', 'model');
568
+ $modelEmail->columns['modified_at']['autoup'] = 1;
569
+ $modelEmail->update(array('status' => 99), array('email_id' => $_REQUEST['id']));
570
+ $this->notice(__('Sending has resumed.', WYSIJA));
571
+ }
572
+
573
+ $this->redirect();
574
+ }
575
+
576
+ function duplicate() {
577
+
578
+ /* 1 - copy the campaign entry */
579
+
580
+ $model = WYSIJA::get('campaign', 'model');
581
+ $query = 'INSERT INTO `[wysija]campaign` (`name`,`description`)
582
+ SELECT concat("' . stripslashes(__('Copy of ', WYSIJA)) . '",`name`),`description` FROM [wysija]campaign
583
+ WHERE campaign_id=' . (int) $_REQUEST['id'];
584
+ $campaignid = $model->query($query);
585
+
586
+ /* 2 - copy the email entry */
587
+ $query = 'INSERT INTO `[wysija]email` (`campaign_id`,`subject`,`body`,`type`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,`status`,`created_at`,`modified_at`)
588
+ SELECT ' . $campaignid . ', concat("' . stripslashes(__('Copy of ', WYSIJA)) . '",`subject`),`body`,`type`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,0,' . time() . ',' . time() . ' FROM [wysija]email
589
+ WHERE email_id=' . (int) $_REQUEST['email_id'];
590
+ $emailid = $model->query($query);
591
+
592
+ //let's reset the count of total childs for auto newsletter
593
+ $mEmail = WYSIJA::get('email', 'model');
594
+ $emailData = $mEmail->getOne(false, array('email_id' => $emailid));
595
+
596
+ if ($emailData['type'] == 2) {
597
+ $paramsReseted = $emailData['params'];
598
+ if (isset($paramsReseted['autonl']['total_child']))
599
+ $paramsReseted['autonl']['total_child'] = 0;
600
+ if (isset($paramsReseted['autonl']['nextSend']))
601
+ $paramsReseted['autonl']['nextSend'] = 0;
602
+ if (isset($paramsReseted['autonl']['firstSend']))
603
+ unset($paramsReseted['autonl']['firstSend']);
604
+ if (isset($paramsReseted['autonl']['lastSend']))
605
+ unset($paramsReseted['autonl']['lastSend']);
606
+ if (isset($paramsReseted['autonl']['articles']['ids']))
607
+ unset($paramsReseted['autonl']['articles']['ids']);
608
+
609
+
610
+ $mEmail->update(array('params' => $paramsReseted), array('email_id' => $emailid));
611
+ }
612
+
613
+ /* 3 - copy the campaign_list entry */
614
+ $query = "INSERT INTO `[wysija]campaign_list` (`campaign_id`,`list_id`,`filter`)
615
+ SELECT $campaignid,`list_id`,`filter` FROM [wysija]campaign_list
616
+ WHERE campaign_id=" . (int) $_REQUEST['id'];
617
+ $model->query($query);
618
+
619
+ $this->notice(__('The newsletter has been duplicated.', WYSIJA));
620
+
621
+ $this->redirect('admin.php?page=wysija_campaigns&id=' . $emailid . '&action=edit');
622
+ }
623
+
624
+ function duplicateEmail() {
625
+ if (!$this->_checkEmailExists($_REQUEST['id']))
626
+ return;
627
+
628
+ $model = WYSIJA::get('campaign', 'model');
629
+ /* 2 - copy the email entry */
630
+ $query = 'INSERT INTO `[wysija]email` (`campaign_id`,`subject`,`body`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,`status`,`created_at`,`modified_at`)
631
+ SELECT `campaign_id`, concat("' . stripslashes(__("Copy of ", WYSIJA)) . '",`subject`),`body`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,0,' . time() . ',' . time() . ' FROM [wysija]email
632
+ WHERE email_id=' . (int) $_REQUEST['id'];
633
+ $emailid = $model->query($query);
634
+
635
+ $this->notice(__('The newsletter has been duplicated.', WYSIJA));
636
+
637
+ $this->redirect('admin.php?page=wysija_campaigns&id=' . $emailid . '&action=edit');
638
+ }
639
+
640
+ function immediateWarning() {
641
+ $model_config = WYSIJA::get('config', 'model');
642
+ $is_multisite = is_multisite();
643
+
644
+ //$is_multisite=true;//PROD comment that line
645
+ if ($is_multisite && $model_config->getValue('sending_method') == 'network') {
646
+ $sending_emails_each = $model_config->getValue('ms_sending_emails_each');
647
+ $number = $model_config->getValue('ms_sending_emails_number');
648
+ } else {
649
+ $sending_emails_each = $model_config->getValue('sending_emails_each');
650
+ $number = $model_config->getValue('sending_emails_number');
651
+ }
652
+
653
+ $formsHelp = WYSIJA::get('forms', 'helper');
654
+
655
+ $timespan = $formsHelp->eachValuesSec[$sending_emails_each];
656
+ $tb = WYSIJA::get('toolbox', 'helper');
657
+
658
+ $this->immediatewarning = str_replace(
659
+ array('[link]', '[/link]', '[settings]'), array('<a href="#">', '</a>', sprintf(__('%1$s emails every %2$s', WYSIJA), $number, trim($tb->duration_string($timespan, true)))), __('Your sending settings ([settings]) can\'t send that quickly to [number] subscribers. Expect delivery delays. [link]Read more[/link]', WYSIJA));
660
+ $this->viewObj->immediatewarning = '<span class="warning-msg" id="immediatewarning">' . $this->immediatewarning . '</span>';
661
+
662
+ $this->jsTrans['immediatewarning'] = $this->immediatewarning;
663
+
664
+ //how many emails can be sent in 12 hours
665
+ //if the frequency is less than 12hours
666
+ if ($timespan < 43200) {
667
+ $ratio = floor(43200 / $timespan);
668
+ $this->jsTrans['possibleemails'] = $ratio * $number;
669
+ } else {
670
+ if ($timespan == 43200) {
671
+ $this->jsTrans['possibleemails'] = $number;
672
+ } else {
673
+ $ratio = floor($timespan / 43200);
674
+ $this->jsTrans['possibleemails'] = $number / $ratio;
675
+ }
676
+ }
677
+ }
678
+
679
+ function editDetails() {
680
+ if (!$this->_checkEmailExists($_REQUEST['id']))
681
+ return;
682
+ $this->viewObj->title = __('Final step: last details', WYSIJA);
683
+ $this->viewShow = 'editDetails';
684
+ $this->js[] = 'wysija-validator';
685
+ $this->jsTrans['previewemail'] = __('Sending preview...', WYSIJA);
686
+ $this->jsTrans['pickadate'] = __('Pick a date', WYSIJA);
687
+ $this->jsTrans['saveclose'] = __('Save & close', WYSIJA);
688
+ $this->jsTrans['sendlater'] = __('Send later', WYSIJA);
689
+
690
+ $this->jsTrans['schedule'] = __('Schedule', WYSIJA);
691
+
692
+ $this->jsTrans['emailCheck'] = WJ_Utils::get_tip_data();
693
+
694
+
695
+ $this->js[] = 'jquery-ui-datepicker';
696
+ $this->js[] = 'wysija-tooltip';
697
+
698
+ $model_list = WYSIJA::get('list', 'model');
699
+ $model_list->limitON = false;
700
+ $this->data = array();
701
+ $this->data['lists'] = $this->__getLists(false, true, true);
702
+
703
+ $model_email = WYSIJA::get('email', 'model');
704
+ $this->data['email'] = $model_email->getOne(false, array('email_id' => $_REQUEST['id']));
705
+
706
+ // The first newsletter, we don't have replyto_email and replyto_name
707
+ if (empty($this->data['email']['replyto_email']) || empty($this->data['email']['replyto_name'])) {
708
+ $current_user = wp_get_current_user();
709
+ $this->data['email']['replyto_email'] = $current_user->data->user_email;
710
+ $this->data['email']['replyto_name'] = $current_user->data->display_name;
711
+ }
712
+
713
+
714
+ if ((int) $this->data['email']['type'] == 2) {
715
+ $this->js['wysija-edit-autonl'] = 'wysija-edit-autonl';
716
+ $this->jsTrans['autonl'] = true;
717
+ $this->immediateWarning();
718
+ $this->jsTrans['send'] = __('Activate now', WYSIJA);
719
+ } else {
720
+ $this->jsTrans['autonl'] = true;
721
+ $this->viewObj->immediatewarning = '';
722
+ $this->jsTrans['send'] = __('Send', WYSIJA);
723
+ }
724
+
725
+ if ((int) $this->data['email']['type'] == 1) {
726
+ $this->jsTrans['alertsend'] = __('You are about to send this newsletter. Please confirm.', WYSIJA);
727
+ } else {
728
+ if (isset($this->data['email']['params']['autonl']['event']) && $this->data['email']['params']['autonl']['event'] == 'subs-2-nl') {
729
+ $this->data['autoresponder'] = 1;
730
+ foreach ($this->data['lists'] as $list) {
731
+ if ($list['list_id'] == $this->data['email']['params']['autonl']['subscribetolist']) {
732
+ break;
733
+ }
734
+ }
735
+
736
+ $this->jsTrans['ignoreprevious'] = sprintf(__('Are you sure you want to ignore the %1$s subscribers of the list %2$s?', WYSIJA), '"' . $list['count'] . '"', '"' . $list['name'] . '"');
737
+ }
738
+ }
739
+
740
+ $this->checkIsEditable();
741
+
742
+ $this->title = sprintf(__('Step %1$s', WYSIJA), 3) . " | " . $this->data['email']['subject'];
743
+ $this->dataAutoNl();
744
+
745
+ $this->jsLoc['wysija-edit-autonl']['autofields'] = $this->data['autonl']['fields'];
746
+
747
+ $modelCL = WYSIJA::get('campaign_list', 'model');
748
+ $this->data['campaign_list'] = $modelCL->get(false, array('campaign_id' => $this->data['email']['campaign_id']));
749
+ }
750
+
751
+ function delete() {
752
+ $this->requireSecurity();
753
+
754
+ $campaign_ids = array();
755
+ if(isset($_REQUEST['id'])) $campaign_ids[] = $_REQUEST['id'];
756
+ if(isset($_REQUEST['campaign']['campaign_id'])) $campaign_ids[] = $_REQUEST['campaign']['campaign_id'];
757
+ if(isset($_REQUEST['wysija']['campaign']['campaign_id'][0])){
758
+ $campaign_ids = array_merge($campaign_ids, $_REQUEST['wysija']['campaign']['campaign_id']);
759
+ }
760
+
761
+ if (!empty($campaign_ids)) {
762
+ foreach($campaign_ids as $campaign_id){
763
+ if($campaign_id > 0){
764
+ $model_campaign = WYSIJA::get('campaign', 'model');
765
+ $model_campaign->delete(array('campaign_id' => $campaign_id));
766
+
767
+ $model_campaign_list = WYSIJA::get('campaign_list', 'model');
768
+ $model_campaign_list->delete(array('campaign_id' => $campaign_id));
769
+
770
+ $modelEmail = WYSIJA::get('email', 'model');
771
+ $modelEmail->delete(array('campaign_id' => $campaign_id));
772
+ }
773
+ }
774
+
775
+ $this->notice(_n(__('Newsletter deleted.', WYSIJA), __('Newsletters deleted.', WYSIJA), count($campaign_ids), WYSIJA));
776
+ } else {
777
+ $this->notice(__('Newsletter can\'t be deleted.', WYSIJA));
778
+ }
779
+
780
+ // retrieve saved filter
781
+ if (!empty($_REQUEST['action']))
782
+ unset($_REQUEST['action']);
783
+ if (!empty($_REQUEST['id']))
784
+ unset($_REQUEST['id']);
785
+ if (!empty($_REQUEST['_wpnonce']))
786
+ unset($_REQUEST['_wpnonce']);
787
+ $redirect = $this->base_url . '?' . http_build_query($_REQUEST);
788
+ $this->redirect($redirect);
789
+ }
790
+
791
+ /**
792
+ *
793
+ * this function is to delete an email that belongs to a campaign
794
+ * when we have a post notification all emails belong to the same campaign
795
+ * we don't want to delete an entire campaign when we delete a single email
796
+ */
797
+ function deleteEmail(){
798
+ $this->requireSecurity();
799
+ if(!$this->_checkEmailExists($_REQUEST['id'])) return;
800
+
801
+ if(isset($_REQUEST['id'])){
802
+ $modelEmail=WYSIJA::get('email','model');
803
+ $modelEmail->delete(array('email_id'=>$_REQUEST['id']));
804
+ $this->notice(__('Newsletter deleted.',WYSIJA));
805
+ }else{
806
+ $this->notice(__('Newsletter can\'t be deleted.',WYSIJA));
807
+ }
808
+
809
+ $this->redirect();
810
+ }
811
+
812
+ function savecamp() {
813
+ $this->redirectAfterSave = false;
814
+
815
+ /* update email */
816
+ $data = array();
817
+
818
+ // in case the newsletter already exists
819
+ if (isset($_REQUEST['id'])) {
820
+ $modelEmail = WYSIJA::get('email', 'model');
821
+ $modelEmail->fieldValid = false;
822
+ $emaildataarr = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
823
+
824
+ $model_campaign = WYSIJA::get('campaign', 'model');
825
+ $model_campaign->update(array('name' => $_POST['wysija']['email']['subject'], 'description' => ''), array('campaign_id' => $emaildataarr['campaign_id']));
826
+
827
+ $campaign_id = $emaildataarr['campaign_id'];
828
+ $email_id = $emaildataarr['email_id'];
829
+ $dataEmail = array(
830
+ 'campaign_id' => $campaign_id,
831
+ 'subject' => $_POST['wysija']['email']['subject'],
832
+ 'type' => $_POST['wysija']['email']['type']);
833
+
834
+ if((int)$dataEmail['type'] === 2) {
835
+ // set autonl params
836
+ $dataEmail['params'] = array('autonl' => $_POST['wysija']['email']['params']['autonl']);
837
+
838
+ // WTF?
839
+ if(!isset($newparams['autonl']['unique_send'])) {
840
+ unset($dataEmail['params']['autonl']['unique_send']);
841
+ } else {
842
+ $dataEmail['params']['autonl']['unique_send'] = true;
843
+ }
844
+ }
845
+
846
+ // check if the newsletter used to be an automatic newsletter (if )
847
+ if((int)$dataEmail['type'] === 1 && (int)$emaildataarr['type'] === 2) {
848
+ // make sure we remove any kind of auto-post block
849
+ $helper_autonews = WYSIJA::get('autonews', 'helper');
850
+ $updated_email_data = $helper_autonews->remove_autopost_blocks($emaildataarr['wj_data']);
851
+ if($updated_email_data !== false) {
852
+ // if the email data has been changed, make sure to update it in the DB
853
+ $dataEmail['wj_data'] = $updated_email_data;
854
+ }
855
+ }
856
+
857
+ $modelEmail->columns['modified_at']['autoup'] = 1;
858
+ $modelEmail->debugupdate = true;
859
+ $dataEmail['email_id'] = $_REQUEST['id'];
860
+
861
+ if(isset($_REQUEST['save-reactivate'])) {
862
+ //if the button save and reactivate has been clicked then we reactivate and redirect to the newsletter page
863
+ $dataEmail['status'] = 99;
864
+ $_REQUEST['return'] = 1;
865
+ }
866
+
867
+ $data['email']['email_id'] = $modelEmail->update($dataEmail, array('email_id' => (int)$_REQUEST['id']));
868
+ } else {
869
+ // get default theme
870
+ $model_config = WYSIJA::get('config', 'model');
871
+ $default_theme = $model_config->getValue('newsletter_default_theme', 'default');
872
+
873
+ $helper_themes = WYSIJA::get('themes', 'helper');
874
+ $theme_data = $helper_themes->getData($default_theme);
875
+
876
+ // get campaign data
877
+ $model_campaign = WYSIJA::get('campaign', 'model');
878
+ $campaign_id = $model_campaign->insert(array('name' => $_POST['wysija']['email']['subject'], 'description' => ''));
879
+
880
+ $modelEmail = WYSIJA::get('email', 'model');
881
+ $modelEmail->fieldValid = false;
882
+ $emaildata = array(
883
+ 'campaign_id' => $campaign_id,
884
+ 'subject' => $_POST['wysija']['email']['subject'],
885
+ 'type' => (int) $_POST['wysija']['email']['type']
886
+ );
887
+
888
+
889
+ // create autonl parameters if necessary
890
+ if ((int) $_POST['wysija']['email']['type'] === 2 && isset($_POST['wysija']['email']['params']['autonl'])) {
891
+ $emaildata['params'] = array('autonl' => $_POST['wysija']['email']['params']['autonl']);
892
+ }
893
+
894
+ // create sample data depending on newsletter's type
895
+ if ((int) $_POST['wysija']['email']['type'] === 2 && $_POST['wysija']['email']['params']['autonl']['event'] === 'new-articles') {
896
+
897
+ // if immediate, post_limit is set to 1
898
+ if ($emaildata['params']['autonl']['when-article'] === 'immediate') {
899
+ $autopostParams = array(
900
+ array('key' => 'category_ids', 'value' => null),
901
+ array('key' => 'title_tag', 'value' => 'h2'),
902
+ array('key' => 'title_alignment', 'value' => 'left'),
903
+ array('key' => 'title_position', 'value' => 'inside'),
904
+ array('key' => 'image_alignment', 'value' => 'alternate'),
905
+ array('key' => 'image_width', 'value' => 325),
906
+ array('key' => 'post_content', 'value' => 'excerpt'),
907
+ array('key' => 'readmore', 'value' => base64_encode(__('Read more.', WYSIJA))),
908
+ array('key' => 'show_divider', 'value' => 'yes'),
909
+ array('key' => 'post_limit', 'value' => 1),
910
+ array('key' => 'post_type', 'value' => 'post'),
911
+ array('key' => 'author_show', 'value' => 'no'),
912
+ array('key' => 'author_label', 'value' => base64_encode(__('Author:', WYSIJA))),
913
+ array('key' => 'category_show', 'value' => 'no'),
914
+ array('key' => 'category_label', 'value' => base64_encode(__('Categories:', WYSIJA))),
915
+ array('key' => 'nopost_message', 'value' => base64_encode(__('Latest content already sent.', WYSIJA))),
916
+ array('key' => 'bgcolor1', 'value' => null),
917
+ array('key' => 'bgcolor2', 'value' => null),
918
+ array('key' => 'sort_by', 'value' => 'newest')
919
+ );
920
+ } else {
921
+ $autopostParams = array(
922
+ array('key' => 'category_ids', 'value' => null),
923
+ array('key' => 'title_tag', 'value' => 'h2'),
924
+ array('key' => 'title_alignment', 'value' => 'left'),
925
+ array('key' => 'title_position', 'value' => 'inside'),
926
+ array('key' => 'image_alignment', 'value' => 'alternate'),
927
+ array('key' => 'image_width', 'value' => 325),
928
+ array('key' => 'post_content', 'value' => 'excerpt'),
929
+ array('key' => 'readmore', 'value' => base64_encode(__('Read more.', WYSIJA))),
930
+ array('key' => 'show_divider', 'value' => 'yes'),
931
+ array('key' => 'post_limit', 'value' => 2),
932
+ array('key' => 'post_type', 'value' => 'post'),
933
+ array('key' => 'author_show', 'value' => 'no'),
934
+ array('key' => 'author_label', 'value' => base64_encode(__('Author:', WYSIJA))),
935
+ array('key' => 'category_show', 'value' => 'no'),
936
+ array('key' => 'category_label', 'value' => base64_encode(__('Categories:', WYSIJA))),
937
+ array('key' => 'nopost_message', 'value' => base64_encode(__('Latest content already sent.', WYSIJA))),
938
+ array('key' => 'bgcolor1', 'value' => null),
939
+ array('key' => 'bgcolor2', 'value' => null),
940
+ array('key' => 'sort_by', 'value' => 'newest')
941
+ );
942
+ }
943
+
944
+ // sample data for post notifications
945
+ $newwjdata = array(
946
+ 'version' => WYSIJA::get_version(),
947
+ 'header' => array(
948
+ 'text' => NULL,
949
+ 'image' => array(
950
+ 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
951
+ 'width' => 600,
952
+ 'height' => 86,
953
+ 'alignment' => 'center',
954
+ 'static' => true,
955
+ ),
956
+ 'alignment' => 'center',
957
+ 'static' => true,
958
+ 'type' => 'header'
959
+ ),
960
+ 'body' => array(
961
+ 'block-1' => array(
962
+ 'text' => array(
963
+ 'value' => '<h3 class="align-right">' . sprintf(__("The posts below were added with the widget %sAutomatic latest content%s", WYSIJA), '<strong>', '</strong>') . '</h3>'
964
+ ),
965
+ 'image' => array(
966
+ 'src' => WYSIJA_EDITOR_IMG . 'default-newsletter/autonewsletter/arrow-up.png',
967
+ 'width' => 45,
968
+ 'height' => 45,
969
+ 'alignment' => 'right',
970
+ 'static' => false
971
+ ),
972
+ 'alignment' => 'right',
973
+ 'static' => false,
974
+ 'position' => '1',
975
+ 'type' => 'content'
976
+ ),
977
+ 'block-2' => array(
978
+ 'text' => array(
979
+ 'value' => '<h3>' . sprintf(__('%sTo edit%s, mouse over to show edit button below.', WYSIJA), '<strong>', '</strong>') . '</h3>'
980
+ ),
981
+ 'image' => array(
982
+ 'src' => WYSIJA_EDITOR_IMG . 'default-newsletter/autonewsletter/arrow-down.png',
983
+ 'width' => 150,
984
+ 'height' => 53,
985
+ 'alignment' => 'left',
986
+ 'static' => false
987
+ ),
988
+ 'alignment' => 'left',
989
+ 'static' => false,
990
+ 'position' => '2',
991
+ 'type' => 'content'
992
+ ),
993
+ 'block-3' => array(
994
+ 'params' => $autopostParams,
995
+ 'position' => '3',
996
+ 'type' => 'auto-post'
997
+ )
998
+ ),
999
+ 'footer' => array(
1000
+ 'text' => NULL,
1001
+ 'image' => array(
1002
+ 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
1003
+ 'width' => 600,
1004
+ 'height' => 86,
1005
+ 'alignment' => 'center',
1006
+ 'static' => true,
1007
+ ),
1008
+ 'alignment' => 'center',
1009
+ 'static' => true,
1010
+ 'type' => 'footer'
1011
+ )
1012
+ );
1013
+ } else {
1014
+ if(!isset($emaildata['params'])) {
1015
+ $emaildata['params'] = array();
1016
+ }
1017
+
1018
+ $emaildata['params']['quickselection'] = array(
1019
+ 'wp-301' => array(
1020
+ 'identifier' => 'wp-301',
1021
+ 'width' => 281,
1022
+ 'height' => 190,
1023
+ 'url' => WYSIJA_EDITOR_IMG . 'default-newsletter/newsletter/pigeon.png',
1024
+ 'thumb_url' => WYSIJA_EDITOR_IMG . 'default-newsletter/newsletter/pigeon-150x150.png'
1025
+ )
1026
+ );
1027
+
1028
+ if($theme_data['divider'] === null) {
1029
+ // default theme does not exist anymore or there is no divider associated to the theme
1030
+ // we need to get the default divider in this case
1031
+ $helper_dividers = WYSIJA::get('dividers', 'helper');
1032
+ $default_divider = $helper_dividers->getDefault();
1033
+ } else {
1034
+ // set default divider
1035
+ $default_divider = $theme_data['divider'];
1036
+ }
1037
+ // set default divider in email parameters
1038
+ $emaildata['params']['divider'] = $default_divider;
1039
+
1040
+ // get bookmarks from iconset 2
1041
+ $helper_bookmarks = WYSIJA::get('bookmarks', 'helper');
1042
+ $bookmarks = $helper_bookmarks->getAllByIconset('medium', '02');
1043
+
1044
+ // sample data for regular newsletter
1045
+ $newwjdata = array(
1046
+ 'version' => WYSIJA::get_version(),
1047
+ 'header' => array(
1048
+ 'text' => null,
1049
+ 'image' => array(
1050
+ // 'src' => WYSIJA_EDITOR_IMG.'default-newsletter/newsletter/header.png',
1051
+ 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
1052
+ 'width' => 600,
1053
+ 'height' => 86,
1054
+ 'alignment' => 'center',
1055
+ 'static' => true
1056
+ ),
1057
+ 'alignment' => 'center',
1058
+ 'static' => true,
1059
+ 'type' => 'header'
1060
+ ),
1061
+ 'body' => array(
1062
+ 'block-1' => array(
1063
+ 'text' => array(
1064
+ 'value' => '<h2><strong>' . __('Step 1:', WYSIJA) . '</strong> ' . __('hey, click on this text!', WYSIJA) . '</h2>' . '<p>' . __('To edit, simply click on this block of text.', WYSIJA) . '</p>'
1065
+ ),
1066
+ 'image' => null,
1067
+ 'alignment' => 'left',
1068
+ 'static' => false,
1069
+ 'position' => 1,
1070
+ 'type' => 'content'
1071
+ ),
1072
+ 'block-2' => array_merge(array(
1073
+ 'position' => 2,
1074
+ 'type' => 'divider'
1075
+ ),
1076
+ $default_divider
1077
+ ),
1078
+ 'block-3' => array(
1079
+ 'text' => array(
1080
+ 'value' => '<h2><strong>' . __('Step 2:', WYSIJA) . '</strong> ' . __('play with this image', WYSIJA) . '</h2>'
1081
+ ),
1082
+ 'image' => null,
1083
+ 'alignment' => 'left',
1084
+ 'static' => false,
1085
+ 'position' => 3,
1086
+ 'type' => 'content'
1087
+ ),
1088
+ 'block-4' => array(
1089
+ 'text' => array(
1090
+ 'value' => '<p>' . __('Position your mouse over the image to the left.', WYSIJA) . '</p>'
1091
+ ),
1092
+ 'image' => array(
1093
+ 'src' => WYSIJA_EDITOR_IMG . 'default-newsletter/newsletter/pigeon.png',
1094
+ 'width' => 281,
1095
+ 'height' => 190,
1096
+ 'alignment' => 'left',
1097
+ 'static' => false
1098
+ ),
1099
+ 'alignment' => 'left',
1100
+ 'static' => false,
1101
+ 'position' => 4,
1102
+ 'type' => 'content'
1103
+ ),
1104
+ 'block-5' => array_merge(array(
1105
+ 'position' => 5,
1106
+ 'type' => 'divider'
1107
+ ), $default_divider
1108
+ ),
1109
+ 'block-6' => array(
1110
+ 'text' => array(
1111
+ 'value' => '<h2><strong>' . __('Step 3:', WYSIJA) . '</strong> ' . __('drop content here', WYSIJA) . '</h2>' .
1112
+ '<p>' . sprintf(__('Drag and drop %1$stext, posts, dividers.%2$s Look on the right!', WYSIJA), '<strong>', '</strong>') . '</p>' .
1113
+ '<p>' . sprintf(__('You can even %1$ssocial bookmarks%2$s like these:', WYSIJA), '<strong>', '</strong>') . '</p>'
1114
+ ),
1115
+ 'image' => null,
1116
+ 'alignment' => 'left',
1117
+ 'static' => false,
1118
+ 'position' => 6,
1119
+ 'type' => 'content'
1120
+ ),
1121
+ 'block-7' => array(
1122
+ 'width' => 184,
1123
+ 'alignment' => 'center',
1124
+ 'items' => array(
1125
+ array_merge(array(
1126
+ 'url' => 'http://www.facebook.com/mailpoetplugin',
1127
+ 'alt' => 'Facebook',
1128
+ 'cellWidth' => 61,
1129
+ 'cellHeight' => 32
1130
+ ), $bookmarks['facebook']),
1131
+ array_merge(array(
1132
+ 'url' => 'http://www.twitter.com/mail_poet',
1133
+ 'alt' => 'Twitter',
1134
+ 'cellWidth' => 61,
1135
+ 'cellHeight' => 32
1136
+ ), $bookmarks['twitter']),
1137
+ array_merge(array(
1138
+ 'url' => 'https://plus.google.com/+Mailpoet',
1139
+ 'alt' => 'Google',
1140
+ 'cellWidth' => 61,
1141
+ 'cellHeight' => 32
1142
+ ), $bookmarks['google'])
1143
+ ),
1144
+ 'position' => 7,
1145
+ 'type' => 'gallery'
1146
+ ),
1147
+ 'block-8' => array_merge(array(
1148
+ 'position' => 8,
1149
+ 'type' => 'divider'
1150
+ ), $default_divider
1151
+ ),
1152
+ 'block-9' => array(
1153
+ 'text' => array(
1154
+ 'value' => '<h2><strong>' . __('Step 4:', WYSIJA) . '</strong> ' . __('and the footer?', WYSIJA) . '</h2>' .
1155
+ '<p>' . sprintf(__('Change the footer\'s content in MailPoet\'s %1$sSettings%2$s page.', WYSIJA), '<strong>', '</strong>') . '</p>'
1156
+ ),
1157
+ 'image' => null,
1158
+ 'alignment' => 'left',
1159
+ 'static' => false,
1160
+ 'position' => 9,
1161
+ 'type' => 'content'
1162
+ )
1163
+ ),
1164
+ 'footer' => array(
1165
+ 'text' => NULL,
1166
+ 'image' => array(
1167
+ // 'src' => WYSIJA_EDITOR_IMG.'default-newsletter/newsletter/footer.png',
1168
+ 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
1169
+ 'width' => 600,
1170
+ 'height' => 86,
1171
+ 'alignment' => 'center',
1172
+ 'static' => true,
1173
+ ),
1174
+ 'alignment' => 'center',
1175
+ 'static' => true,
1176
+ 'type' => 'footer'
1177
+ )
1178
+ );
1179
+ }
1180
+
1181
+ // set default styles
1182
+ $helper_engine = WYSIJA::get('wj_engine', 'helper');
1183
+ $styles = $helper_engine->getDefaultStyles();
1184
+ // end - set default styles
1185
+
1186
+ // set theme specific data
1187
+ if($theme_data['header'] !== null) {
1188
+ $newwjdata['header'] = $theme_data['header'];
1189
+ }
1190
+ if($theme_data['footer'] !== null) {
1191
+ $newwjdata['footer'] = $theme_data['footer'];
1192
+ }
1193
+ if($theme_data['divider'] !== null) {
1194
+ $newwjdata['widgets'] = array('divider' => $theme_data['divider']);
1195
+ }
1196
+ // end - set theme specific data
1197
+
1198
+ $emaildata['wj_data'] = base64_encode(serialize($newwjdata));
1199
+ $emaildata['wj_styles'] = base64_encode(serialize($styles));
1200
+
1201
+ $email_id = $data['email']['email_id'] = $modelEmail->insert($emaildata);
1202
+
1203
+ $this->notice(__('Newsletter successfully created.', WYSIJA));
1204
+ }
1205
+
1206
+ $this->_saveLists($campaign_id, true);
1207
+
1208
+ if (isset($_REQUEST['return']))
1209
+ $this->redirect();
1210
+ else {
1211
+ $this->redirect('admin.php?page=wysija_campaigns&action=editTemplate&id=' . $email_id);
1212
+ }
1213
+ }
1214
+
1215
+ function saveemail() {
1216
+ $this->redirectAfterSave = false;
1217
+ //$this->requireSecurity();
1218
+ $modelEmail = WYSIJA::get("email", "model");
1219
+ $modelEmail->fieldValid = false;
1220
+ $emaildataarr = $modelEmail->getOne(array('email_id' => $_REQUEST['id']));
1221
+
1222
+ if (isset($_REQUEST['save-reactivate'])) {
1223
+ //if the button save and reactivate has been clicked then we reactivate and redirect to the newsletter page
1224
+ $dataEmail['status'] = 99;
1225
+ $_REQUEST['return'] = 1;
1226
+ }
1227
+
1228
+ if (isset($_REQUEST['return']))
1229
+ $this->redirect();
1230
+ else {
1231
+ $this->redirect('admin.php?page=wysija_campaigns&action=editDetails&id=' . $emaildataarr['email_id']);
1232
+ }
1233
+ }
1234
+
1235
+ function savelast() {
1236
+ $this->redirectAfterSave = false;
1237
+ $post_notification = false;
1238
+ $this->requireSecurity();
1239
+
1240
+ if (!isset($_POST['wysija']['email']['from_name']) || !isset($_POST['wysija']['email']['from_email']) || !isset($_POST['wysija']['email']['replyto_name']) || !isset($_POST['wysija']['email']['replyto_email'])) {
1241
+ $this->error(__('Information is missing.', WYSIJA));
1242
+ return $this->editDetails();
1243
+ }
1244
+ if (isset($_REQUEST['wysija']['email']['params']['googletrackingcode']) && $_REQUEST['wysija']['email']['params']['googletrackingcode'] &&
1245
+ (!is_string($_REQUEST['wysija']['email']['params']['googletrackingcode']) OR
1246
+ preg_match('#[^a-z0-9_-\s]#i', $_REQUEST['wysija']['email']['params']['googletrackingcode']) !== 0 )) {
1247
+ //force to simple text
1248
+ $_REQUEST['wysija']['email']['params']['googletrackingcode'] = preg_replace('#[^a-z0-9_-\s]#i', '_', $_REQUEST['wysija']['email']['params']['googletrackingcode']);
1249
+ $this->error(__('The Google Campaign name needs to be only letters, number, spaces and hyphens. We\'ll improve this in the future!', WYSIJA), 1);
1250
+ return $this->editDetails();
1251
+ }
1252
+
1253
+ $update_email = array(
1254
+ 'email_id' => $_POST['wysija']['email']['email_id'],
1255
+ 'from_name' => $_POST['wysija']['email']['from_name'],
1256
+ 'from_email' => $_POST['wysija']['email']['from_email'],
1257
+ 'replyto_name' => $_POST['wysija']['email']['replyto_name'],
1258
+ 'replyto_email' => $_POST['wysija']['email']['replyto_email'],
1259
+ 'subject' => $_POST['wysija']['email']['subject'],
1260
+ );
1261
+ $model_email = WYSIJA::get('email', 'model');
1262
+ if (isset($_POST['wysija']['email']['params']))
1263
+ $update_email['params'] = $_POST['wysija']['email']['params'];
1264
+
1265
+ //insert into campaigns lists
1266
+ $this->_saveLists($_POST['wysija']['campaign']['campaign_id']);
1267
+ $email_data = $model_email->getOne($_POST['wysija']['email']['email_id']);
1268
+
1269
+ // if we just save the draf we don't go through the big sending process setup
1270
+ if (isset($_POST['submit-draft']) || isset($_POST['submit-pause']) || (isset($_REQUEST['wj_redir']) && $_REQUEST['wj_redir'] == 'savelastback')) {
1271
+ if (isset($_POST['wysija']['email']['params']['schedule']['isscheduled']))
1272
+ $this->notice(__('Newsletter has been scheduled.', WYSIJA));
1273
+ else
1274
+ $this->notice(__('Newsletter has been saved as a draft.', WYSIJA));
1275
+ }else {
1276
+ // we update the param attribute with what's has been posted
1277
+ foreach ($update_email as $ki => $vi) {
1278
+ if ($ki == 'params') {
1279
+ foreach ($vi as $parake => $paraval) {
1280
+ $email_data['params'][$parake] = $paraval;
1281
+ }
1282
+ $update_email[$ki] = $email_data[$ki];
1283
+ }
1284
+ else
1285
+ $email_data[$ki] = $vi;
1286
+ }
1287
+
1288
+ // if the checkbox to ignore retroactivity is here we just tell the class
1289
+ if (isset($_POST['wysija']['email']['ignore_subscribers'])) {
1290
+ $model_email->retro_active_autoresponders = false;
1291
+ }
1292
+
1293
+ // activate or send the email depending on the typ
1294
+ $model_email->send_activate($email_data);
1295
+ }
1296
+
1297
+ // update email
1298
+ $update_email['type'] = $email_data['type'];
1299
+
1300
+ if ($post_notification) {
1301
+ $helper_autonews = WYSIJA::get('autonews', 'helper');
1302
+ $update_email['params']['autonl']['nextSend'] = $helper_autonews->getNextSend($update_email);
1303
+ }
1304
+
1305
+ $model_email->reset();
1306
+ $model_email->columns['modified_at']['autoup'] = 1;
1307
+
1308
+ // update some fields of the email
1309
+ $model_email->update($update_email);
1310
+
1311
+ // update the campaign subject which ispretty much useless but good to keep in sync with the email
1312
+ $model_campaign = WYSIJA::get('campaign', 'model');
1313
+ $model_campaign->reset();
1314
+ $update_campaign = array('campaign_id' => $_REQUEST['id'], 'name' => $_POST['wysija']['email']['subject']);
1315
+ $model_campaign->update($update_campaign);
1316
+
1317
+ if (isset($_REQUEST['wj_redir']) && $_REQUEST['wj_redir'] == 'savelastback') {
1318
+ return $this->redirect('admin.php?page=wysija_campaigns&action=editTemplate&id=' . $_POST['wysija']['email']['email_id']);
1319
+ }
1320
+ else
1321
+ return $this->redirect();
1322
+ }
1323
+
1324
+ function _saveLists($campaignId, $flagup = false) {
1325
+ //record the list that we have in that campaign
1326
+ $modelCampL = WYSIJA::get('campaign_list', 'model');
1327
+ if ($flagup || (int) $campaignId > 0) {
1328
+ $modelCampL->delete(array('equal' => array('campaign_id' => $campaignId)));
1329
+ $modelCampL->reset();
1330
+ }
1331
+
1332
+ if (isset($_POST['wysija']['campaign_list']['list_id'])) {
1333
+ //$modelCampL=WYSIJA::get("campaign_list","model");
1334
+ foreach ($_POST['wysija']['campaign_list']['list_id'] as $listid) {
1335
+ $modelCampL->insert(array('campaign_id' => $campaignId, "list_id" => $listid));
1336
+ }
1337
+ }
1338
+ }
1339
+
1340
+ function _addLinkFilter($status, $type = 'status') {
1341
+ switch ($type) {
1342
+ case 'status':
1343
+ switch ($status) {
1344
+ case 'draft':
1345
+ $this->filters['equal'] = array('status' => 0);
1346
+ break;
1347
+ case 'sending':
1348
+ $this->filters['equal'] = array('status' => 99);
1349
+ break;
1350
+ case 'sent':
1351
+ $this->filters['equal'] = array('status' => 2);
1352
+ break;
1353
+ case 'paused':
1354
+ $this->filters['equal'] = array('status' => -1);
1355
+ break;
1356
+ case 'scheduled':
1357
+ $this->filters['equal'] = array('status' => 4);
1358
+ break;
1359
+ }
1360
+ break;
1361
+ case 'type':
1362
+ switch ($status) {
1363
+ case 'regular':
1364
+ $this->filters['equal'] = array('type' => 1);
1365
+ break;
1366
+ case 'autonl':
1367
+ $this->filters['equal'] = array('type' => 2);
1368
+ break;
1369
+ }
1370
+ break;
1371
+ }
1372
+ }
1373
+
1374
+ /**
1375
+ * Get all campaigns, based on the filters
1376
+ */
1377
+ protected function get_campaigns() {
1378
+ $order_by = ' ORDER BY ';
1379
+
1380
+ if (isset($_REQUEST['orderby'])) {
1381
+ if (!is_string($_REQUEST['orderby']) OR preg_match('|[^a-z0-9#_.-]|i', $_REQUEST['orderby']) !== 0) {
1382
+ $_REQUEST['orderby'] = '';
1383
+ }
1384
+ if (!in_array(strtoupper($_REQUEST['ordert']), array('DESC', 'ASC')))
1385
+ $_REQUEST['ordert'] = 'DESC';
1386
+ $order_by.=$_REQUEST['orderby'] . ' ' . $_REQUEST['ordert'];
1387
+ }else {
1388
+ $order_by.='FIELD(B.status, 99,3,1,0,2), ';
1389
+ $order_by.='B.status desc, ';
1390
+ $order_by.='B.modified_at desc, ';
1391
+ $order_by.='B.sent_at desc, ';
1392
+ $order_by.='B.type desc, ';
1393
+ $order_by.='A.' . $this->modelObj->getPk() . ' DESC';
1394
+ }
1395
+
1396
+ $query = '
1397
+ SELECT
1398
+ A.`campaign_id`,
1399
+ A.`name` as `campaign_name`,
1400
+ B.`subject` as `name`,
1401
+ A.`description`,
1402
+ B.`params`,
1403
+ B.`type`,
1404
+ B.`number_sent`,
1405
+ B.`number_opened`,
1406
+ B.`number_clicked`,
1407
+ B.`number_unsub`,
1408
+ (B.`number_sent` +
1409
+ B.`number_opened` +
1410
+ B.`number_clicked` +
1411
+ B.`number_unsub` +
1412
+ B.`number_bounce` +
1413
+ B.`number_forward`
1414
+ ) AS `number_total`,
1415
+ B.`status`,
1416
+ B.`created_at`,
1417
+ B.`modified_at`,
1418
+ B.`sent_at`,
1419
+ B.`email_id`
1420
+ FROM
1421
+ `[wysija]' . $this->modelObj->table_name . '` AS A
1422
+ LEFT JOIN
1423
+ `[wysija]email` AS B on A.`campaign_id` = B.`campaign_id`
1424
+ LEFT JOIN
1425
+ `[wysija]campaign_list` AS C on A.`campaign_id` = C.`campaign_id`';
1426
+ $campaigns = $this->modelObj->getResults($query . $this->modelObj->makeWhere() . ' GROUP BY B.email_id' . $order_by . $this->modelObj->setLimit());
1427
+
1428
+ // calculate percetange of open / click / unsubscribe
1429
+ $helper_numbers = WYSIJA::get('numbers', 'helper');
1430
+ foreach ($campaigns as &$campaign) {
1431
+ // open rate, based on sent number
1432
+ $campaign['rate_opened'] = $helper_numbers->calculate_percetage($campaign['number_opened'], $campaign['number_total'], 1);
1433
+ // click rate, based on opened number
1434
+ $campaign['rate_clicked'] = $helper_numbers->calculate_percetage($campaign['number_clicked'], $campaign['number_total'], 1);
1435
+ // unsubscribe rate, based on opened number
1436
+ $campaign['rate_unsub'] = $helper_numbers->calculate_percetage($campaign['number_unsub'], $campaign['number_total'], 1);
1437
+ }
1438
+ return $campaigns;
1439
+ }
1440
+
1441
+ /**
1442
+ * Get the first campaign in history
1443
+ */
1444
+ protected function get_oldest_compaign() {
1445
+ $query = '
1446
+ SELECT
1447
+ MIN(B.created_at) as datemin
1448
+ FROM `[wysija]' . $this->modelObj->table_name . '` as A
1449
+ LEFT JOIN
1450
+ `[wysija]email` AS B on A.campaign_id = B.campaign_id
1451
+ LEFT JOIN
1452
+ `[wysija]campaign_list` as C on A.campaign_id = C.campaign_id';
1453
+
1454
+ return $this->modelObj->query('get_row', $query . $this->modelObj->makeWhere());
1455
+ }
1456
+
1457
+ /**
1458
+ * Count ALL emails of each email-status
1459
+ * @todo: move to model
1460
+ */
1461
+ protected function count_emails_by_status() {
1462
+ $query = '
1463
+ SELECT
1464
+ COUNT(`email_id`) AS `campaigns`,
1465
+ `status`
1466
+ FROM
1467
+ `[wysija]email`
1468
+ WHERE
1469
+ `campaign_id` > 0
1470
+ GROUP BY `status`';
1471
+
1472
+ $countss = $this->modelObj->query('get_res', $query);
1473
+ $counts = array();
1474
+ $total = 0;
1475
+
1476
+ foreach ($countss as $count) {
1477
+ switch ($count['status']) {
1478
+ case '0':
1479
+ $type = 'draft';
1480
+ break;
1481
+ case '1':
1482
+ case '3':
1483
+ case '99':
1484
+ $type = 'sending';
1485
+ break;
1486
+ case '2':
1487
+ $type = 'sent';
1488
+ break;
1489
+ case '-1':
1490
+ $type = 'paused';
1491
+ break;
1492
+ case '4':
1493
+ $type = 'scheduled';
1494
+ break;
1495
+ }
1496
+ $total = $total + $count['campaigns'];
1497
+ $counts['status-' . $type] = $count['campaigns'];
1498
+ }
1499
+ return $counts;
1500
+ }
1501
+
1502
+ /**
1503
+ * Count emails which matched the filters
1504
+ */
1505
+ protected function count_emails() {
1506
+ $query = '
1507
+ SELECT
1508
+ COUNT(DISTINCT B.`email_id`) AS `campaigns`
1509
+ FROM
1510
+ `[wysija]' . $this->modelObj->table_name . '` AS A
1511
+ LEFT JOIN
1512
+ `[wysija]email` AS B ON A.`campaign_id` = B.`campaign_id`
1513
+ LEFT JOIN
1514
+ `[wysija]campaign_list` AS C ON A.`campaign_id` = C.`campaign_id`';
1515
+ return $this->modelObj->count($query . $this->modelObj->makeWhere(), 'campaigns');
1516
+ }
1517
+
1518
+ /**
1519
+ * Count ALL emails of each type of email
1520
+ */
1521
+ protected function count_emails_by_type() {
1522
+ $query = '
1523
+ SELECT
1524
+ COUNT(`email_id`) AS `campaigns`,
1525
+ `type`
1526
+ FROM
1527
+ `[wysija]email`
1528
+ WHERE
1529
+ `campaign_id` > 0
1530
+ GROUP BY `type`';
1531
+ $countss = $this->modelObj->query('get_res', $query, ARRAY_A);
1532
+ $counts = array();
1533
+ foreach ($countss as $count) {
1534
+ switch ($count['type']) {
1535
+ case '1':
1536
+ $type = 'regular';
1537
+ break;
1538
+ case '2':
1539
+ $type = 'autonl';
1540
+ break;
1541
+ }
1542
+ $counts['type-' . $type] = $count['campaigns'];
1543
+ }
1544
+ return $counts;
1545
+ }
1546
+
1547
+ /**
1548
+ * Get all existing lists
1549
+ */
1550
+ protected function get_lists() {
1551
+ $model_list = WYSIJA::get('list', 'model');
1552
+ $query = '
1553
+ SELECT
1554
+ A.`list_id`,
1555
+ A.`name`,
1556
+ A.`is_enabled`,
1557
+ COUNT( B.`campaign_id` ) AS `users`
1558
+ FROM
1559
+ `[wysija]' . $model_list->table_name . '` as A
1560
+ LEFT JOIN
1561
+ `[wysija]campaign_list` AS B on A.`list_id` = B.`list_id`
1562
+ GROUP BY A.`list_id`';
1563
+ $result = $model_list->getResults($query);
1564
+ $lists = array();
1565
+ foreach ($result as $list_obj) {
1566
+ $lists[$list_obj['list_id']] = $list_obj;
1567
+ }
1568
+ return $lists;
1569
+ }
1570
+
1571
+ function defaultDisplay() {
1572
+ $this->data['base_url'] = $this->base_url . '?' . http_build_query($_REQUEST); // saved filter
1573
+ $this->title = __('Newsletters', WYSIJA);
1574
+ $this->viewShow = $this->action = 'main';
1575
+ $this->js[] = 'wysija-admin-list';
1576
+ $this->jsTrans["selecmiss"] = __('Please select a newsletter.', WYSIJA);
1577
+ $this->jsTrans['suredelete'] = __('Delete this newsletter for ever?', WYSIJA);
1578
+ $this->jsTrans['suredelete_bulk'] = __('Delete these newsletters for ever?', WYSIJA);
1579
+ $this->jsTrans['processqueue'] = __('Sending batch of emails...', WYSIJA);
1580
+ $this->jsTrans['viewnews'] = __('View newsletter', WYSIJA);
1581
+ $this->jsTrans['confirmpauseedit'] = __('The newsletter will be deactivated, you will need to reactivate it once you\'re over editing it. Do you want to proceed?', WYSIJA);
1582
+
1583
+
1584
+ //get the filters
1585
+ if (isset($_REQUEST['search']) && $_REQUEST['search']) {
1586
+ $this->filters['like'] = array();
1587
+ foreach ($this->searchable as $field)
1588
+ $this->filters['like'][$field] = $_REQUEST['search'];
1589
+ }
1590
+
1591
+ if (isset($_REQUEST['filter-list']) && $_REQUEST['filter-list']) {
1592
+ $this->filters['equal'] = array('C.list_id' => $_REQUEST['filter-list']);
1593
+ }
1594
+
1595
+ if (isset($_REQUEST['filter-date']) && $_REQUEST['filter-date']) {
1596
+ $this->filters['greater_eq'] = array('created_at' => $_REQUEST['filter-date']);
1597
+ $this->filters['less_eq'] = array('created_at' => strtotime('+1 month', $_REQUEST['filter-date']));
1598
+ }
1599
+
1600
+ $this->filters['is'] = array('type' => 'IS NOT NULL');
1601
+
1602
+
1603
+ if (isset($_REQUEST['link_filter']) && $_REQUEST['link_filter']) {
1604
+ $linkfilters = explode('-', $_REQUEST['link_filter']);
1605
+
1606
+ if (count($linkfilters) > 1) {
1607
+ $this->_addLinkFilter($linkfilters[1], $linkfilters[0]);
1608
+ } else {
1609
+ $this->_addLinkFilter($_REQUEST['link_filter']);
1610
+ }
1611
+ }
1612
+
1613
+ $this->modelObj->noCheck = true;
1614
+ $this->modelObj->reset();
1615
+ if ($this->filters)
1616
+ $this->modelObj->setConditions($this->filters);
1617
+
1618
+
1619
+ // Count emails by status and type
1620
+ $emails_by_status = $this->count_emails_by_status();
1621
+ $emails_by_type = $this->count_emails_by_type();
1622
+ $counts = array_merge($emails_by_status, $emails_by_type);
1623
+ $counts['all'] = array_sum($emails_by_status);
1624
+
1625
+ // collect data
1626
+ $this->data['campaigns'] = $this->get_campaigns();
1627
+ $this->data['datemin'] = $this->get_oldest_compaign();
1628
+ $lists = $this->get_lists(); // $lists is in use later within this scope
1629
+ $this->data['lists'] = $lists;
1630
+
1631
+ // for paging
1632
+ $this->modelObj->countRows = $this->filters ? $this->count_emails () : $counts['all'];
1633
+
1634
+
1635
+ // count queue
1636
+ $email_ids = array();
1637
+ foreach ($this->data['campaigns'] as $emailcamp) {
1638
+ if (in_array($emailcamp['status'], array(1, 3, 99)))
1639
+ $email_ids[] = $emailcamp['email_id'];
1640
+ }
1641
+ $model_queue = WYSIJA::get('queue', 'model');
1642
+ $model_queue->setConditions(array("email_id" => $email_ids));
1643
+ $model_queue->groupBy('email_id');
1644
+ $queue = $model_queue->count();
1645
+ if ($queue) {
1646
+ $this->viewObj->queuedemails = $queue;
1647
+ }
1648
+
1649
+ $this->modelObj->reset();
1650
+
1651
+ //make a loop from the first created to now and increment an array of months
1652
+ $now = time();
1653
+ $this->data['dates'] = array();
1654
+
1655
+ if ((int) $this->data['datemin']['datemin'] > 1) {
1656
+ setlocale(LC_TIME, 'en_US');
1657
+ $formtlettres = "1 " . date('F', $this->data['datemin']['datemin']) . ' ' . date("Y", $this->data['datemin']['datemin']);
1658
+ $month_start = strtotime($formtlettres);
1659
+
1660
+ if ($month_start > 0) {
1661
+ for ($i = $month_start; $i < $now; $i = strtotime('+1 month', $i)) {
1662
+ $this->data['dates'][$i] = date_i18n('F Y', $i); //date('F Y',$i);
1663
+ }
1664
+ }
1665
+ }
1666
+
1667
+
1668
+
1669
+ $campaign_ids_sent = $campaign_ids = array();
1670
+ foreach ($this->data['campaigns'] as &$campaign) {
1671
+ $campaign_ids[] = $campaign['campaign_id'];
1672
+ $modelEmail = WYSIJA::get('email', 'model');
1673
+ $modelEmail->getParams($campaign);
1674
+ if (in_array((int) $campaign['status'], array(-1, 1, 2, 3, 99)))
1675
+ $campaign_ids_sent[] = $campaign['campaign_id'];
1676
+ }
1677
+
1678
+ // 3 - campaign_list request & count request for queue */
1679
+ if ($campaign_ids) {
1680
+ $modeluList = WYSIJA::get('campaign_list', 'model');
1681
+ $userlists = $modeluList->get(array('list_id', 'campaign_id'), array('campaign_id' => $campaign_ids));
1682
+
1683
+ if ($campaign_ids_sent) {
1684
+ $modeluList = WYSIJA::get("email_user_stat", "model");
1685
+ $statstotal = $modeluList->getResults("SELECT COUNT(A.user_id) as count,B.email_id FROM `[wysija]queue` as A
1686
+ JOIN `[wysija]email` as B on A.email_id=B.email_id
1687
+ WHERE B.campaign_id IN (" . implode(",", $campaign_ids_sent) . ") group by B.email_id");
1688
+
1689
+ $senttotalgroupedby = $modeluList->getResults("SELECT COUNT(A.user_id) as count,B.campaign_id,B.email_id,B.type,B.status,A.status as statususer FROM `[wysija]" . $modeluList->table_name . "` as A
1690
+ JOIN `[wysija]email` as B on A.email_id=B.email_id
1691
+ WHERE B.campaign_id IN (" . implode(",", $campaign_ids_sent) . ") group by A.status,B.email_id"); //,A.status
1692
+
1693
+
1694
+ $updateEmail = array();
1695
+ $columnnamestatus = array(0 => "number_sent", 1 => "number_opened", 2 => "number_clicked", 3 => "number_unsub", -1 => "number_bounce");
1696
+ foreach ($senttotalgroupedby as $sentbystatus) {
1697
+ if ($sentbystatus['statususer'] != "-2")
1698
+ $updateEmail[$sentbystatus['email_id']][$columnnamestatus[$sentbystatus['statususer']]] = $sentbystatus['count'];
1699
+ if (isset($senttotal[$sentbystatus['email_id']])) {
1700
+ $senttotal[$sentbystatus['email_id']]['count'] = (int) $senttotal[$sentbystatus['email_id']]['count'] + (int) $sentbystatus['count'];
1701
+ } else {
1702
+ unset($sentbystatus['statususer']);
1703
+ $senttotal[$sentbystatus['email_id']] = $sentbystatus;
1704
+ }
1705
+ }
1706
+
1707
+ $modelEmail = WYSIJA::get('email', 'model');
1708
+
1709
+ foreach ($updateEmail as $emailid => $update) {
1710
+
1711
+ foreach ($columnnamestatus as $v) {
1712
+ if (!isset($update[$v]))
1713
+ $update[$v] = 0;
1714
+ }
1715
+
1716
+ $modelEmail->update($update, array('email_id' => $emailid));
1717
+ $modelEmail->reset();
1718
+ }
1719
+
1720
+
1721
+ /**/
1722
+ $modelC = WYSIJA::get('config', 'model');
1723
+ $running = false;
1724
+
1725
+ $is_multisite = is_multisite();
1726
+
1727
+ //$is_multisite=true;//PROD comment that line
1728
+ if ($is_multisite && $modelC->getValue('sending_method') == 'network') {
1729
+ $sending_emails_each = $modelC->getValue('ms_sending_emails_each');
1730
+ } else {
1731
+ $sending_emails_each = $modelC->getValue('sending_emails_each');
1732
+ }
1733
+
1734
+ if ($modelC->getValue('cron_manual')) {
1735
+ $formsHelp = WYSIJA::get('forms', 'helper');
1736
+ $queue_frequency = $formsHelp->eachValuesSec[$sending_emails_each];
1737
+ $queue_scheduled = WYSIJA::get_cron_schedule('queue');
1738
+
1739
+ $next_scheduled_queue = $queue_scheduled['next_schedule'];
1740
+ $running = $queue_scheduled['running'];
1741
+
1742
+ if ($running) {
1743
+ $helperToolbox = WYSIJA::get('toolbox', 'helper');
1744
+ $running = time() - $running;
1745
+ $running = $helperToolbox->duration_string($running, true, 4);
1746
+ }
1747
+ } else {
1748
+ $schedules = wp_get_schedules();
1749
+ $queue_frequency = $schedules[wp_get_schedule('wysija_cron_queue')]['interval'];
1750
+ $next_scheduled_queue = wp_next_scheduled('wysija_cron_queue');
1751
+ }
1752
+
1753
+
1754
+
1755
+ $status_sent_complete = array();
1756
+ if (isset($senttotal) && $senttotal) {
1757
+ foreach ($senttotal as $sentot) {
1758
+ if ($sentot) {
1759
+ $this->data['sent'][$sentot['email_id']]['total'] = $sentot['count'];
1760
+ $this->data['sent'][$sentot['email_id']]['to'] = $sentot['count'];
1761
+ } else {
1762
+ $this->data['sent'][$sentot['email_id']]['total'] = $this->data['sent'][$sentot['email_id']]['to'] = 0;
1763
+ }
1764
+ $this->data['sent'][$sentot['email_id']]['status'] = $sentot['status'];
1765
+ $this->data['sent'][$sentot['email_id']]['type'] = $sentot['type'];
1766
+ $this->data['sent'][$sentot['email_id']]['left'] = (int) $this->data['sent'][$sentot['email_id']]['total'] - (int) $this->data['sent'][$sentot['email_id']]['to'];
1767
+ }
1768
+ }
1769
+
1770
+ foreach ($statstotal as $sentot) {
1771
+ if (!isset($this->data['sent'][$sentot['email_id']])) {
1772
+ $this->data['sent'][$sentot['email_id']]['total'] = 0;
1773
+ $this->data['sent'][$sentot['email_id']]['to'] = 0;
1774
+ }
1775
+ $this->data['sent'][$sentot['email_id']]['total'] = $this->data['sent'][$sentot['email_id']]['total'] + $sentot['count'];
1776
+ $this->data['sent'][$sentot['email_id']]['left'] = (int) $this->data['sent'][$sentot['email_id']]['total'] - (int) $this->data['sent'][$sentot['email_id']]['to'];
1777
+ }
1778
+
1779
+ //$is_multisite=true;//PROD comment that line
1780
+ if ($is_multisite && $modelC->getValue('sending_method') == 'network') {
1781
+ $sending_emails_number = $modelC->getValue('ms_sending_emails_number');
1782
+ } else {
1783
+ $sending_emails_number = $modelC->getValue('sending_emails_number');
1784
+ }
1785
+
1786
+ if (isset($this->data['sent'])) {
1787
+ foreach ($this->data['sent'] as $key => &$camp) {
1788
+ if ($this->data['sent'][$key]['left'] > 0) {
1789
+ $cronsneeded = ceil($this->data['sent'][$key]['left'] / $sending_emails_number);
1790
+ $this->data['sent'][$key]['remaining_time'] = $cronsneeded * $queue_frequency;
1791
+ $this->data['sent'][$key]['running_for'] = $running;
1792
+ $this->data['sent'][$key]['next_batch'] = $next_scheduled_queue - time();
1793
+ $this->data['sent'][$key]['remaining_time'] = $this->data['sent'][$key]['remaining_time'] - ($queue_frequency) + $this->data['sent'][$key]['next_batch'];
1794
+ } else {
1795
+ if ((in_array($this->data['sent'][$key]['status'], array(1, 3, 99))) && $this->data['sent'][$key]['type'] == 1)
1796
+ $status_sent_complete[] = $key;
1797
+ }
1798
+ }
1799
+ }
1800
+
1801
+
1802
+ // status update to sent for the one that are sent
1803
+ if (count($status_sent_complete) > 0) {
1804
+ $modelEmail = WYSIJA::get('email', 'model');
1805
+ $modelEmail->noCheck = true;
1806
+ $modelEmail->reset();
1807
+ $modelEmail->update(array('status' => 2), array('equal' => array('email_id' => $status_sent_complete)));
1808
+ }
1809
+ }
1810
+ }
1811
+
1812
+ $this->data['counts'] = array_reverse($counts);
1813
+
1814
+ /* regrouping all the data in the same array */
1815
+ foreach ($this->data['campaigns'] as &$campaign) {
1816
+ /* default key while we don't have the data */
1817
+ //TODO add data for stats about emails opened clicked etc
1818
+ $campaign["emails"] = 0;
1819
+ $campaign["opened"] = 0;
1820
+ $campaign["clicked"] = 0;
1821
+
1822
+ if ($userlists) {
1823
+ foreach ($userlists as $key => $userlist) {
1824
+ if ($campaign["campaign_id"] == $userlist["campaign_id"] && isset($lists[$userlist["list_id"]])) {
1825
+ if (!isset($campaign["lists"]))
1826
+ $campaign["lists"] = $lists[$userlist["list_id"]]["name"];
1827
+ else
1828
+ $campaign["lists"].=", " . $lists[$userlist["list_id"]]["name"];
1829
+ }
1830
+ }
1831
+ }
1832
+ if (isset($campaign["lists"]) && !$campaign["lists"])
1833
+ unset($campaign["lists"]);
1834
+
1835
+ if (((isset($campaign['params']['schedule']['isscheduled']) ||
1836
+ ($campaign['type'] == 2 && isset($campaign['params']['autonl']['event']) && in_array($campaign['params']['autonl']['event'], array('new-articles'/* ,'subs-2-nl' */)))
1837
+ ) && $campaign['status'] != 2 && !isset($campaign["lists"])) || ($campaign['type'] == 2 && isset($campaign['params']['autonl']['event']) && in_array($campaign['params']['autonl']['event'], array('subs-2-nl')) && $campaign['status'] != 2 && (!isset($campaign['params']['autonl']['subscribetolist']) || !isset($lists[$campaign['params']['autonl']['subscribetolist']]) ))
1838
+ ) {
1839
+ $campaign['classRow'] = " listmissing ";
1840
+ $campaign['msgListEdit'] = '<strong>' . __('The list has been deleted.', WYSIJA) . '</strong>';
1841
+ $campaign['msgSendSuspended'] = '<strong>' . __('Sending suspended.', WYSIJA) . '</strong>';
1842
+ }
1843
+ }
1844
+
1845
+ $this->dataAutoNl();
1846
+ if (!$this->data['campaigns']) {
1847
+ $this->notice(__('There are no newsletters.', WYSIJA));
1848
+ }
1849
+ }
1850
+
1851
+ function setviewStatsfilter() {
1852
+ /* get the filters */
1853
+ $this->searchable = array("email", "firstname", "lastname");
1854
+ $this->filters = array();
1855
+ if (isset($_REQUEST['search']) && $_REQUEST['search']) {
1856
+ $this->filters["like"] = array();
1857
+ foreach ($this->searchable as $field)
1858
+ $this->filters["like"][$field] = $_REQUEST['search'];
1859
+ }
1860
+ $this->tableQuery = 'email_user_stat';
1861
+ $this->statusemail = 'B.status as umstatus';
1862
+ if (isset($_REQUEST['link_filter']) && $_REQUEST['link_filter']) {
1863
+ switch ($_REQUEST['link_filter']) {
1864
+ case 'inqueue':
1865
+ $this->tableQuery = 'queue';
1866
+ $this->statusemail = '-2 as umstatus';
1867
+ break;
1868
+ case 'sent':
1869
+ $this->filters['equal'] = array('B.status' => 0);
1870
+ break;
1871
+ case 'bounced':
1872
+ $this->filters['equal'] = array('B.status' => -1);
1873
+ break;
1874
+ case 'opened':
1875
+ $this->filters['equal'] = array('B.status' => 1);
1876
+ break;
1877
+ case 'clicked':
1878
+ $this->filters['equal'] = array('B.status' => 2);
1879
+ break;
1880
+ case 'unsubscribe':
1881
+ $this->filters['equal'] = array('B.status' => 3);
1882
+ break;
1883
+ case 'notsent':
1884
+ $this->filters['equal'] = array('B.status' => -2);
1885
+ break;
1886
+ }
1887
+ }
1888
+ // filter by url id
1889
+ if (isset($_REQUEST['url_id']) && (int) $_REQUEST['url_id'] > 0) {
1890
+ $this->tableQuery = 'email_user_url';
1891
+ $this->filters['equal'] = array('B.url_id' => (int) $_REQUEST['url_id']);
1892
+ $this->statusemail = '2 as umstatus'; //by default, when filter by url_id, all subscribers had clicked
1893
+ }
1894
+ }
1895
+
1896
+ function viewstats() {
1897
+ $this->js[] = 'wysija-admin-list';
1898
+ $this->js[] = 'wysija-charts';
1899
+ $this->viewShow = 'viewstats';
1900
+
1901
+ $this->modelObj = WYSIJA::get("email", "model");
1902
+ $this->modelObj->limitON = false;
1903
+
1904
+ $email_object = $this->modelObj->getOne(false, array("email_id" => $_REQUEST['id']));
1905
+ $this->viewObj->model = $this->modelObj;
1906
+ $this->viewObj->namecampaign = $email_object['subject'];
1907
+ $this->viewObj->title = sprintf(__('Stats : %1$s', WYSIJA), $email_object['subject']);
1908
+
1909
+ $modelObjCamp = WYSIJA::get("campaign", "model");
1910
+ $limit_pp = false;
1911
+ if (isset($modelObjCamp->limit_pp))
1912
+ $limit_pp = $modelObjCamp->limit_pp;
1913
+ $modelObjCamp->limitON = false;
1914
+ $campaign = $modelObjCamp->getOne(false, array("campaign_id" => $email_object['campaign_id']));
1915
+
1916
+
1917
+ $this->setviewStatsfilter();
1918
+
1919
+ $this->modelObj->reset();
1920
+ $this->modelObj->noCheck = true;
1921
+
1922
+ /* 0 - counting request */
1923
+ $queryCmmonStart = 'SELECT count(distinct B.user_id) as users FROM `[wysija]user` as A';
1924
+ $queryCmmonStart.=' LEFT JOIN `[wysija]' . $this->tableQuery . '` as B on A.user_id=B.user_id';
1925
+
1926
+ /* all the counts query */
1927
+ $query = "SELECT count(user_id) as users, status FROM `[wysija]email_user_stat` as A
1928
+ WHERE A.email_id=" . $email_object['email_id'] . " GROUP BY status";
1929
+ $countss = $this->modelObj->query("get_res", $query, ARRAY_A);
1930
+
1931
+ /* we also count what is in the queue */
1932
+ $query = "SELECT count(user_id) as users FROM `[wysija]queue` as A
1933
+ WHERE A.email_id=" . $email_object['email_id'];
1934
+ $countss[-2]['status'] = -3;
1935
+ $countss[-2]['users'] = $this->modelObj->count($query, 'users');
1936
+
1937
+ $counts = array();
1938
+ $truetotal = $total = 0;
1939
+
1940
+ foreach ($countss as $count) {
1941
+ switch ($count['status']) {
1942
+ case "-3":
1943
+ $type = 'inqueue';
1944
+ break;
1945
+ case "-2":
1946
+ $type = 'notsent';
1947
+ break;
1948
+ case "-1":
1949
+ $type = 'bounced';
1950
+ break;
1951
+ case "0":
1952
+ $type = 'sent';
1953
+ break;
1954
+ case "1":
1955
+ $type = 'opened';
1956
+ break;
1957
+ case "2":
1958
+ $type = 'clicked';
1959
+ break;
1960
+ case "3":
1961
+ $type = 'unsubscribe';
1962
+ break;
1963
+ }
1964
+ if ($count['status'] != "-2")
1965
+ $total = $total + $count['users'];
1966
+ $truetotal = $truetotal + $count['users'];
1967
+ $counts[$type] = $count['users'];
1968
+ }
1969
+
1970
+ $counts['allsent'] = $total;
1971
+ $counts['all'] = $truetotal;
1972
+
1973
+ $this->modelObj->reset();
1974
+ $this->filters['equal']["B.email_id"] = $email_object['email_id'];
1975
+
1976
+ $this->modelObj->noCheck = true;
1977
+ if ($this->filters)
1978
+ $this->modelObj->setConditions($this->filters);
1979
+
1980
+ //$this->modelObj->setConditions(array("equal"=>array("B.email_id"=>$emailObj['email_id'])));
1981
+
1982
+ /* 1 - subscriber request */
1983
+ $query = 'SELECT A.user_id, A.firstname, A.lastname,A.status as ustatus,' . $this->statusemail . ' , A.email, B.* FROM `[wysija]user` as A';
1984
+ $query.=' LEFT JOIN `[wysija]' . $this->tableQuery . '` as B on A.user_id=B.user_id';
1985
+ $queryFinal = $this->modelObj->makeWhere();
1986
+
1987
+ /* without filter we already have the total number of subscribers */
1988
+ if ($this->filters)
1989
+ $this->modelObj->countRows = $this->modelObj->count($queryCmmonStart . $queryFinal, 'users');
1990
+ else
1991
+ $this->modelObj->countRows = $counts['all'];
1992
+
1993
+ $orderby = " ORDER BY ";
1994
+ /**
1995
+ * Until now, we have
1996
+ * - 3 possible values of $this->tableQuery (queue, email_user_url, email_user_stat), set by $this->setviewStatsfilter()
1997
+ * - 2 possible values of $_REQUEST['orderby']
1998
+ * => 3x2 = 6 cases
1999
+ */
2000
+ if (isset($_REQUEST['orderby'])) {
2001
+ switch ($this->tableQuery) {
2002
+ case 'email_user_url':
2003
+ case 'email_user_stat':
2004
+ $orderby .= 'B.' . $_REQUEST['orderby'] . " " . $_REQUEST['ordert'];
2005
+ break;
2006
+
2007
+ case 'queue':
2008
+ default:
2009
+ $orderby .= 'A.user_id DESC';
2010
+ break;
2011
+ }
2012
+ } else {
2013
+ switch ($this->tableQuery) {
2014
+ case 'email_user_url':
2015
+ $orderby .= 'B.clicked_at DESC, B.number_clicked DESC'; // by default, sort by last clicked and biggest hit
2016
+ break;
2017
+
2018
+ case 'email_user_stat':
2019
+ $orderby .= 'B.opened_at DESC, B.status DESC'; // by default, sort by last open and its staus value
2020
+ break;
2021
+
2022
+ case 'queue':
2023
+ default:
2024
+ $orderby .= 'A.user_id DESC';
2025
+ break;
2026
+ }
2027
+ }
2028
+ $this->data['tableQuery'] = $this->tableQuery;
2029
+ $this->modelObj->limitON = true;
2030
+ $this->data['subscribers'] = $this->modelObj->getResults($query . $queryFinal . " GROUP BY A.user_id" . $orderby . $this->modelObj->setLimit(0, (int)$limit_pp));
2031
+ $this->modelObj->reset();
2032
+
2033
+ /* make the data object for the listing view */
2034
+ $modelList = WYSIJA::get("list", "model");
2035
+
2036
+ /* 2 - list request */
2037
+ $query = "SELECT A.list_id, A.name,A.is_enabled, count( B.user_id ) AS users FROM `[wysija]" . $modelList->table_name . "` as A";
2038
+ $query.=" LEFT JOIN `[wysija]user_list` as B on A.list_id = B.list_id";
2039
+ $query.=" GROUP BY A.list_id";
2040
+ $listsDB = $modelList->getResults($query);
2041
+
2042
+ $lists = array();
2043
+ foreach ($listsDB as $listobj) {
2044
+ $lists[$listobj["list_id"]] = $listobj;
2045
+ }
2046
+
2047
+ $listsDB = null;
2048
+
2049
+ $user_ids = array();
2050
+ foreach ($this->data['subscribers'] as $subscriber) {
2051
+ $user_ids[] = $subscriber['user_id'];
2052
+ }
2053
+
2054
+ /* 3 - user_list request */
2055
+ if ($user_ids) {
2056
+ $modeluList = WYSIJA::get("user_list", "model");
2057
+ $userlists = $modeluList->get(array("list_id", "user_id"), array("user_id" => $user_ids));
2058
+ }
2059
+
2060
+
2061
+ $this->data['lists'] = $lists;
2062
+ $this->data['counts'] = array_reverse($counts);
2063
+
2064
+ /* regrouping all the data in the same array */
2065
+ foreach ($this->data['subscribers'] as $keysus => $subscriber) {
2066
+ /* default key while we don't have the data */
2067
+ //TODO add data for stats about emails opened clicked etc
2068
+ $this->data['subscribers'][$keysus]["emails"] = 0;
2069
+ $this->data['subscribers'][$keysus]["opened"] = 0;
2070
+ $this->data['subscribers'][$keysus]["clicked"] = 0;
2071
+
2072
+ if ($userlists) {
2073
+ foreach ($userlists as $key => $userlist) {
2074
+ if ($subscriber["user_id"] == $userlist["user_id"] && isset($lists[$userlist["list_id"]])) {
2075
+ if (!isset($this->data['subscribers'][$keysus]["lists"]))
2076
+ $this->data['subscribers'][$keysus]["lists"] = $lists[$userlist["list_id"]]["name"];
2077
+ else
2078
+ $this->data['subscribers'][$keysus]["lists"].=", " . $lists[$userlist["list_id"]]["name"];
2079
+ }
2080
+ }
2081
+ }
2082
+ }
2083
+
2084
+ $this->data['email'] = $email_object;
2085
+
2086
+ if (!$this->data['subscribers']) {
2087
+ $this->notice(__("Your request can't retrieve any subscribers. Change your filters!", WYSIJA));
2088
+ }
2089
+
2090
+ // execute hooks
2091
+ $hook_params = array(
2092
+ 'email_id' => $_REQUEST['id'],
2093
+ 'email_object' => $email_object
2094
+ );
2095
+
2096
+ $this->data['hooks']['hook_newsletter_top'] = apply_filters('hook_newsletter_top', WYSIJA_module::execute_hook('hook_newsletter_top', $hook_params), $hook_params);
2097
+ $this->data['hooks']['hook_newsletter_bottom'] = apply_filters('hook_newsletter_bottom', WYSIJA_module::execute_hook('hook_newsletter_bottom', $hook_params), $hook_params);
2098
+ }
2099
+
2100
+ function getListSubscriberQry($selectcolumns) {
2101
+ $this->modelObj = WYSIJA::get("email", "model");
2102
+ $this->emailObj = $this->modelObj->getOne(false, array('email_id' => $_REQUEST['id']));
2103
+
2104
+ /* use the filter if there is */
2105
+ $this->setviewStatsfilter();
2106
+
2107
+ if ($selectcolumns == "B.user_id") {
2108
+ //unset($this->filters["like"]);
2109
+ }
2110
+
2111
+ $this->filters['equal']["B.email_id"] = $this->emailObj['email_id'];
2112
+ $this->modelObj->noCheck = true;
2113
+ if ($this->filters)
2114
+ $this->modelObj->setConditions($this->filters);
2115
+
2116
+ /* select insert all the subscribers from that campaign into user_list */
2117
+ if ($selectcolumns == "B.user_id") {
2118
+ $query = "SELECT $selectcolumns FROM `[wysija]" . $this->tableQuery . "` as B";
2119
+ $query.=$this->modelObj->makeWhere();
2120
+ } else {
2121
+ $query = "SELECT $selectcolumns FROM `[wysija]user` as A";
2122
+ $query.=" LEFT JOIN `[wysija]" . $this->tableQuery . "` as B on A.user_id=B.user_id";
2123
+ $query.=$this->modelObj->makeWhere();
2124
+ }
2125
+
2126
+ return $query;
2127
+ }
2128
+
2129
+ function createnewlist() {
2130
+ /* get the email subject */
2131
+ $emailModel = WYSIJA::get('email', 'model');
2132
+ $email = $emailModel->getOne(array('subject'), array('email_id' => $_REQUEST['id']));
2133
+
2134
+ $this->modelObj->reset();
2135
+
2136
+ /* set the name of the new list */
2137
+ $prefix = "";
2138
+ if (isset($_REQUEST['link_filter']))
2139
+ $prefix = ' (' . $this->viewObj->getTransStatusEmail($_REQUEST['link_filter']) . ')';
2140
+ $listname = sprintf(__('Segment of %1$s', WYSIJA), $email['subject'] . $prefix);
2141
+
2142
+ /* insert new list */
2143
+ $modelL = WYSIJA::get('list', 'model');
2144
+ $listid = $modelL->insert(array('is_enabled' => 1, 'name' => $listname, 'description' => __('List created based on a newsletter segment.', WYSIJA)));
2145
+
2146
+ /* get list of subscribers filtered or not */
2147
+ $query = $this->getListSubscriberQry($listid . ', A.user_id, ' . time() . ', 0');
2148
+
2149
+ $query2 = 'INSERT INTO `[wysija]user_list` (`list_id`,`user_id`,`sub_date`,`unsub_date`) ' . $query;
2150
+
2151
+ $this->modelObj->query($query2);
2152
+
2153
+ $this->notice(sprintf(__('A new list "%1$s" has been created out of this segment.', WYSIJA), $listname));
2154
+ $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2155
+ }
2156
+
2157
+ function unsubscribeall() {
2158
+ // Update user_list, set unsubdate and sub_date
2159
+ $query = $this->getListSubscriberQry('B.user_id');
 
 
 
 
 
 
 
 
2160
  $query1 = "
2161
+ UPDATE `[wysija]user_list`
2162
+ SET
2163
  `unsub_date` = ".time().",
2164
  `sub_date` = 0
2165
+ WHERE
2166
  `user_id` IN ($query)
2167
  AND `list_id` NOT IN (SELECT `list_id` FROM `[wysija]list` WHERE `is_enabled` < 1)
2168
  ";
2169
+ $this->modelObj->query($query1);
2170
+
2171
+ // unsubscribe from user where select from email_user_stat
2172
+ $query2 = "UPDATE `[wysija]user` SET `status`=-1 WHERE `user_id` IN ($query)";
2173
+ $this->modelObj->query($query2);
2174
+
2175
+ $this->notice(__('The segment has been unbsubscribed from all the lists.', WYSIJA));
2176
+ $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2177
+ }
2178
+
2179
+ function sendconfirmation() {
2180
+ //delete from user_lists where select from email_user_stat
2181
+ $query = $this->getListSubscriberQry('B.user_id ');
2182
+
2183
+ $user_ids = $this->modelObj->query('get_res', $query);
2184
+
2185
+ $uids = array();
2186
+ foreach ($user_ids as $data) {
2187
+ $uids[] = $data['user_id'];
2188
+ }
2189
+
2190
+ $helperUser = WYSIJA::get('user', 'helper');
2191
+ $helperUser->sendConfirmationEmail($uids);
2192
+ $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2193
+ }
2194
+
2195
+ function removequeue() {
2196
+ /* delete from queue where select from email_user_stat */
2197
+ $query = $this->getListSubscriberQry('B.user_id');
2198
+ $query2 = "DELETE FROM `[wysija]queue` where user_id IN ($query) AND email_id=" . $this->emailObj['email_id'];
2199
+ $this->modelObj->query($query2);
2200
+
2201
+ $this->notice(__('The segment has been removed from the queue of this newsletter.', WYSIJA));
2202
+ $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2203
+ }
2204
+
2205
+ function export() {
2206
+ /* select from email_user_stat left join user */
2207
+ $query = $this->getListSubscriberQry('B.user_id');
2208
+ $result = $this->modelObj->query('get_res', $query);
2209
+ $user_ids = array();
2210
+ foreach ($result as $user)
2211
+ $user_ids[] = $user['user_id'];
2212
+
2213
+ $fileHelp = WYSIJA::get('file', 'helper');
2214
+ $tempfilename = $fileHelp->temp(implode(',', $user_ids), 'export_userids', '.txt');
2215
+
2216
+ //$this->redirect("admin.php?page=wysija_campaigns&action=viewstats&id=".$_REQUEST['id']."&user_ids=".serialize($result));
2217
+ $this->redirect('admin.php?page=wysija_subscribers&action=exportcampaign&camp_id=' . $_REQUEST['id'] . '&file_name=' . base64_encode($tempfilename['path']));
2218
+ }
2219
+
2220
+ function unsubscribelist($data) {
2221
+
2222
+ $modelL = WYSIJA::get('list', 'model');
2223
+ $list = $modelL->getOne(false, array('list_id' => $data['listid']));
2224
+ if ($list['is_enabled']) {
2225
+ /* delete from user_lists where select from email_user_stat */
2226
+ $query = $this->getListSubscriberQry("B.user_id");
2227
+ $query2 = "DELETE FROM `[wysija]user_list` where user_id IN ($query) and list_id=" . $data['listid'];
2228
+ $this->modelObj->query($query2);
2229
+
2230
+ $this->notice(sprintf(__('The segment has been unbsubscribed from the list "%1$s".', WYSIJA), $list['name']));
2231
+ } else {
2232
+ $this->notice(sprintf(__('The segment cannot be unbsubscribed from an [IMPORT] list.', WYSIJA), $list['name']));
2233
+ }
2234
+
2235
+ $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2236
+ }
2237
+
2238
+ function articles() {
2239
+ $this->iframeTabs = array('articles' => __("Post Selection", WYSIJA));
2240
+
2241
+ // required js files
2242
+ $this->js[] = 'wysija-admin-ajax';
2243
+ $this->js[] = 'wysija-base-script-64';
2244
+ $this->js[] = 'wysija-scriptaculous';
2245
+ $this->js[] = 'wysija-colorpicker';
2246
+
2247
+ // translations
2248
+ $this->jsTrans['show_advanced'] = __('Display and insert options', WYSIJA);
2249
+ $this->jsTrans['hide_advanced'] = __('Back to selection', WYSIJA);
2250
+ $this->jsTrans['loading_results'] = __('Loading results...', WYSIJA);
2251
+ $this->jsTrans['inserting_selection'] = __('Inserting selected articles...', WYSIJA);
2252
+ $this->jsTrans['post_selected'] = __('selected', WYSIJA);
2253
+
2254
+ // default tab in popup (this needs to be removed at some point)
2255
+ $_GET['tab'] = 'articles';
2256
+
2257
+ // get parameters
2258
+ $params = array(
2259
+ 'category_ids' => null,
2260
+ 'category' => null,
2261
+ 'title_tag' => 'h2',
2262
+ 'title_alignment' => 'left',
2263
+ 'title_position' => 'inside',
2264
+ 'image_alignment' => 'alternate',
2265
+ 'image_width' => 325,
2266
+ 'post_content' => 'excerpt',
2267
+ 'readmore' => __('Read more.', WYSIJA),
2268
+ 'show_divider' => 'yes',
2269
+ 'post_limit' => 5,
2270
+ 'post_type' => 'post',
2271
+ 'author_show' => 'no',
2272
+ 'author_label' => __('Author:', WYSIJA),
2273
+ 'category_show' => 'no',
2274
+ 'category_label' => __('Categories:', WYSIJA),
2275
+ 'nopost_message' => __('Latest content already sent.', WYSIJA),
2276
+ 'bgcolor1' => null,
2277
+ 'bgcolor2' => null,
2278
+ 'sort_by' => 'newest'
2279
+ );
2280
+
2281
+ // check if GET parameters are specified
2282
+ foreach($params as $key => $value) {
2283
+ if(array_key_exists($key, $_GET)) {
2284
+ switch($key) {
2285
+ case 'autopost_count':
2286
+ $params[$key] = (int)$_GET[$key];
2287
+ break;
2288
+ case 'readmore':
2289
+ case 'nopost_message':
2290
+ $params[$key] = base64_decode($_GET[$key]);
2291
+ break;
2292
+ default:
2293
+ $params[$key] = $_GET[$key];
2294
+ }
2295
+ }
2296
+ }
2297
+
2298
+ $model_config = WYSIJA::get('config', 'model');
2299
+ $insert_post_parameters = $model_config->getValue('insert_post_parameters');
2300
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
2301
+
2302
+ if($insert_post_parameters !== false) {
2303
+ // there are user params
2304
+ $params = $helper_wj_engine->decodeParameters(array_merge($params, $insert_post_parameters));
2305
+ }
2306
+
2307
+ // get autopost count
2308
+ $this->data['autopost_count'] = (array_key_exists('autopost_count', $_GET)) ? (int) $_GET['autopost_count'] : 0;
2309
+
2310
+ // get autopost type (single or multiple)
2311
+ $this->data['autopost_type'] = (array_key_exists('autopost_type', $_GET)) ? $_GET['autopost_type'] : 'multiple';
2312
+
2313
+ // if only one group of post can be added, change default alignment to left
2314
+ if($this->data['autopost_type'] === 'single' && $params['image_alignment'] === 'alternate') {
2315
+ $params['image_alignment'] = 'left';
2316
+ }
2317
+
2318
+ // get post categories (even when there's no post)
2319
+ $post_categories = get_categories(array('hide_empty' => 0));
2320
+ $categories = array();
2321
+ foreach ($post_categories as $category) {
2322
+ $categories[] = array('id' => $category->cat_ID, 'name' => $category->name);
2323
+ }
2324
+ $this->data['categories'] = $categories;
2325
+
2326
+ // max number of posts
2327
+ $this->data['post_limits'] = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 50);
2328
+
2329
+ $this->data['params'] = $params;
2330
+
2331
+ return $this->popupContent();
2332
+ }
2333
+
2334
+ function themeupload() {
2335
+ $helperNumbers = WYSIJA::get('numbers', 'helper');
2336
+ $bytes = $helperNumbers->get_max_file_upload();
2337
+
2338
+ if (isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH'] > $bytes['maxbytes']) {
2339
+ if (isset($_FILES['my-theme']['name']) && $_FILES['my-theme']['name']) {
2340
+ $filename = $_FILES['my-theme']['name'];
2341
+ } else {
2342
+ $filename = "";
2343
+ }
2344
+
2345
+ $this->error(sprintf(__('Upload error, file %1$s is too large! (MAX:%2$s)', WYSIJA), $filename, $bytes['maxmegas']), true);
2346
+ $this->redirect('admin.php?page=wysija_campaigns&action=themes');
2347
+
2348
+ return false;
2349
+ }
2350
+
2351
+
2352
+ $ZipfileResult = trim(file_get_contents($_FILES['my-theme']['tmp_name']));
2353
+
2354
+ $themesHelp = WYSIJA::get('themes', 'helper');
2355
+ $result = $themesHelp->installTheme($_FILES['my-theme']['tmp_name'], true);
2356
+ $this->redirect('admin.php?page=wysija_campaigns&action=themes&reload=1');
2357
+
2358
+ return true;
2359
+ }
2360
+
2361
+ function themes() {
2362
+ $this->iframeTabs = array('themes' => __('Install Themes', WYSIJA));
2363
+ $this->js[] = 'wysija-admin-ajax';
2364
+ $this->js[] = 'wysija-base-script-64';
2365
+ $this->jsTrans['viewinfos'] = __('Details & PSD', WYSIJA);
2366
+ $this->jsTrans['viewback'] = __('<< Back', WYSIJA);
2367
+ $this->jsTrans['install'] = __('Download', WYSIJA);
2368
+ $this->jsTrans['reinstall'] = __('Reinstall', WYSIJA);
2369
+ $this->jsTrans['premiumonly'] = __('Premium', WYSIJA);
2370
+
2371
+ $model_config = WYSIJA::get('config', 'model');
2372
+ //change the translation of the button when it's premium
2373
+ if ($model_config->getValue('premium_key'))
2374
+ $this->jsTrans['ispremium'] = 1;
2375
+ else
2376
+ $this->jsTrans['ispremium'] = 0;
2377
+
2378
+ $this->jsTrans['premiumfiles'] = __('Photoshop file available as part of [link]Premium features[/link].', WYSIJA);
2379
+
2380
+ $helper_licence = WYSIJA::get('licence', 'helper');
2381
+ $url_checkout = $helper_licence->get_url_checkout('themes');
2382
+ $this->jsTrans['premiumfiles'] = str_replace(array('[link]', '[/link]'), array('<a href="' . $url_checkout . '" target="_blank" >', '</a>'), $this->jsTrans['premiumfiles']);
2383
+
2384
+ $this->jsTrans['showallthemes'] = __('Show all themes', WYSIJA);
2385
+ $this->jsTrans['totalvotes'] = __('(%1$s votes)', WYSIJA);
2386
+ $this->jsTrans['voterecorded'] = __("Your vote has been recorded.", WYSIJA);
2387
+ $this->jsTrans['votenotrecorded'] = __("Your vote could not be recorded.", WYSIJA);
2388
+ $this->jsTrans['reinstallwarning'] = __('Watch out! If you reinstall this theme all the files which are in the folder:/wp-content/uploads/wysija/themes/%1$s will be overwritten. Are you sure you want to reinstall?', WYSIJA);
2389
+ $this->jsTrans['errorconnecting'] = __("We were unable to contact the API, the site may be down. Please try again later.", WYSIJA);
2390
+
2391
+ $this->jsTrans['viewallthemes'] = __('View all themes by %1$s', WYSIJA);
2392
+ $this->jsTrans['downloadpsd'] = __("Download original Photoshop file", WYSIJA);
2393
+ $this->jsTrans['downloadzip'] = __("Download as .zip", WYSIJA);
2394
+ $this->jsTrans['viewauthorsite'] = __("View author's website", WYSIJA);
2395
+ $this->jsTrans['stars'] = __('Average rating: %1$s', WYSIJA);
2396
+ $this->jsTrans['starsyr'] = __('My rating: %1$s', WYSIJA);
2397
+ $this->jsTrans['downloads'] = __('Downloads: %1$s', WYSIJA);
2398
+ $this->jsTrans['tags'] = __('Tags: %1$s', WYSIJA);
2399
+ $this->jsTrans['lastupdated'] = __('Last updated: %1$s', WYSIJA);
2400
+ $this->jsTrans['includes'] = __('Includes: %1$s', WYSIJA);
2401
+
2402
+ $helper_themes = WYSIJA::get('themes', 'helper');
2403
+
2404
+ $this->jsTrans['installedthemes'] = $helper_themes->getInstalled();
2405
+
2406
+ $url = admin_url('admin.php');
2407
+ $helper_toolbox = WYSIJA::get("toolbox", "helper");
2408
+ $domain_name = $helper_toolbox->_make_domain_name($url);
2409
+ $this->jsTrans['domainname'] = $domain_name;
2410
+
2411
+ $_GET['tab'] = 'themes';
2412
+
2413
+ return $this->popupContent();
2414
+ }
2415
+
2416
+ function bookmarks() {
2417
+ $this->iframeTabs = array('bookmarks' => __('Bookmarks Selection', WYSIJA));
2418
+ $this->js[] = 'wysija-admin-ajax';
2419
+
2420
+ $_GET['tab'] = 'bookmarks';
2421
+
2422
+ $networks = array(
2423
+ 'facebook' => array(
2424
+ 'label' => 'Facebook',
2425
+ 'url' => null,
2426
+ 'placeholder' => 'https://www.facebook.com/mailpoetplugin'
2427
+ ),
2428
+ 'twitter' => array(
2429
+ 'label' => 'Twitter',
2430
+ 'url' => null,
2431
+ 'placeholder' => 'http://www.twitter.com/mail_poet'
2432
+ ),
2433
+ 'google' => array(
2434
+ 'label' => 'Google+',
2435
+ 'url' => null,
2436
+ 'placeholder' => null
2437
+ ),
2438
+ 'linkedin' => array(
2439
+ 'label' => 'LinkedIn',
2440
+ 'url' => null,
2441
+ 'placeholder' => null
2442
+ )
2443
+ );
2444
+
2445
+ // get networks' url from config
2446
+ $model_config = WYSIJA::get('config', 'model');
2447
+ $urls = $model_config->getValue('social_bookmarks');
2448
+
2449
+ // set url from config for each network if specified
2450
+ foreach ($networks as $network => $values) {
2451
+ if (isset($urls[$network]) and strlen(trim($urls[$network])) > 0) {
2452
+ $networks[$network]['url'] = $urls[$network];
2453
+ }
2454
+ }
2455
+
2456
+ $this->data['networks'] = $networks;
2457
+ $this->data['size'] = 'medium';
2458
+ $this->data['theme'] = isset($_REQUEST['theme']) ? $_REQUEST['theme'] : 'default';
2459
+
2460
+ return $this->popupContent();
2461
+ }
2462
+
2463
+ function dividers() {
2464
+ $this->iframeTabs = array('dividers' => __("Dividers Selection", WYSIJA));
2465
+ $this->js[] = 'wysija-admin-ajax';
2466
+ $this->js[] = 'wysija-base-script-64';
2467
+
2468
+ $_GET['tab'] = 'dividers';
2469
+
2470
+ $model_email = WYSIJA::get('email', 'model');
2471
+ $this->data['email'] = $email = $model_email->getOne(false, array('email_id' => $_REQUEST['emailId']));
2472
+
2473
+ // get dividers
2474
+ $helper_dividers = WYSIJA::get('dividers', 'helper');
2475
+ $dividers = $helper_dividers->getAll();
2476
+
2477
+ // get theme divider if it's not the default theme
2478
+ if (isset($email['params']['theme'])) {
2479
+ $helper_themes = WYSIJA::get('themes', 'helper');
2480
+ $themeDivider = $helper_themes->getDivider($email['params']['theme']);
2481
+ if ($themeDivider !== NULL) {
2482
+ array_unshift($dividers, $themeDivider);
2483
+ }
2484
+ }
2485
+
2486
+ // get selected divider
2487
+ if (isset($email['params']['divider'])) {
2488
+ $selected_divider = $email['params']['divider'];
2489
+ } else {
2490
+ $helper_dividers = WYSIJA::get('dividers', 'helper');
2491
+ $selected_divider = $helper_dividers->getDefault();
2492
+ }
2493
+
2494
+ // set selected divider in first position
2495
+ array_unshift($dividers, $selected_divider);
2496
+
2497
+ // remove selected divider if present in the list
2498
+ for ($i = 1; $i < count($dividers); $i++) {
2499
+ if ($dividers[$i]['src'] === $selected_divider['src']) {
2500
+ unset($dividers[$i]);
2501
+ break;
2502
+ }
2503
+ }
2504
+
2505
+ $this->data['selected'] = $selected_divider;
2506
+ $this->data['dividers'] = $dividers;
2507
+ return $this->popupContent();
2508
+ }
2509
+
2510
+ function autopost() {
2511
+ $this->iframeTabs = array('autopost' => __("Add / Edit group of posts", WYSIJA));
2512
+ $this->js[] = 'wysija-admin-ajax';
2513
+ $this->js[] = 'wysija-base64';
2514
+ $this->js[] = 'wysija-scriptaculous';
2515
+ $this->js[] = 'wysija-colorpicker';
2516
+ $this->js[] = 'wysija-chosen-jquery';
2517
+
2518
+ // translations
2519
+ $this->jsTrans['show_advanced'] = __('Show display options', WYSIJA);
2520
+ $this->jsTrans['hide_advanced'] = __('Hide display options', WYSIJA);
2521
+
2522
+ $_GET['tab'] = 'autopost';
2523
+
2524
+ // get parameters
2525
+ $params = array(
2526
+ 'category_ids' => null,
2527
+ 'category_condition' => 'include',
2528
+ 'title_tag' => 'h2',
2529
+ 'title_alignment' => 'left',
2530
+ 'title_position' => 'inside',
2531
+ 'image_alignment' => 'alternate',
2532
+ 'image_width' => 325,
2533
+ 'post_content' => 'excerpt',
2534
+ 'readmore' => __('Read more.', WYSIJA),
2535
+ 'show_divider' => 'yes',
2536
+ 'post_limit' => 5,
2537
+ 'post_type' => 'post',
2538
+ 'author_show' => 'no',
2539
+ 'author_label' => __('Author:', WYSIJA),
2540
+ 'category_show' => 'no',
2541
+ 'category_label' => __('Categories:', WYSIJA),
2542
+ 'nopost_message' => __('Latest content already sent.', WYSIJA),
2543
+ 'bgcolor1' => null,
2544
+ 'bgcolor2' => null,
2545
+ 'sort_by' => 'newest'
2546
+ );
2547
+
2548
+ // check if GET parameters are specified
2549
+ foreach ($params as $key => $value) {
2550
+ if (array_key_exists($key, $_GET)) {
2551
+ switch ($key) {
2552
+ case 'autopost_count':
2553
+ $params[$key] = (int) $_GET[$key];
2554
+ break;
2555
+ case 'author_label':
2556
+ case 'category_label':
2557
+ case 'readmore':
2558
+ case 'nopost_message':
2559
+ $params[$key] = base64_decode($_GET[$key]);
2560
+ break;
2561
+ default:
2562
+ $params[$key] = $_GET[$key];
2563
+ }
2564
+ }
2565
+ }
2566
+
2567
+ // get autopost count
2568
+ $this->data['autopost_count'] = (array_key_exists('autopost_count', $_GET)) ? (int) $_GET['autopost_count'] : 0;
2569
+
2570
+ // get autopost type (single or multiple)
2571
+ $this->data['autopost_type'] = (array_key_exists('autopost_type', $_GET)) ? $_GET['autopost_type'] : 'multiple';
2572
+
2573
+ // if only one group of post can be added, change default alignment to left
2574
+ if ($this->data['autopost_type'] === 'single') {
2575
+ if ($params['image_alignment'] === 'alternate')
2576
+ $params['image_alignment'] = 'left';
2577
+ }
2578
+
2579
+ // we use that now, because categories from a post are different than categories from a CPT
2580
+ $helper_wp_tools = WYSIJA::get('wp_tools','helper');
2581
+ $this->data['categories'] = $helper_wp_tools->get_categories();
2582
+
2583
+ // max number of posts
2584
+ $this->data['post_limits'] = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 50);
2585
+
2586
+ $this->data['params'] = $params;
2587
+
2588
+ return $this->popupContent();
2589
+ }
2590
+
2591
+ function image_data() {
2592
+ $this->data['url'] = (isset($_GET['url']) && $_GET['url'] !== '') ? trim(urldecode($_GET['url'])) : null;
2593
+ $this->data['alt'] = (isset($_GET['alt'])) ? trim(urldecode($_GET['alt'])) : '';
2594
+
2595
+ $this->iframeTabs = array('image_data' => __("Image Parameters", WYSIJA));
2596
+ $_GET['tab'] = 'image_data';
2597
+ return $this->popupContent();
2598
+ }
2599
+
2600
+ function medias() {
2601
+ $this->popupContent();
2602
+ }
2603
+
2604
+ function special_wysija_browse() {
2605
+ $this->_wysija_subaction();
2606
+ $this->jsTrans['deleteimg'] = __('Delete image for all newsletters?', WYSIJA);
2607
+ return wp_iframe(array($this->viewObj, 'popup_wysija_browse'), array());
2608
+ }
2609
+
2610
+ function special_wordp_browse() {
2611
+ $this->_wysija_subaction();
2612
+ $this->jsTrans['deleteimg'] = __('This image might be in an article. Delete anyway?', WYSIJA);
2613
+ return wp_iframe(array($this->viewObj, 'popup_wp_browse'), array());
2614
+ }
2615
+
2616
+ function _wysija_subaction() {
2617
+
2618
+ if (isset($_REQUEST['subaction'])) {
2619
+ if ($_REQUEST['subaction'] === 'delete') {
2620
+ if (isset($_REQUEST['imgid']) && (int) $_REQUEST['imgid'] > 0) {
2621
+ /* delete the image with id imgid */
2622
+ $res = wp_delete_attachment((int) $_REQUEST['imgid'], true);
2623
+ if ($res) {
2624
+ $this->notice(__('Image has been deleted.', WYSIJA));
2625
+ }
2626
+ }
2627
+ }
2628
+ }
2629
+ return true;
2630
+ }
2631
+
2632
+ function special_new_wordp_upload() {
2633
+
2634
+ //wp_enqueue_script('plupload-all');
2635
+ wp_enqueue_script('wysija-plupload-handlers', WYSIJA_URL . 'js/jquery/pluploadHandler.js', array('plupload-all', 'jquery'));
2636
+ $uploader_l10n = array(
2637
+ 'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
2638
+ 'file_exceeds_size_limit' => __('%s exceeds the maximum upload size for this site.'),
2639
+ 'zero_byte_file' => __('This file is empty. Please try another.'),
2640
+ 'invalid_filetype' => __('This file type is not allowed. Please try another.'),
2641
+ 'not_an_image' => __('This file is not an image. Please try another.'),
2642
+ 'image_memory_exceeded' => __('Memory exceeded. Please try another smaller file.'),
2643
+ 'image_dimensions_exceeded' => __('This is larger than the maximum size. Please try another.'),
2644
+ 'default_error' => __('An error occurred in the upload. Please try again later.'),
2645
+ 'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
2646
+ 'upload_limit_exceeded' => __('You may only upload 1 file.'),
2647
+ 'http_error' => __('HTTP error.'),
2648
+ 'upload_failed' => __('Upload failed.'),
2649
+ 'big_upload_failed' => __('Please try uploading this file with the %1$sbrowser uploader%2$s.'),
2650
+ 'big_upload_queued' => __('%s exceeds the maximum upload size for the multi-file uploader when used in your browser.'),
2651
+ 'io_error' => __('IO error.'),
2652
+ 'security_error' => __('Security error.'),
2653
+ 'file_cancelled' => __('File canceled.'),
2654
+ 'upload_stopped' => __('Upload stopped.'),
2655
+ 'dismiss' => __('Dismiss'),
2656
+ 'crunching' => __('Crunching&hellip;'),
2657
+ 'deleted' => __('moved to the trash.'),
2658
+ 'error_uploading' => __('&#8220;%s&#8221; has failed to upload.')
2659
+ );
2660
+
2661
+ wp_localize_script('wysija-plupload-handlers', 'pluploadL10n', $uploader_l10n);
2662
+
2663
+ wp_enqueue_script('image-edit');
2664
+ wp_enqueue_script('set-post-thumbnail');
2665
+ wp_enqueue_style('imgareaselect');
2666
+ wp_enqueue_script('media-gallery');
2667
+
2668
+ /* wp_register_style('myplupload', '/adjust-this-url/myplupload.css');
2669
+ wp_enqueue_style('myplupload'); */
2670
+
2671
+
2672
+ $errors = array();
2673
+ return wp_iframe(array($this->viewObj, 'popup_new_wp_upload'), $errors);
2674
+ }
2675
+
2676
+ function special_wordp_upload() {
2677
+
2678
+ wp_enqueue_script('swfupload-all');
2679
+ wp_enqueue_script('swfupload-handlers');
2680
+ wp_enqueue_script('wysija-upload-handlers', WYSIJA_URL . "js/jquery/uploadHandlers.js");
2681
+ wp_enqueue_script('image-edit');
2682
+ wp_enqueue_script('set-post-thumbnail');
2683
+ wp_enqueue_style('imgareaselect');
2684
+
2685
+ $errors = array();
2686
+ $id = 0;
2687
+ if (isset($_GET['flash']))
2688
+ $_GET['flash'] = 1;
2689
+ if (isset($_POST['html-upload']) && !empty($_FILES)) {
2690
+ // Upload File button was clicked
2691
+ $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
2692
+ unset($_FILES);
2693
+ if (is_wp_error($id)) {
2694
+ $errors['upload_error'] = $id;
2695
+ $id = false;
2696
+ }
2697
+ }
2698
+
2699
+ if (!empty($_POST['insertonlybutton'])) {
2700
+ $href = $_POST['insertonly']['href'];
2701
+ if (!empty($href) && !strpos($href, '://'))
2702
+ $href = "http://$href";
2703
+
2704
+ $title = esc_attr($_POST['insertonly']['title']);
2705
+ if (empty($title))
2706
+ $title = basename($href);
2707
+ if (!empty($title) && !empty($href))
2708
+ $html = "<a href='" . esc_url($href) . "' >$title</a>";
2709
+ $html = apply_filters('file_send_to_editor_url', $html, esc_url_raw($href), $title);
2710
+ return media_send_to_editor($html);
2711
+ }
2712
+
2713
+ if (!empty($_POST)) {
2714
+ $return = media_upload_form_handler();
2715
+
2716
+ if (is_string($return))
2717
+ return $return;
2718
+ if (is_array($return))
2719
+ $errors = $return;
2720
+ }
2721
+
2722
+ if (isset($_POST['save'])) {
2723
+ $errors['upload_notice'] = __('Saved.', WYSIJA);
2724
+ return media_upload_gallery();
2725
+ }
2726
+
2727
+
2728
+ return wp_iframe(array($this->viewObj, 'popup_wp_upload'), $errors);
2729
+ }
2730
+
2731
+ function _checkEmailExists($emailId) {
2732
+ $result = false;
2733
+ $modelEmail = WYSIJA::get('email', 'model');
2734
+ if ($modelEmail->exists(array('email_id' => $emailId)))
2735
+ $result = true;
2736
+
2737
+ if (!$result) {
2738
+ $this->error(__("The newsletter doesn't exist.", WYSIJA), 1);
2739
+ $this->redirect('admin.php?page=wysija_campaigns');
2740
+ }
2741
+ else
2742
+ return true;
2743
+ }
 
 
 
 
 
 
2744
 
2745
  }
controllers/back/config.php CHANGED
@@ -18,7 +18,7 @@ class WYSIJA_control_back_config extends WYSIJA_control_back{
18
  $this->jsTrans['bounceconnect'] = __('Bounce handling connection test', WYSIJA);
19
  $this->jsTrans['processbounceT'] = __('Bounce handling processing', WYSIJA);
20
  $this->jsTrans['doubleoptinon'] = __('Subscribers will now need to activate their subscription by email in order to receive your newsletters. This is recommended.', WYSIJA);
21
- $this->jsTrans['doubleoptinoff'] = __('Unconfirmed subscribers will receive your newsletters from now on without the need to activate their subscriptions.', WYSIJA);
22
  $this->jsTrans['processbounce'] = __('Process bounce handling now!', WYSIJA);
23
  $this->jsTrans['errorbounceforward'] = __('When setting up the bounce system, you need to have a different address for the bounce email and the forward to address', WYSIJA);
24
 
@@ -29,6 +29,9 @@ class WYSIJA_control_back_config extends WYSIJA_control_back{
29
  case 'log':
30
  case 'save':
31
  case 'clearlog':
 
 
 
32
  wp_enqueue_script('wysija-config-settings', WYSIJA_URL.'js/admin-config-settings.js', array('wysija-admin-js-global'), WYSIJA::get_version());
33
  wp_localize_script('wysija-config-settings', 'mpEmailCheck', WJ_Utils::get_tip_data());
34
  wp_enqueue_script('jquery-cookie', WYSIJA_URL.'js/jquery/jquery.cookie.js', array('jquery'), WYSIJA::get_version());
@@ -59,9 +62,9 @@ class WYSIJA_control_back_config extends WYSIJA_control_back{
59
  return;
60
  break;
61
  default:
62
- wp_enqueue_script( 'mailpoet.tooltip', WYSIJA_URL . 'js/vendor/bootstrap.tooltip.js', array( 'jquery' ), WYSIJA::get_version(), true );
63
- wp_enqueue_style( 'mailpoet.tooltip', WYSIJA_URL . 'css/vendor/bootstrap.tooltip.css', array(), WYSIJA::get_version(), 'screen' );
64
- wp_enqueue_script('wysija-config-settings', WYSIJA_URL.'js/admin-config-settings.js', array('wysija-admin-js-global'), WYSIJA::get_version(), true);
65
  wp_localize_script('wysija-config-settings', 'mpEmailCheck', WJ_Utils::get_tip_data());
66
  wp_enqueue_script('jquery-cookie', WYSIJA_URL.'js/jquery/jquery.cookie.js', array('jquery'), WYSIJA::get_version());
67
  }
@@ -254,7 +257,7 @@ class WYSIJA_control_back_config extends WYSIJA_control_back{
254
  $this->js[]='wysija-admin-ajax-proto';
255
  // $this->js[]='wysija-admin-ajax';
256
  $this->js[]='wysija-base-script-64';
257
- $this->js[] = 'mailpoet-select2';
258
 
259
  // make sure the editor content is not cached
260
  //header('Cache-Control: no-cache, max-age=0, must-revalidate, no-store'); // HTTP/1.1
18
  $this->jsTrans['bounceconnect'] = __('Bounce handling connection test', WYSIJA);
19
  $this->jsTrans['processbounceT'] = __('Bounce handling processing', WYSIJA);
20
  $this->jsTrans['doubleoptinon'] = __('Subscribers will now need to activate their subscription by email in order to receive your newsletters. This is recommended.', WYSIJA);
21
+ $this->jsTrans['doubleoptinoff'] = __('Unconfirmed subscribers will receive your newslettters from now on without the need to activate their subscriptions.', WYSIJA);
22
  $this->jsTrans['processbounce'] = __('Process bounce handling now!', WYSIJA);
23
  $this->jsTrans['errorbounceforward'] = __('When setting up the bounce system, you need to have a different address for the bounce email and the forward to address', WYSIJA);
24
 
29
  case 'log':
30
  case 'save':
31
  case 'clearlog':
32
+
33
+ wp_enqueue_script('jquery-qtip', WYSIJA_URL.'js/qtip2/jquery.qtip.min.js', array('jquery'), WYSIJA::get_version());
34
+ wp_enqueue_style('jquery-qtip-css', WYSIJA_URL.'css/qtip2/jquery.qtip.min.css');
35
  wp_enqueue_script('wysija-config-settings', WYSIJA_URL.'js/admin-config-settings.js', array('wysija-admin-js-global'), WYSIJA::get_version());
36
  wp_localize_script('wysija-config-settings', 'mpEmailCheck', WJ_Utils::get_tip_data());
37
  wp_enqueue_script('jquery-cookie', WYSIJA_URL.'js/jquery/jquery.cookie.js', array('jquery'), WYSIJA::get_version());
62
  return;
63
  break;
64
  default:
65
+ wp_enqueue_script( 'jquery-qtip', WYSIJA_URL.'js/qtip2/jquery.qtip.min.js', array('jquery'), WYSIJA::get_version());
66
+ wp_enqueue_style('jquery-qtip-css', WYSIJA_URL.'css/qtip2/jquery.qtip.min.css');
67
+ wp_enqueue_script('wysija-config-settings', WYSIJA_URL.'js/admin-config-settings.js', array('wysija-admin-js-global', 'jquery-qtip'), WYSIJA::get_version());
68
  wp_localize_script('wysija-config-settings', 'mpEmailCheck', WJ_Utils::get_tip_data());
69
  wp_enqueue_script('jquery-cookie', WYSIJA_URL.'js/jquery/jquery.cookie.js', array('jquery'), WYSIJA::get_version());
70
  }
257
  $this->js[]='wysija-admin-ajax-proto';
258
  // $this->js[]='wysija-admin-ajax';
259
  $this->js[]='wysija-base-script-64';
260
+ $this->js[] = 'wysija-chosen-proto';
261
 
262
  // make sure the editor content is not cached
263
  //header('Cache-Control: no-cache, max-age=0, must-revalidate, no-store'); // HTTP/1.1
controllers/back/statistics.php CHANGED
@@ -1,197 +1,176 @@
1
  <?php
 
2
  defined('WYSIJA') or die('Restricted access');
3
  require_once(WYSIJA_CORE.'module'.DS.'statistics.php'); // @todo
4
 
5
- class WYSIJA_control_back_statistics extends WYSIJA_control_back
6
- {
7
-
8
- /**
9
- * Main model of this controller
10
- * @var string
11
- */
12
- public $model = 'statistics';
13
-
14
- /**
15
- * Main view of this controller
16
- * @var string
17
- */
18
- public $view = 'statistics';
19
-
20
- /**
21
- * Base URL of all requests
22
- * @var string
23
- */
24
- public $base_url = 'admin.php';
25
-
26
- /**
27
- * Load blocks at a same time (FALSE) or one by one (TRUE)
28
- * @var TRUE
29
- */
30
- protected $lazy_load = true;
31
-
32
- /**
33
- * list of pre-defined dates
34
- * @var Array
35
- */
36
- protected $pre_defined_dates = array( );
37
-
38
- protected $date_format = 'Y/m/d';
39
-
40
- protected $js_date_format = 'yy/mm/dd';
41
-
42
- /**
43
- * Constructor
44
- */
45
- function WYSIJA_control_back_statistics()
46
- {
47
-
48
- }
49
-
50
- public function defaultDisplay()
51
- {
52
- $this->pre_defined_dates = $this->get_pre_defined_dates();
53
- // Define view
54
- $this->viewShow = $this->action = 'main';
55
- $this->js['jquery.core'] = 'jquery/ui/jquery.ui.core';
56
- $this->js['jquery.datepicker'] = 'jquery/ui/jquery.ui.datepicker';
57
- $this->js['wysijalazyload'] = 'wysija-lazyload';
58
- $this->js['admin-statistics-filter'] = 'admin-statistics-filter';
59
- wp_enqueue_style('jquery.core', WYSIJA_URL.'css/jquery/ui/themes/base/jquery.ui.core.min.css', array( ), WYSIJA::get_version());
60
- wp_enqueue_style('jquery.core', WYSIJA_URL.'css/jquery/ui/themes/base/jquery.ui.theme.min.css', array( ), WYSIJA::get_version());
61
-
62
- // date filter
63
- $default_duration = $this->get_default_duration();
64
- if (function_exists('date_diff'))
65
- {
66
- $this->data['date_interval'] = date_diff(date_create($default_duration['from']), date_create($default_duration['to']));
67
- }
68
- else
69
- {
70
- $duration = strtotime($default_duration['to']) - strtotime($default_duration['from']);
71
- $helper_toolbox = WYSIJA::get('toolbox', 'helper');
72
- $this->data['date_interval'] = (object)$helper_toolbox->convert_seconds_to_array($duration, false);
73
- }
74
-
75
- $this->data['custom_dates'] = $this->pre_defined_dates;
76
- $this->data['default_duration'] = $default_duration;
77
- $this->data['js_date_format'] = $this->js_date_format;
78
-
79
- // Process and push data into view
80
- $this->data['lazy_load'] = $this->lazy_load;
81
- $hook_name = 'hook_stats';
82
- $hook_params = array( );
83
- $hook_params['top'] = WYSIJA_module_statistics::DEFAULT_TOP_RECORDS;
84
- $hook_params['from'] = !empty($_REQUEST['filter']['from']) ? $_REQUEST['filter']['from'] : $default_duration['from'];
85
- $hook_params['to'] = !empty($_REQUEST['filter']['to']) ? $_REQUEST['filter']['to'] : $default_duration['to'];
86
- $hook_params['group_by'] = ($this->data['date_interval']->days == 0 || $this->data['date_interval']->days > WYSIJA_module_statistics::SWITCHING_DATE_TO_MONTH_THRESHOLD) ?
87
- WYSIJA_module_statistics::GROUP_BY_MONTH :
88
- WYSIJA_module_statistics::GROUP_BY_DATE; // $this->data['date_interval']->days == 0, means, no begin date, no end date
89
-
90
- // Hack!
91
- $_REQUEST['limit_pp'] = $hook_params['top'];// Pagination, mark current selected value
92
-
93
- $modules = WYSIJA_module::get_modules_from_hook($hook_name);
94
- $this->data['modules'] = $modules;
95
- $this->data['lazy_load_modules'] = array( );
96
- $this->data['first_module'] = '';
97
-
98
- if (!$this->lazy_load)
99
- {
100
- $this->data['hooks'][$hook_name] = apply_filters('hook_stats', '', $hook_params);
101
- }
102
- else
103
- {
104
- if (!empty($modules))
105
- {
106
- $first_module = array_shift($modules);
107
- // List of lazy loaded modules
108
- $this->data['lazy_load_modules'] = $modules;
109
-
110
- // Evenly we are lazy loading, we always load the first module by default
111
- $this->data['first_module'] = apply_filters('custom_module_hook', '', $first_module, $hook_name, $hook_params);
112
- }
113
- }
114
- }
115
-
116
- /**
117
- * get pre defined dates (duration)
118
- * @return type
119
- */
120
- protected function get_pre_defined_dates()
121
- {
122
- return array(
123
- array(
124
- 'value' => 7,
125
- 'label' => __('Last 7 days', WYSIJA),
126
- 'selected' => false,
127
- 'from' => date($this->date_format, strtotime('-7 days')),
128
- 'to' => date($this->date_format, strtotime('tomorrow'))
129
- ),
130
- array(
131
- 'value' => 'last_month',
132
- 'label' => __('Last month', WYSIJA),
133
- 'selected' => false,
134
- 'from' => date($this->date_format, mktime(0, 0, 0, date('m')-1, 1, date('Y'))),
135
- 'to' => date($this->date_format, mktime(0, 0, 0, date('m'), 0, date('Y')))
136
-
137
-
138
- ),
139
- array(
140
- 'value' => 30,
141
- 'label' => __('Last 30 days', WYSIJA),
142
- 'selected' => false,
143
- 'from' => date($this->date_format, strtotime('-30 days')),
144
- 'to' => date($this->date_format, strtotime('tomorrow'))
145
- ),
146
- array(
147
- 'value' => 90,
148
- 'label' => __('Last 90 days', WYSIJA),
149
- 'selected' => true,
150
- 'from' => date($this->date_format, strtotime('-90 days')),
151
- 'to' => date($this->date_format, strtotime('tomorrow'))
152
- ),
153
- array(
154
- 'value' => 180,
155
- 'label' => __('Last 180 days', WYSIJA),
156
- 'selected' => false,
157
- 'from' => date($this->date_format, strtotime('-180 days')),
158
- 'to' => date($this->date_format, strtotime('tomorrow'))
159
- ),
160
- array(
161
- 'value' => 365,
162
- 'label' => __('Last 365 days', WYSIJA),
163
- 'selected' => false,
164
- 'from' => date($this->date_format, strtotime('-365 days')),
165
- 'to' => date($this->date_format, strtotime('tomorrow'))
166
- ),
167
- array(
168
- 'value' => 0,
169
- 'label' => __('Custom dates', WYSIJA),
170
- 'selected' => false,
171
- 'from' => '',
172
- 'to' => ''
173
- ),
174
- );
175
  }
176
-
177
- /**
178
- * Get default duration of stats
179
- * @return int
180
- */
181
- protected function get_default_duration()
182
- {
183
- foreach ($this->pre_defined_dates as $duration)
184
- if (isset($duration['selected']) && $duration['selected'])
185
- return $duration;
186
- return end($this->pre_defined_dates);
187
  }
188
-
189
- function date_diff($time_start, $time_end)
190
- {
191
- $result = null;
192
- $duration = $time_end - $time_start;
193
- $result->days = floor($duration / (60 * 60 * 24));
194
- return $result;
195
- }
196
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  }
1
  <?php
2
+
3
  defined('WYSIJA') or die('Restricted access');
4
  require_once(WYSIJA_CORE.'module'.DS.'statistics.php'); // @todo
5
 
6
+ class WYSIJA_control_back_statistics extends WYSIJA_control_back {
7
+
8
+ /**
9
+ * Main model of this controller
10
+ * @var string
11
+ */
12
+ public $model = 'statistics';
13
+
14
+ /**
15
+ * Main view of this controller
16
+ * @var string
17
+ */
18
+ public $view = 'statistics';
19
+
20
+ /**
21
+ * Base URL of all requests
22
+ * @var string
23
+ */
24
+ public $base_url = 'admin.php';
25
+
26
+ /**
27
+ * Load blocks at a same time (FALSE) or one by one (TRUE)
28
+ * @var TRUE
29
+ */
30
+ protected $lazy_load = true;
31
+
32
+ /**
33
+ * list of pre-defined dates
34
+ * @var Array
35
+ */
36
+ protected $pre_defined_dates = array();
37
+ protected $date_format = 'Y/m/d';
38
+ protected $js_date_format = 'yy/mm/dd';
39
+
40
+ /**
41
+ * Constructor
42
+ */
43
+ function WYSIJA_control_back_statistics() {}
44
+
45
+ public function defaultDisplay() {
46
+ $this->pre_defined_dates = $this->get_pre_defined_dates();
47
+ // Define view
48
+ $this->viewShow = $this->action = 'main';
49
+ $this->js['jquery.core'] = 'jquery/ui/jquery.ui.core';
50
+ $this->js['jquery.datepicker'] = 'jquery/ui/jquery.ui.datepicker';
51
+ $this->js['wysijalazyload'] = 'wysija-lazyload';
52
+ $this->js['admin-statistics-filter'] = 'admin-statistics-filter';
53
+ wp_enqueue_style('jquery.core', WYSIJA_URL.'css/jquery/ui/themes/base/jquery.ui.core.min.css', array(), WYSIJA::get_version());
54
+ wp_enqueue_style('jquery.core', WYSIJA_URL.'css/jquery/ui/themes/base/jquery.ui.theme.min.css', array(), WYSIJA::get_version());
55
+
56
+ // date filter
57
+ $default_duration = $this->get_default_duration();
58
+ if( function_exists('date_diff')){
59
+ $this->data['date_interval'] = date_diff(date_create($default_duration['from']), date_create($default_duration['to']));
60
+ }else{
61
+ $duration = strtotime($default_duration['to']) - strtotime($default_duration['from']);
62
+ $helper_toolbox = WYSIJA::get('toolbox' , 'helper');
63
+ $this->data['date_interval'] = (object)$helper_toolbox->convert_seconds_to_array($duration , false);
64
+ }
65
+
66
+ $this->data['custom_dates'] = $this->pre_defined_dates;
67
+ $this->data['default_duration'] = $default_duration;
68
+ $this->data['js_date_format'] = $this->js_date_format;
69
+
70
+ // Process and push data into view
71
+ $this->data['lazy_load'] = $this->lazy_load;
72
+ $hook_name = 'hook_stats';
73
+ $hook_params = array();
74
+ $hook_params['top'] = WYSIJA_module_statistics::DEFAULT_TOP_RECORDS;
75
+ $hook_params['from'] = !empty($_REQUEST['filter']['from']) ? $_REQUEST['filter']['from'] : $default_duration['from'];
76
+ $hook_params['to'] = !empty($_REQUEST['filter']['to']) ? $_REQUEST['filter']['to'] : $default_duration['to'];
77
+ $hook_params['group_by'] = ($this->data['date_interval']->days == 0 || $this->data['date_interval']->days > WYSIJA_module_statistics::SWITCHING_DATE_TO_MONTH_THRESHOLD) ?
78
+ WYSIJA_module_statistics::GROUP_BY_MONTH :
79
+ WYSIJA_module_statistics::GROUP_BY_DATE;// $this->data['date_interval']->days == 0, means, no begin date, no end date
80
+
81
+ $modules = WYSIJA_module::get_modules_from_hook($hook_name);
82
+ $this->data['modules'] = $modules;
83
+ $this->data['lazy_load_modules'] = array();
84
+ $this->data['first_module'] = '';
85
+
86
+ if (!$this->lazy_load) {
87
+ $this->data['hooks'][$hook_name] = apply_filters('hook_stats', '', $hook_params);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  }
89
+ else {
90
+ if (!empty($modules)) {
91
+ $first_module = array_shift($modules);
92
+ // List of lazy loaded modules
93
+ $this->data['lazy_load_modules'] = $modules;
94
+
95
+ // Evenly we are lazy loading, we always load the first module by default
96
+ $this->data['first_module'] = apply_filters('custom_module_hook', '', $first_module, $hook_name, $hook_params);
97
+ }
 
 
98
  }
99
+ }
100
+
101
+ /**
102
+ * get pre defined dates (duration)
103
+ * @return type
104
+ */
105
+ protected function get_pre_defined_dates() {
106
+ return array(
107
+ array(
108
+ 'value' => 7,
109
+ 'label' => __('Last 7 days', WYSIJA),
110
+ 'selected' => false,
111
+ 'from' => date($this->date_format, strtotime('-7 days')),
112
+ 'to' => date($this->date_format, strtotime('tomorrow'))
113
+ ),
114
+ array(
115
+ 'value' => 'last_month',
116
+ 'label' => __('Last month', WYSIJA),
117
+ 'selected' => false,
118
+ 'from' => date($this->date_format, strtotime('first day of previous month')),
119
+ 'to' => date($this->date_format, strtotime('last day of previous month'))
120
+ ),
121
+ array(
122
+ 'value' => 30,
123
+ 'label' => __('Last 30 days', WYSIJA),
124
+ 'selected' => false,
125
+ 'from' => date($this->date_format, strtotime('-30 days')),
126
+ 'to' => date($this->date_format, strtotime('tomorrow'))
127
+ ),
128
+ array(
129
+ 'value' => 90,
130
+ 'label' => __('Last 90 days', WYSIJA),
131
+ 'selected' => true,
132
+ 'from' => date($this->date_format, strtotime('-90 days')),
133
+ 'to' => date($this->date_format, strtotime('tomorrow'))
134
+ ),
135
+ array(
136
+ 'value' => 180,
137
+ 'label' => __('Last 180 days', WYSIJA),
138
+ 'selected' => false,
139
+ 'from' => date($this->date_format, strtotime('-180 days')),
140
+ 'to' => date($this->date_format, strtotime('tomorrow'))
141
+ ),
142
+ array(
143
+ 'value' => 365,
144
+ 'label' => __('Last 365 days', WYSIJA),
145
+ 'selected' => false,
146
+ 'from' => date($this->date_format, strtotime('-365 days')),
147
+ 'to' => date($this->date_format, strtotime('tomorrow'))
148
+ ),
149
+ array(
150
+ 'value' => 0,
151
+ 'label' => __('Custom dates', WYSIJA),
152
+ 'selected' => false,
153
+ 'from' => '',
154
+ 'to' => ''
155
+ ),
156
+ );
157
+ }
158
+
159
+ /**
160
+ * Get default duration of stats
161
+ * @return int
162
+ */
163
+ protected function get_default_duration() {
164
+ foreach ($this->pre_defined_dates as $duration)
165
+ if (isset($duration['selected']) && $duration['selected'])
166
+ return $duration;
167
+ return end($this->pre_defined_dates);
168
+ }
169
+
170
+ function date_diff($time_start,$time_end){
171
+ $result = null;
172
+ $duration = $time_end - $time_start;
173
+ $result->days = floor($duration/(60*60*24));
174
+ return $result;
175
+ }
176
  }
controllers/back/subscribers.php CHANGED
@@ -145,22 +145,6 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
145
  }
146
 
147
 
148
- /**
149
- * Get selected lists
150
- * @return array
151
- */
152
- protected function get_selected_lists() {
153
- $result = array();
154
- if (isset($_REQUEST['wysija']['filter']['filter_list'])) {
155
- $result[] = $_REQUEST['wysija']['filter']['filter_list'];
156
- } elseif (!empty($_REQUEST['filter-list'])) {
157
- $lists = explode(',', trim($_REQUEST['filter-list']));// currently, only single list is allowed.
158
- if (!empty($lists)) {
159
- $result = array_merge ($result, $lists);
160
- }
161
- }
162
- return $result;
163
- }
164
 
165
  function defaultDisplay(){
166
  $this->viewShow=$this->action='main';
@@ -190,7 +174,6 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
190
 
191
  // count the rows based on the filters
192
  $filters = $this->modelObj->detect_filters();
193
-
194
  $select = array( 'COUNT(DISTINCT([wysija]user.user_id)) as total_users', 'MAX([wysija]user.created_at) as max_create_at');
195
  $count_rows = $this->modelObj->get_subscribers( $select, $filters);
196
 
@@ -221,7 +204,6 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
221
 
222
  $this->data['current_counts'] = $this->modelObj->countRows;
223
  $this->data['show_batch_select'] = ($this->modelObj->limit >= $this->modelObj->countRows) ? false : true;
224
- $this->data['selected_lists'] = $this->get_selected_lists();
225
  $this->modelObj->reset();
226
 
227
 
@@ -363,7 +345,7 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
363
  $this->notice(sprintf(__('%1$s subscribers have been added to "%2$s".',WYSIJA),$this->_affected_rows,$result['name']));
364
  else
365
  $this->notice(sprintf(__('%1$s subscriber have been added to "%2$s".',WYSIJA),$this->_affected_rows,$result['name']));
366
- $this->redirect_after_bulk_action();
367
  }
368
 
369
  /**
@@ -389,23 +371,9 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
389
  $this->notice(sprintf(__('%1$s subscriber have been moved to "%2$s".',WYSIJA), $this->_affected_rows, $result['name']));
390
  }
391
 
392
- $this->redirect_after_bulk_action();
393
  }
394
 
395
- /**
396
- * After performing a bulk action, let's keep the current list filter
397
- */
398
- protected function redirect_after_bulk_action() {
399
- $filter_list = !empty($_REQUEST['wysija']['filter']['filter_list']) ? $_REQUEST['wysija']['filter']['filter_list'] : 0;
400
- if (empty($filter_list)) {// view all lists
401
- $this->redirect('admin.php?page=wysija_subscribers');
402
- } elseif (is_numeric($filter_list)) {
403
- $this->redirect('admin.php?page=wysija_subscribers&filter-list='.$filter_list);
404
- } else {// subscribers in no list
405
- $this->redirect('admin.php?page=wysija_subscribers&filter-list=orphaned');
406
- }
407
- }
408
-
409
  /**
410
  * Bulk action remove subscribers from all existing lists
411
  * @param type $data = array('list_id'=>?)
@@ -418,10 +386,10 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
418
  $helpU->removeFromLists(array(),$_POST['wysija']['user']['user_id']);
419
 
420
  if($this->_affected_rows > 1)
421
- $this->notice(sprintf(__('%1$s subscribers have been removed from all existing lists.',WYSIJA),$this->_affected_rows));
422
  else
423
- $this->notice(sprintf(__('%1$s subscriber have been removed from all existing lists.',WYSIJA),$this->_affected_rows));
424
- $this->redirect_after_bulk_action();
425
  }
426
 
427
  /**
@@ -441,8 +409,7 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
441
  $this->notice(sprintf(__('%1$s subscribers have been removed from "%2$s".',WYSIJA),$this->_affected_rows, $result['name']));
442
  else
443
  $this->notice(sprintf(__('%1$s subscriber have been removed from "%2$s".',WYSIJA),$this->_affected_rows, $result['name']));
444
-
445
- $this->redirect_after_bulk_action();
446
  }
447
 
448
  /**
@@ -459,7 +426,7 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
459
  $this->notice(sprintf(__('%1$s subscribers have been confirmed.',WYSIJA),$this->_affected_rows));
460
  else
461
  $this->notice(sprintf(__('%1$s subscriber have been confirmed.',WYSIJA),$this->_affected_rows));
462
- $this->redirect_after_bulk_action();
463
  }
464
 
465
  /**
@@ -974,7 +941,7 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
974
 
975
  // make sure the total count of subscribers is updated
976
  $helper_user->refreshUsers();
977
- $this->redirect_after_bulk_action();
978
  }
979
 
980
  /**
145
  }
146
 
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
 
149
  function defaultDisplay(){
150
  $this->viewShow=$this->action='main';
174
 
175
  // count the rows based on the filters
176
  $filters = $this->modelObj->detect_filters();
 
177
  $select = array( 'COUNT(DISTINCT([wysija]user.user_id)) as total_users', 'MAX([wysija]user.created_at) as max_create_at');
178
  $count_rows = $this->modelObj->get_subscribers( $select, $filters);
179
 
204
 
205
  $this->data['current_counts'] = $this->modelObj->countRows;
206
  $this->data['show_batch_select'] = ($this->modelObj->limit >= $this->modelObj->countRows) ? false : true;
 
207
  $this->modelObj->reset();
208
 
209
 
345
  $this->notice(sprintf(__('%1$s subscribers have been added to "%2$s".',WYSIJA),$this->_affected_rows,$result['name']));
346
  else
347
  $this->notice(sprintf(__('%1$s subscriber have been added to "%2$s".',WYSIJA),$this->_affected_rows,$result['name']));
348
+ $this->redirect('admin.php?page=wysija_subscribers&filter-list='.$data['listid']);
349
  }
350
 
351
  /**
371
  $this->notice(sprintf(__('%1$s subscriber have been moved to "%2$s".',WYSIJA), $this->_affected_rows, $result['name']));
372
  }
373
 
374
+ $this->redirect('admin.php?page=wysija_subscribers&filter-list='.$data['listid']);
375
  }
376
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377
  /**
378
  * Bulk action remove subscribers from all existing lists
379
  * @param type $data = array('list_id'=>?)
386
  $helpU->removeFromLists(array(),$_POST['wysija']['user']['user_id']);
387
 
388
  if($this->_affected_rows > 1)
389
+ $this->notice(sprintf(__('%1$s subscribers have been removed from all exising lists.',WYSIJA),$this->_affected_rows));
390
  else
391
+ $this->notice(sprintf(__('%1$s subscriber have been removed from all exising lists.',WYSIJA),$this->_affected_rows));
392
+ $this->defaultDisplay();
393
  }
394
 
395
  /**
409
  $this->notice(sprintf(__('%1$s subscribers have been removed from "%2$s".',WYSIJA),$this->_affected_rows, $result['name']));
410
  else
411
  $this->notice(sprintf(__('%1$s subscriber have been removed from "%2$s".',WYSIJA),$this->_affected_rows, $result['name']));
412
+ $this->redirect('admin.php?page=wysija_subscribers&filter-list='.$data['listid']);
 
413
  }
414
 
415
  /**
426
  $this->notice(sprintf(__('%1$s subscribers have been confirmed.',WYSIJA),$this->_affected_rows));
427
  else
428
  $this->notice(sprintf(__('%1$s subscriber have been confirmed.',WYSIJA),$this->_affected_rows));
429
+ $this->defaultDisplay();
430
  }
431
 
432
  /**
941
 
942
  // make sure the total count of subscribers is updated
943
  $helper_user->refreshUsers();
944
+ $this->redirect();
945
  }
946
 
947
  /**
controllers/front/stats.php CHANGED
@@ -5,14 +5,6 @@ defined('WYSIJA') or die('Restricted access');
5
  class WYSIJA_control_front_stats extends WYSIJA_control_front{
6
  var $model='' ;
7
  var $view='';
8
-
9
- /**
10
- * Possible characters to be url encoded
11
- * @var array
12
- */
13
- protected $characters_to_encode = array(
14
- '@'
15
- );
16
 
17
  function WYSIJA_control_front_stats(){
18
  parent::WYSIJA_control_front();
@@ -27,30 +19,17 @@ class WYSIJA_control_front_stats extends WYSIJA_control_front{
27
 
28
  $WJ_Stats = new WJ_Stats();
29
  if(!empty($WJ_Stats->clicked_url)){
30
- // clicked stats
31
- $url = $this->encode_url($WJ_Stats->subscriber_clicked());
32
  do_action('mpoet_click_stats', $WJ_Stats);
33
  $this->redirect($url);
34
  }else{
35
- // opened stat
36
  $WJ_Stats->subscriber_opened();
37
  }
38
  }
39
 
40
  return true;
41
  }
42
-
43
- /**
44
- * Encode some special characters in url
45
- * @param string $url
46
- * @return string
47
- */
48
- protected function encode_url($url) {
49
- return str_replace(
50
- $this->characters_to_encode,
51
- array_map('urlencode', $this->characters_to_encode),
52
- $url
53
- );
54
- }
55
-
56
  }
5
  class WYSIJA_control_front_stats extends WYSIJA_control_front{
6
  var $model='' ;
7
  var $view='';
 
 
 
 
 
 
 
 
8
 
9
  function WYSIJA_control_front_stats(){
10
  parent::WYSIJA_control_front();
19
 
20
  $WJ_Stats = new WJ_Stats();
21
  if(!empty($WJ_Stats->clicked_url)){
22
+ //clicked stats
23
+ $url = $WJ_Stats->subscriber_clicked();
24
  do_action('mpoet_click_stats', $WJ_Stats);
25
  $this->redirect($url);
26
  }else{
27
+ //opened stat */
28
  $WJ_Stats->subscriber_opened();
29
  }
30
  }
31
 
32
  return true;
33
  }
34
+
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
core/base.php CHANGED
@@ -1,53 +1,47 @@
1
  <?php
2
  // Require constants.
3
- require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'constants.php' );
4
-
5
  // Require global classes autoloader
6
- require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'autoloader.php' );
7
-
8
- defined( 'WYSIJA' ) or die( 'Restricted access' );
9
 
10
- global $wysija_msg, $wysija_wpmsg;
11
- if ( ! $wysija_msg ) {
12
- $wysija_msg = array();
13
- }
14
- $wysija_wpmsg = array();
15
 
16
  class WYSIJA_object{
17
 
18
- /**
19
- * Static variable holding core MailPoet's version
20
- * @var array
21
- */
22
- static $version = '2.6.8';
23
-
24
  function WYSIJA_object(){
25
 
26
  }
27
 
28
  /**
29
- * Order an array by param name string compare
30
- *
31
- * @param array $a Array with the param to compare
32
- * @param array $b Array with the param to compare
33
- * @return int Sorting result from strcmp
34
  */
35
- public static function sort_by_name( $a, $b ){
36
- return strcmp( strtolower( $a['name'] ), strtolower( $b['name'] ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  }
38
 
39
- /**
40
- * Returns the version of based on a path
41
- *
42
- * @filter mailpoet/get_version
43
- * @filter mailpoet/package
44
- *
45
- * @param string $path
46
- * @return string Version of the package
47
- */
48
- public static function get_version( $path = null ) {
49
- return apply_filters( 'mailpoet/get_version', self::$version, apply_filters( 'mailpoet/package', 'core', $path ) );
50
- }
51
 
52
  /**
53
  * get the current_user data in a safe manner making sure a field exists before returning it's value
@@ -55,22 +49,16 @@ class WYSIJA_object{
55
  * @param string $field
56
  * @return mixed
57
  */
58
- public static function wp_get_userdata( $field = false ) {
59
  //WordPress globals be careful there
60
  global $current_user;
61
- if ( $field ) {
62
- if ( function_exists( 'get_currentuserinfo' ) ) {
63
- // Here is an exception because of one of the weirdest bug
64
- // the idea is to make sure we don't call get_currentuserinfo on the wysija_subscribers page when on a multisite
65
- if ( ! ( isset( $_GET['page'] ) && $_GET['page'] === 'wysija_subscribers' && is_multisite() ) ){
66
- get_currentuserinfo();
67
- }
68
- }
69
- if ( isset( $current_user->{$field} ) ){
70
- return $current_user->{$field};
71
- } elseif ( isset( $current_user->data->{$field} ) ){
72
- return $current_user->data->{$field};
73
- } else {
74
  return $current_user;
75
  }
76
  }
@@ -82,16 +70,14 @@ class WYSIJA_object{
82
  * @global array $wysija_wpmsg
83
  * @param type $msg
84
  */
85
- function wp_notice( $msg ){
86
  global $wysija_wpmsg;
87
 
88
  //add the hook only once
89
- if ( ! $wysija_wpmsg ) {
90
- add_action( 'admin_notices', array( $this, 'wp_msgs' ) );
91
- }
92
 
93
  //record msgs
94
- $wysija_wpmsg['updated'][] = $msg;
95
  }
96
 
97
  /**
@@ -99,16 +85,14 @@ class WYSIJA_object{
99
  * @global array $wysija_wpmsg
100
  * @param type $msg
101
  */
102
- function wp_error( $msg ){
103
  global $wysija_wpmsg;
104
 
105
  //add the hook only once
106
- if ( ! $wysija_wpmsg ){
107
- add_action( 'admin_notices', array( $this, 'wp_msgs' ) );
108
- }
109
 
110
  //record msgs
111
- $wysija_wpmsg['error'][] = $msg;
112
  }
113
 
114
  /**
@@ -119,15 +103,13 @@ class WYSIJA_object{
119
  */
120
  function wp_msgs() {
121
  global $wysija_wpmsg;
122
- foreach ( $wysija_wpmsg as $keymsg => $wp2 ){
123
- $msgs = '<div class="' . $keymsg . ' fade">';
124
- foreach ( $wp2 as $mymsg ){
125
- $msgs .= '<p><strong>MailPoet</strong> : ' . $mymsg . '</p>';
126
- }
127
- $msgs .= '</div>';
128
  }
129
 
130
- // This is bad, we should be checking for valid HTML here.
131
  echo $msgs;
132
  }
133
 
@@ -137,12 +119,10 @@ class WYSIJA_object{
137
  * @param boolean $public if set to true it will appear as a full message, otherwise it will appear behind a "Show more details." link
138
  * @param boolean $global if set to true it will appear on all of the backend interfaces, not only wysija's own
139
  */
140
- function error( $msg, $public = false, $global = false ){
141
- $status = 'error';
142
- if ( $global ){
143
- $status = 'g-' . $status;
144
- }
145
- $this->setInfo( $status, $msg, $public );
146
  }
147
 
148
  /**
@@ -151,12 +131,10 @@ class WYSIJA_object{
151
  * @param boolean $public if set to true it will appear as a full message, otherwise it will appear behind a "Show more details." link
152
  * @param boolean $global if set to true it will appear on all of the backend interfaces, not only wysija's own
153
  */
154
- function notice( $msg, $public = true, $global = false ){
155
  $status = 'updated';
156
- if ( $global ){
157
- $status = 'g-' . $status;
158
- }
159
- $this->setInfo( $status, $msg, $public );
160
  }
161
 
162
  /**
@@ -209,17 +187,16 @@ class WYSIJA_object{
209
 
210
 
211
  class WYSIJA_help extends WYSIJA_object{
212
- var $controller = null;
213
 
214
  static $admin_body_class_runner = false;
215
 
216
  function WYSIJA_help(){
217
- add_action( 'widgets_init', array( $this, 'widgets_init' ), 1 );
218
 
219
- // Only load this when ajax is not used
220
- if ( !( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
221
- add_action( 'init', array( $this, 'register_scripts' ), 1 );
222
  }
 
223
 
224
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
225
  add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
@@ -228,21 +205,17 @@ class WYSIJA_help extends WYSIJA_object{
228
  function widgets_init() {
229
  //load the widget file
230
  require_once(WYSIJA_WIDGETS.'wysija_nl.php');
231
- register_widget( 'WYSIJA_NL_Widget' );
232
  }
233
 
234
  public function admin_enqueue_scripts(){
235
- if ( WYSIJA_ITF ){
236
- wp_enqueue_script( 'mailpoet-global' );
237
- }
238
- wp_enqueue_style( 'mailpoet-dashicons' );
239
  }
240
 
241
  public function admin_body_class( $body_class_str ){
242
 
243
- if ( WYSIJA_help::$admin_body_class_runner === true ){
244
  return $body_class_str;
245
- }
246
 
247
  WYSIJA_help::$admin_body_class_runner = true;
248
 
@@ -259,8 +232,6 @@ class WYSIJA_help extends WYSIJA_object{
259
 
260
  if ( version_compare( $wp_version, '3.8', '<' ) ){
261
  $class[] = 'mp-menu-icon-bg';
262
- } else {
263
- $class[] = 'mpoet-ui';
264
  }
265
 
266
  return implode( ' ', $class );
@@ -269,42 +240,8 @@ class WYSIJA_help extends WYSIJA_object{
269
  function register_scripts(){
270
  $helper_toolbox = WYSIJA::get('toolbox','helper');
271
  $wp_language_code = $helper_toolbox->get_language_code();
272
- $valid_language = array(
273
- 'ar',
274
- 'ca',
275
- 'cs',
276
- 'cz',
277
- 'da',
278
- 'de',
279
- 'el',
280
- 'es',
281
- 'et',
282
- 'fa',
283
- 'fi',
284
- 'fr',
285
- 'he',
286
- 'hr',
287
- 'hu',
288
- 'id',
289
- 'it',
290
- 'ja',
291
- 'lt',
292
- 'nl',
293
- 'no',
294
- 'pl',
295
- 'pt',
296
- 'pt_BR',
297
- 'ro',
298
- 'ru',
299
- 'sv',
300
- 'tr',
301
- 'vi',
302
- 'zh_CN',
303
- 'zh_TW',
304
- );
305
-
306
 
307
- if ( in_array( $wp_language_code, $valid_language ) ) {
308
  wp_register_script('wysija-validator-lang',WYSIJA_URL.'js/validate/languages/jquery.validationEngine-'.$wp_language_code.'.js', array( 'jquery' ),WYSIJA::get_version(),true );
309
  }else{
310
  wp_register_script('wysija-validator-lang',WYSIJA_URL.'js/validate/languages/jquery.validationEngine-en.js', array( 'jquery' ),WYSIJA::get_version(),true );
@@ -318,7 +255,6 @@ class WYSIJA_help extends WYSIJA_object{
318
  wp_register_style('validate-engine-css',WYSIJA_URL.'css/validationEngine.jquery.css',array(),WYSIJA::get_version());
319
  wp_register_script('wysija-admin-ajax', WYSIJA_URL.'js/admin-ajax.js',array(),WYSIJA::get_version());
320
  wp_register_script('wysija-admin-ajax-proto', WYSIJA_URL.'js/admin-ajax-proto.js',array(),WYSIJA::get_version());
321
- wp_register_script( 'mailpoet-global', WYSIJA_URL.'js/admin-global.js', array( 'jquery', 'underscore' ), WYSIJA::get_version() );
322
 
323
  if(defined('WYSIJA_SIDE') && WYSIJA_SIDE=='front') wp_enqueue_style('validate-engine-css');
324
 
@@ -326,58 +262,43 @@ class WYSIJA_help extends WYSIJA_object{
326
 
327
 
328
  /**
329
- * All the ajax requests are routed through here
330
  */
331
  function ajax() {
332
 
333
- $result_array = array();
334
- if( !$_REQUEST || !isset( $_REQUEST['controller'] ) || !isset( $_REQUEST['task'] ) ){
335
- $result_array = array( 'result' => false );
336
  }else{
337
- $plugin_requesting_ajax = 'wysija-newsletters';
 
338
 
339
- // we override the plugin resquesting ajax if specified in the request
340
- if( isset( $_REQUEST['wysijaplugin'] ) ){
341
- $plugin_requesting_ajax = $_REQUEST['wysijaplugin'];
342
- }
343
 
344
- // fetching the right controller
345
- $this->controller = WYSIJA::get( $_REQUEST['controller'] , 'controller' , false, $plugin_requesting_ajax );
346
-
347
- // let's make sure the requested task exist
348
- if( method_exists( $this->controller , $_REQUEST['task'] ) ){
349
- $result_array['result'] = $this->controller->$_REQUEST['task']();
350
  }else{
351
- $this->error( 'Method "' . $_REQUEST['task'] . '" doesn\'t exist for controller : "'.$_REQUEST['controller'] );
352
  }
353
  }
354
 
355
- // get the appended messages triggerred during the task execution
356
- $result_array['msgs'] = $this->getMsgs();
357
 
358
- // this header will allow ajax request from the home domain, this can be a lifesaver when domain mapping is on
359
- if(function_exists('home_url')){
360
- header('Access-Control-Allow-Origin: '.home_url());
361
- }
362
 
363
- // let's encode our response in the json format
364
- $json_data = json_encode($result_array);
365
 
366
- // in some case scenarios our client will have jQuery forcing the jsonp so we need to adapt ourselves
367
  if(isset($_REQUEST['callback'])) {
368
- // special header for json-p
369
- header('Content-type: application/javascript');
370
-
371
- $helper_jsonp = WYSIJA::get('jsonp', 'helper');
372
- if($helper_jsonp->isValidCallback($_REQUEST['callback'])) {
373
- print $_REQUEST['callback'] . '('.$json_data.');';
374
- }
375
  } else {
376
- // standard header for unwrapped classic json response
377
- header('Content-type: application/json');
378
- print $json_data;
379
  }
380
- // our ajax response is printed, no need to let WordPress or 3rd party plugin execute more code
381
  die();
382
  }
383
  }
@@ -396,9 +317,9 @@ class WYSIJA extends WYSIJA_object{
396
  * @param boolean $simple
397
  * @return type
398
  */
399
- public static function get_permalink( $pageid, $params = array(), $simple = false ){
400
- $hWPtools = WYSIJA::get( 'wp_tools', 'helper' );
401
- return $hWPtools->get_permalink( $pageid, $params, $simple );
402
  }
403
 
404
  /**
@@ -407,13 +328,11 @@ class WYSIJA extends WYSIJA_object{
407
  * @param type $extendedplugin
408
  * @return boolean
409
  */
410
- public static function load_lang( $extendedplugin = false ){
411
  static $extensionloaded = false;
412
 
413
  //we return the entire array of extensions loaded if non is specified
414
- if ( ! $extendedplugin ) {
415
- return $extensionloaded;
416
- }
417
 
418
  //we only need to load this translation loader once on init
419
  if(!$extensionloaded){
@@ -456,9 +375,10 @@ class WYSIJA extends WYSIJA_object{
456
  //to allow wysija team members to work in english mode if debug is activated
457
  global $current_user;
458
 
459
- if((int)$debugmode > 0 && empty($current_user)) return true;
460
 
461
- if(isset($current_user->data->user_email) && (strpos($current_user->data->user_email, '@mailpoet.com') !== false)) {
 
462
  return true;
463
  }
464
  return false;
@@ -466,28 +386,16 @@ class WYSIJA extends WYSIJA_object{
466
 
467
  /**
468
  * this function exists just to fix the issue with qtranslate :/ (it only fix it partially)
469
- * @param type $extended_plugin
470
  */
471
- public static function load_lang_init($extended_plugin=false){
472
- $model_config = WYSIJA::get('config','model');
473
- $debug_mode = (int)$model_config->getValue('debug_new');
474
-
475
- if($debug_mode === 0 || ($debug_mode > 0 && WYSIJA::is_wysija_admin($debug_mode) === false)) {
476
- $extensions_loaded = WYSIJA::load_lang('get_all');
477
- foreach($extensions_loaded as $extended_plugin => $translation_string){
478
-
479
- // check for translation file overriding from transstring wp-content/languages/wysija-newsletters/wysija-newsletters-en_US.mo
480
- $filename = WP_CONTENT_DIR.DS.'languages'.DS.$extended_plugin.DS.$translation_string.'-'.get_locale().'.mo';
481
-
482
- if( !file_exists($filename) ){
483
- // get the translation file in our local file
484
- $filename = WYSIJA_PLG_DIR.$extended_plugin.DS.'languages'.DS.$translation_string.'-'.get_locale().'.mo';
485
- }
486
-
487
- // load the translation file with WP's load_textdomain
488
- if( file_exists( $filename ) ){
489
- load_textdomain( $translation_string, $filename );
490
- }
491
  }
492
  }
493
  }
@@ -1040,62 +948,37 @@ class WYSIJA extends WYSIJA_object{
1040
  $include_category_ids = array();
1041
  $exclude_category_ids = array();
1042
 
1043
- // ALC need to check for post_type on each block of the autoposts
1044
- $wj_data = maybe_unserialize( base64_decode( $email['wj_data'] ) );
1045
- $post_types = array();
1046
- $has_alc_blocks = false;
1047
-
1048
- foreach ( $wj_data['body'] as $block_key => $block ){
1049
- if ( $block['type'] !== 'auto-post' ){
1050
- continue;
1051
- }
1052
-
1053
- $has_alc_blocks = true;
1054
-
1055
- // get post type and post categories from block parameters
1056
- foreach( $block['params'] as $param_data ) {
1057
- if(in_array($param_data['key'], array('post_type', 'cpt')) && strlen(trim($param_data['value'])) > 0) {
1058
- // store post type
1059
- $post_types[] = trim($param_data['value']);
1060
- } else if($param_data['key'] === 'category_ids' && strlen(trim($param_data['value'])) > 0) {
1061
- // store post category ids
1062
- $include_category_ids = array_map('intval', explode(',', trim($param_data['value'])));
1063
- }
1064
- }
1065
  }
1066
-
1067
- if ( $has_alc_blocks === true && ! in_array( $post->post_type, $post_types ) ) {
1068
- continue;
1069
  }
1070
 
1071
  // get post categories
 
1072
  $helper_wp_tools = WYSIJA::get('wp_tools', 'helper');
1073
- $taxonomies = $helper_wp_tools->get_post_category_ids($post);
1074
 
1075
  // assume the post has to be sent
1076
  $do_send_post = true;
1077
 
1078
  // post categories have to match at least one of the email's included categories
1079
- $include_intersection = array_intersect($taxonomies, $include_category_ids);
1080
  if(!empty($include_category_ids) && empty($include_intersection)) {
1081
  $do_send_post = false;
1082
  }
1083
 
1084
- $exclude_intersection = array_intersect($taxonomies, $exclude_category_ids);
1085
  // post categories should not match any one of the email's excluded categories
1086
  if(!empty($exclude_category_ids) && !empty($exclude_intersection)) {
1087
  $do_send_post = false;
1088
  }
1089
 
1090
  if($do_send_post) {
1091
- WYSIJA::log('post_transition_hook_give_birth', array(
1092
- 'post_id' => $post->ID,
1093
- 'post_title' => $post->post_title,
1094
- 'newsletter' => $email,
1095
- 'old_status' => $old_status,
1096
- 'new_status' => $new_status
1097
- ),'post_notif');
1098
-
1099
  $model_email->reset();
1100
  $model_email->give_birth($email, $post->ID);
1101
  }
@@ -1444,7 +1327,7 @@ add_action('transition_post_status', array('WYSIJA', 'hook_postNotification_tran
1444
  add_action('delete_post', array('WYSIJA', 'hook_auto_newsletter_refresh'), 1, 1);
1445
 
1446
  // add image size for emails
1447
- add_image_size('wysija-newsletters-max', 600, 9999);
1448
 
1449
  $modelConf=WYSIJA::get('config','model');
1450
  if($modelConf->getValue('installed_time')){
1
  <?php
2
  // Require constants.
3
+ require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'constants.php');
 
4
  // Require global classes autoloader
5
+ require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'autoloader.php');
 
 
6
 
7
+ defined('WYSIJA') or die('Restricted access');
8
+ global $wysija_msg;
9
+ global $wysija_wpmsg;
10
+ if(!$wysija_msg) $wysija_msg=array();
11
+ $wysija_wpmsg=array();
12
 
13
  class WYSIJA_object{
14
 
 
 
 
 
 
 
15
  function WYSIJA_object(){
16
 
17
  }
18
 
19
  /**
20
+ * return a plugin version safely anywhere in any hook and stock it staticaly
21
+ * @staticvar array $versions
22
+ * @param string $plugin_name
23
+ * @return array|string
 
24
  */
25
+ public static function get_version($plugin_name=false) {
26
+ static $versions=array();
27
+ if(isset($versions[$plugin_name])) return $versions[$plugin_name];
28
+ if ( ! function_exists( 'get_plugins' ) ) {
29
+ if(file_exists(ABSPATH . 'wp-admin'.DS.'includes'.DS.'plugin.php')){
30
+ require_once( ABSPATH . 'wp-admin'.DS.'includes'.DS.'plugin.php' );
31
+ }
32
+ }
33
+ if (function_exists( 'get_plugins' ) ) {
34
+ if(!$plugin_name) $plugin_name='wysija-newsletters/index.php';
35
+ $plugin_file = WP_PLUGIN_DIR . DS . str_replace('/',DS,$plugin_name);
36
+ $plugin_data = get_plugin_data( $plugin_file );
37
+ $versions[$plugin_name] = $plugin_data['Version'];
38
+ }else{
39
+ $versions[$plugin_name]='undefined';
40
+ }
41
+ return $versions[$plugin_name];
42
  }
43
 
44
+
 
 
 
 
 
 
 
 
 
 
 
45
 
46
  /**
47
  * get the current_user data in a safe manner making sure a field exists before returning it's value
49
  * @param string $field
50
  * @return mixed
51
  */
52
+ public static function wp_get_userdata($field=false){
53
  //WordPress globals be careful there
54
  global $current_user;
55
+ if($field){
56
+ if(function_exists('get_currentuserinfo')) get_currentuserinfo();
57
+ if(isset($current_user->$field))
58
+ return $current_user->$field;
59
+ elseif(isset($current_user->data->$field))
60
+ return $current_user->data->$field;
61
+ else{
 
 
 
 
 
 
62
  return $current_user;
63
  }
64
  }
70
  * @global array $wysija_wpmsg
71
  * @param type $msg
72
  */
73
+ function wp_notice($msg){
74
  global $wysija_wpmsg;
75
 
76
  //add the hook only once
77
+ if(!$wysija_wpmsg) add_action('admin_notices', array($this,'wp_msgs'));
 
 
78
 
79
  //record msgs
80
+ $wysija_wpmsg['updated'][]=$msg;
81
  }
82
 
83
  /**
85
  * @global array $wysija_wpmsg
86
  * @param type $msg
87
  */
88
+ function wp_error($msg){
89
  global $wysija_wpmsg;
90
 
91
  //add the hook only once
92
+ if(!$wysija_wpmsg) add_action('admin_notices', array($this,'wp_msgs'));
 
 
93
 
94
  //record msgs
95
+ $wysija_wpmsg['error'][]=$msg;
96
  }
97
 
98
  /**
103
  */
104
  function wp_msgs() {
105
  global $wysija_wpmsg;
106
+ foreach($wysija_wpmsg as $keymsg => $wp2){
107
+ $msgs= '<div class="'.$keymsg.' fade">';
108
+ foreach($wp2 as $mymsg)
109
+ $msgs.= '<p><strong>MailPoet</strong> : '.$mymsg.'</p>';
110
+ $msgs.= '</div>';
 
111
  }
112
 
 
113
  echo $msgs;
114
  }
115
 
119
  * @param boolean $public if set to true it will appear as a full message, otherwise it will appear behind a "Show more details." link
120
  * @param boolean $global if set to true it will appear on all of the backend interfaces, not only wysija's own
121
  */
122
+ function error($msg,$public=false,$global=false){
123
+ $status='error';
124
+ if($global) $status='g-'.$status;
125
+ $this->setInfo($status,$msg,$public);
 
 
126
  }
127
 
128
  /**
131
  * @param boolean $public if set to true it will appear as a full message, otherwise it will appear behind a "Show more details." link
132
  * @param boolean $global if set to true it will appear on all of the backend interfaces, not only wysija's own
133
  */
134
+ function notice($msg,$public=true,$global=false){
135
  $status = 'updated';
136
+ if($global) $status='g-'.$status;
137
+ $this->setInfo($status,$msg,$public);
 
 
138
  }
139
 
140
  /**
187
 
188
 
189
  class WYSIJA_help extends WYSIJA_object{
190
+ var $controller=null;
191
 
192
  static $admin_body_class_runner = false;
193
 
194
  function WYSIJA_help(){
 
195
 
196
+ if(!defined('DOING_AJAX')){
197
+ add_action('init', array($this, 'register_scripts'), 1);
 
198
  }
199
+ add_action('widgets_init', array($this, 'widgets_init'), 1);
200
 
201
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
202
  add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
205
  function widgets_init() {
206
  //load the widget file
207
  require_once(WYSIJA_WIDGETS.'wysija_nl.php');
208
+ register_widget('WYSIJA_NL_Widget');
209
  }
210
 
211
  public function admin_enqueue_scripts(){
212
+ wp_enqueue_style('mailpoet-dashicons');
 
 
 
213
  }
214
 
215
  public function admin_body_class( $body_class_str ){
216
 
217
+ if ( WYSIJA_help::$admin_body_class_runner === true )
218
  return $body_class_str;
 
219
 
220
  WYSIJA_help::$admin_body_class_runner = true;
221
 
232
 
233
  if ( version_compare( $wp_version, '3.8', '<' ) ){
234
  $class[] = 'mp-menu-icon-bg';
 
 
235
  }
236
 
237
  return implode( ' ', $class );
240
  function register_scripts(){
241
  $helper_toolbox = WYSIJA::get('toolbox','helper');
242
  $wp_language_code = $helper_toolbox->get_language_code();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
 
244
+ if(file_exists(WYSIJA_DIR.'js'.DS.'validate'.DS.'languages'.DS.'jquery.validationEngine-'.$wp_language_code.'.js')){
245
  wp_register_script('wysija-validator-lang',WYSIJA_URL.'js/validate/languages/jquery.validationEngine-'.$wp_language_code.'.js', array( 'jquery' ),WYSIJA::get_version(),true );
246
  }else{
247
  wp_register_script('wysija-validator-lang',WYSIJA_URL.'js/validate/languages/jquery.validationEngine-en.js', array( 'jquery' ),WYSIJA::get_version(),true );
255
  wp_register_style('validate-engine-css',WYSIJA_URL.'css/validationEngine.jquery.css',array(),WYSIJA::get_version());
256
  wp_register_script('wysija-admin-ajax', WYSIJA_URL.'js/admin-ajax.js',array(),WYSIJA::get_version());
257
  wp_register_script('wysija-admin-ajax-proto', WYSIJA_URL.'js/admin-ajax-proto.js',array(),WYSIJA::get_version());
 
258
 
259
  if(defined('WYSIJA_SIDE') && WYSIJA_SIDE=='front') wp_enqueue_style('validate-engine-css');
260
 
262
 
263
 
264
  /**
265
+ * when doing an ajax request in admin this is the first place we come to
266
  */
267
  function ajax() {
268
 
269
+ $resultArray=array();
270
+ if(!$_REQUEST || !isset($_REQUEST['controller']) || !isset($_REQUEST['task'])){
271
+ $resultArray=array('result'=>false);
272
  }else{
273
+ $wysijapp='wysija-newsletters';
274
+ if(isset($_REQUEST['wysijaplugin'])) $wysijapp=$_REQUEST['wysijaplugin'];
275
 
276
+ $this->controller=WYSIJA::get($_REQUEST['controller'],'controller', false, $wysijapp);
 
 
 
277
 
278
+ if(method_exists($this->controller, $_REQUEST['task'])){
279
+ $resultArray['result']=$this->controller->$_REQUEST['task']();
 
 
 
 
280
  }else{
281
+ $this->error('Method "'.$_REQUEST['task'].'" doesn\'t exist for controller : "'.$_REQUEST['controller']);
282
  }
283
  }
284
 
285
+ $resultArray['msgs'] = $this->getMsgs();
 
286
 
287
+ //this header will allow ajax request from the home domain, this can be a lifesaver when domain mapping is on
288
+ if(function_exists('home_url')) header('Access-Control-Allow-Origin: '.home_url());
 
 
289
 
290
+ header('Content-type: application/json');
291
+ $jsonData = json_encode($resultArray);
292
 
293
+ //in some case scenario our client will have jquery forcing the jsonp so we need to adapt ourselves
294
  if(isset($_REQUEST['callback'])) {
295
+ $hJSONP = WYSIJA::get('jsonp', 'helper');
296
+ if($hJSONP->isValidCallback($_REQUEST['callback'])) {
297
+ print $_REQUEST['callback'] . '('.$jsonData.');';
298
+ }
 
 
 
299
  } else {
300
+ print $jsonData;
 
 
301
  }
 
302
  die();
303
  }
304
  }
317
  * @param boolean $simple
318
  * @return type
319
  */
320
+ public static function get_permalink($pageid,$params=array(),$simple=false){
321
+ $hWPtools=WYSIJA::get('wp_tools','helper');
322
+ return $hWPtools->get_permalink($pageid,$params,$simple);
323
  }
324
 
325
  /**
328
  * @param type $extendedplugin
329
  * @return boolean
330
  */
331
+ public static function load_lang($extendedplugin=false){
332
  static $extensionloaded = false;
333
 
334
  //we return the entire array of extensions loaded if non is specified
335
+ if(!$extendedplugin) return $extensionloaded;
 
 
336
 
337
  //we only need to load this translation loader once on init
338
  if(!$extensionloaded){
375
  //to allow wysija team members to work in english mode if debug is activated
376
  global $current_user;
377
 
378
+ if((int)$debugmode>0 && empty($current_user)) return true;
379
 
380
+ if(isset($current_user->data->user_email) &&
381
+ (strpos($current_user->data->user_email, '@mailpoet.com') !== false)) {
382
  return true;
383
  }
384
  return false;
386
 
387
  /**
388
  * this function exists just to fix the issue with qtranslate :/ (it only fix it partially)
389
+ * @param type $extendedplugin
390
  */
391
+ public static function load_lang_init($extendedplugin=false){
392
+ $config=WYSIJA::get('config','model');
393
+ $debugmode=(int)$config->getValue('debug_new');
394
+ if($debugmode==0 || ($debugmode>0 && !WYSIJA::is_wysija_admin($debugmode))){
395
+ $extensionloaded=WYSIJA::load_lang('get_all');
396
+ foreach($extensionloaded as $extendedplugin => $transstring){
397
+ $filename=WYSIJA_PLG_DIR.$extendedplugin.DS.'languages'.DS.$transstring.'-'.get_locale().'.mo';
398
+ if(file_exists($filename)) load_textdomain($transstring, $filename);
 
 
 
 
 
 
 
 
 
 
 
 
399
  }
400
  }
401
  }
948
  $include_category_ids = array();
949
  $exclude_category_ids = array();
950
 
951
+ // get included categories
952
+ if(isset($email['params']['autonl']['include_category_ids']) && !empty($email['params']['autonl']['include_category_ids'])) {
953
+ $include_category_ids = $email['params']['autonl']['include_category_ids'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
954
  }
955
+ // get excluded categories
956
+ if(isset($email['params']['autonl']['exclude_category_ids']) && !empty($email['params']['autonl']['exclude_category_ids'])) {
957
+ $exclude_category_ids = $email['params']['autonl']['exclude_category_ids'];
958
  }
959
 
960
  // get post categories
961
+ //$post_categories = wp_get_post_categories($post->ID);
962
  $helper_wp_tools = WYSIJA::get('wp_tools', 'helper');
963
+ $post_categories = $helper_wp_tools->get_post_category_ids($post);
964
 
965
  // assume the post has to be sent
966
  $do_send_post = true;
967
 
968
  // post categories have to match at least one of the email's included categories
969
+ $include_intersection = array_intersect($post_categories, $include_category_ids);
970
  if(!empty($include_category_ids) && empty($include_intersection)) {
971
  $do_send_post = false;
972
  }
973
 
974
+ $exclude_intersection = array_intersect($post_categories, $exclude_category_ids);
975
  // post categories should not match any one of the email's excluded categories
976
  if(!empty($exclude_category_ids) && !empty($exclude_intersection)) {
977
  $do_send_post = false;
978
  }
979
 
980
  if($do_send_post) {
981
+ WYSIJA::log('post_transition_hook_give_birth',array('postID'=>$post->ID,'postID'=>$post->post_title,'old_status'=>$old_status,'new_status'=>$new_status),'post_notif');
 
 
 
 
 
 
 
982
  $model_email->reset();
983
  $model_email->give_birth($email, $post->ID);
984
  }
1327
  add_action('delete_post', array('WYSIJA', 'hook_auto_newsletter_refresh'), 1, 1);
1328
 
1329
  // add image size for emails
1330
+ add_image_size('wysija-newsletters-max', 600, 99999);
1331
 
1332
  $modelConf=WYSIJA::get('config','model');
1333
  if($modelConf->getValue('installed_time')){
core/model.php CHANGED
@@ -2,1033 +2,1037 @@
2
  defined('WYSIJA') or die('Restricted access');
3
  class WYSIJA_model extends WYSIJA_object{
4
 
5
- var $table_prefix='wysija';
6
- var $table_name='';
7
- var $pk='';
8
- var $values=array();
9
- var $conditions=array();
10
- var $orderby=array();
11
- var $groupby=false;
12
- var $noCheck =false;
13
- var $replaceQRY=false;
14
- var $limitON=false;
15
- var $dbg=false;
16
- var $colCheck=true;
17
- var $getFormat=ARRAY_A;
18
- var $getOne=false;
19
- var $fieldValid=true;
20
- var $specialUpdate=false;
21
- var $escapeFields=array();
22
- var $escapingOn=false;
23
- var $tableWP=false;
24
- var $columns=array();
25
- var $joins=array();
26
- var $ignore = false;
27
- var $sql_error = false;
28
- var $last_error = '';
29
- var $comparisonKeys = array('equal', 'notequal', 'like', 'greater', 'less', 'greater_eq', 'less_eq', 'is');
30
- var $time_start = 0;
31
- var $query_duration = 0;
32
-
33
- function WYSIJA_model($extensions=''){
34
- if(defined('WYSIJA_DBG') && WYSIJA_DBG>0) $this->dbg=true;
35
- global $wpdb;
36
- $this->wpprefix=$wpdb->prefix;
37
- if($extensions) $this->table_prefix=$extensions;
38
- //fix for radiokapi
39
- //$this->wpprefix=$wpdb->base_prefix;
40
- }
41
- /**
42
- * since we reuse the same objects accross the whole application
43
- * once in a while for instance between a delete and a select we need to reset the objects to update the conditions
44
- */
45
- function reset(){
46
- $this->values = array();
47
- $this->conditions = array();
48
- $this->orderby = array();
49
- $this->groupby = false;
50
- $this->getFormat = ARRAY_A;
51
- $this->getOne = false;
52
- $this->limitON = false;
53
- $this->sql_error = false;
54
- $this->last_error = '';
55
- }
56
-
57
- /**
58
- *
59
- * @param type $columnsOrPKval
60
- * @param type $conditions
61
- * @return type
62
- */
63
- function get($columnsOrPKval=false,$conditions=array()){
64
- /*then columns becomes the pk value*/
65
- if(!$conditions){
66
- $conditions=array('equal'=>array($this->pk=>$columnsOrPKval));
67
- $columnsOrPKval=false;
68
- $this->noCheck=true;
69
- }
70
-
71
- /* if we pass just the id strong in the get conditions then it's the pk*/
72
- if($conditions && !is_array($conditions)){
73
- $conditions=array('equal'=>array($this->pk=>$conditions));
74
- }
75
- if($this->setConditions($conditions)){
76
- if($this->getOne) $results=$this->getRows($columnsOrPKval,0,1);
77
- else $results=$this->getRows($columnsOrPKval);
78
- //$this->escapeQuotesFromRes($results);
79
- if($this->getOne && count($results)==1){
80
- switch($this->getFormat){
81
- case ARRAY_A:
82
- foreach($results as $res)return $res;
83
- break;
84
- case OBJECT:
85
- foreach($results as $res)return $res;
86
- break;
87
- }
88
- }
89
- else return $results;
90
- }
91
-
92
- return false;
93
- }
94
-
95
- function getOne($columnsOrPKval=false,$conditions=array()){
96
- $this->getOne=true;
97
- $this->limitON=true;
98
-
99
- return $this->get($columnsOrPKval,$conditions);
100
- }
101
-
102
- /**
103
- * get a list of result based on a select query
104
- * @global type $wpdb
105
- * @param type $columns
106
- * @param type $page
107
- * @param type $limit
108
- * @return type
109
- */
110
- function getRows($columns=false,$page=0,$limit=false){
111
-
112
- /*set the columns*/
113
- if($columns){
114
- if(is_array($columns)){
115
- $columns=implode(', ',$columns);
116
- }
117
- }else $columns='*';
118
-
119
-
120
- $query='SELECT '.$columns.' FROM `'.$this->getSelectTableName()."`";
121
- $query.=$this->makeJoins();
122
- $query.=$this->makeWhere();
123
- $query.=$this->makeGroupBY();
124
- $query.=$this->makeOrderBY();
125
-
126
- if($this->limitON) $query.=$this->setLimit($page,$limit);
127
- $results=$this->query('get_res',$query,$this->getFormat);
128
-
129
- //$this->escapeQuotesFromRes($results);
130
-
131
- return $results;
132
- }
133
-
134
- function escapeQuotesFromRes(&$results){
135
- if(!$this->escapingOn) return false;
136
- foreach($results as $k =>$r){
137
-
138
- if(in_array($this->getFormat,array(ARRAY_A,ARRAY_N))){
139
- foreach($r as $k1 =>$v1){
140
- if(in_array($k1,$this->escapeFields)){
141
- $results[$k][$k1]= stripslashes($v1);
142
- }
143
- }
144
- }
145
- }
146
- }
147
-
148
- function setLimit($page=0,$limit=false){
149
- /*set the limit of the selection*/
150
-
151
- if(!$this->getOne){
152
- if($page==0){
153
- if(isset($_REQUEST['pagi'])){
154
- $page=(int)$_REQUEST['pagi'];
155
- if($page!=0) $page=$page-1;
156
- }
157
-
158
- }else $page=$page-1;
159
- }
160
-
161
- if(!$limit){
162
- if(isset($this->limit_pp)) $limit=$this->limit_pp;
163
- else{
164
- $config=WYSIJA::get('config','model');
165
- $limit=$config->getValue('limit_listing');
166
- }
167
- }
168
-
169
- $this->limit=(int)$limit;
170
- $this->page=$page;
171
- $this->limit_start=(int)($this->page*$this->limit);
172
- $this->limit_end=(int)($this->limit_start+$this->limit);
173
-
174
- return " LIMIT $this->limit_start , $this->limit";
175
- }
176
-
177
- /**
178
- * DEPRECATED
179
- * to have a custom query through the model and get the result immediately
180
- * @param type $query
181
- * @return type
182
- */
183
- function getResults($query,$type=ARRAY_A){
184
- return $this->query('get_res',$query, $type);
185
- }
186
-
187
- /**
188
- * to have a custom query through the model and get the result immediately
189
- * @param type $query
190
- * @return type
191
- */
192
- public function get_results($query,$type=ARRAY_A){
193
- return $this->getResults($query,$type);
194
- }
195
-
196
-
197
- function getSelectTableName(){
198
- if($this->joins && isset($this->joins['tablestart'])){
199
- if(isset($this->joins['prefstart'])) return $this->wpprefix.$this->joins['prefstart'].'_'.$this->joins['tablestart'];
200
- else return $this->getPrefix().$this->joins['tablestart'];
201
- }else return $this->getPrefix().$this->table_name;
202
- }
203
-
204
- /**
205
- * simple SQL count
206
- * @global type $wpdb
207
- * @return type
208
- */
209
- function count($query=false,$keygetcount=false){
210
- if(!$query){
211
- $groupBy=$this->makeGroupBY();
212
- $columnMore='';
213
- if($groupBy) $columnMore=','.$this->groupby;
214
- $query='SELECT COUNT('.$this->getPk().') as count '.$columnMore.' FROM `'.$this->getSelectTableName().'`';
215
- $query.=$this->makeJoins();
216
-
217
- $query.=$this->makeWhere();
218
- $query.=$groupBy;
219
- }
220
-
221
-
222
- // if dbg is on we track the duration of the query
223
- if($this->dbg){
224
- $this->timer_start();
225
- }
226
- $results=$this->query('get_res',$query,$this->getFormat);
227
-
228
- // if dbg is on we track the duration of the query
229
- if($this->dbg){
230
- $this->timer_stop();
231
- $this->keepQry('count');
232
- }
233
-
234
- if(!$results || count($results)>1) return $results;
235
- else {
236
- if($keygetcount) return $results[0][$keygetcount];
237
- else{
238
- foreach($results[0] as $key => $count) return $count;
239
- }
240
- }
241
-
242
-
243
- return $results;
244
- }
245
-
246
- /**
247
- * make the SQL WHERE condition string
248
- * @return string
249
- */
250
- function makeWhere(){
251
- $query='';
252
- if($this->conditions){
253
- /*set the WHERE clause*/
254
- $conditions=array();
255
- foreach($this->conditions as $type=>$values){
256
- if(!in_array($type, $this->comparisonKeys)){
257
- $conditionsss=$this->conditions;
258
- $this->conditions=array();
259
- $this->conditions['equal']=$conditionsss;
260
-
261
- break;
262
- }
263
- }
264
- foreach($this->conditions as $type=>$values){
265
- if($type=='like' && count($values)>1){
266
- if(is_array($values)){
267
- $total=count($values);
268
- $i=1;
269
- $likeCond='';
270
- foreach($values as $qfield => $qval){
271
- $likeCond.=$qfield." LIKE '%".esc_sql(addcslashes($qval, '%_' ))."%'";
272
- if($i<$total){
273
- $likeCond.=' OR ';
274
- }
275
- $i++;
276
- }
277
- $conditions[]='('.$likeCond.')';
278
- }
279
- continue;
280
- }
281
- foreach($values as $condK => $condVal){
282
-
283
- //secure from injections
284
- $this->_secureFieldVal($condK, $condVal);
285
-
286
- switch($type){
287
- case 'equal':
288
- if(is_array($condVal)){
289
- $conditions[]=$condK.' IN ("'.implode('","', $condVal).'")';
290
- }else{
291
- if(is_null($condVal)) {
292
- $conditions[] = $condK.' IS NULL';
293
- } else {
294
- if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
295
- $conditions[] = $condK.'='.$condVal;
296
- }
297
- }
298
- break;
299
- case 'notequal':
300
- if(is_array($condVal)){
301
- $conditions[]=$condK.' NOT IN ("'.implode('","', $condVal).'")';
302
- }else{
303
- //this means that if I delete something with a list of ids and the array happens to be empty array of ids it will just delete everything by
304
- if(is_null($condVal)) {
305
- $conditions[] = $condK.' IS NOT NULL';
306
- } else {
307
- if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
308
- $conditions[] = $condK.' != '.$condVal;
309
- }
310
- }
311
- break;
312
- case 'like':
313
- $conditions[]=$condK." LIKE '%".esc_sql(addcslashes($condVal, '%_' ))."%'";
314
- break;
315
- case 'greater':
316
- if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
317
- $conditions[]=$condK.' > '.$condVal;
318
- break;
319
- case 'less':
320
- if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
321
- $conditions[]=$condK.' < '.$condVal;
322
- break;
323
- case 'greater_eq':
324
- if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
325
- $conditions[]=$condK.' >= '.$condVal;
326
- break;
327
- case 'less_eq':
328
- if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
329
- $conditions[]=$condK.' <= '.$condVal;
330
- break;
331
- case 'is':
332
-
333
- $conditions[]=$condK.' '.$condVal;
334
- break;
335
- }
336
- }
337
-
338
- }
339
-
340
- $query.=' WHERE '.implode(' AND ',$conditions);
341
- }
342
-
343
- return $query;
344
- }
345
-
346
- /**
347
- * make the SQL ORDER BY condition string
348
- * @return string
349
- */
350
- function makeOrderBY(){
351
- $query=' ORDER BY ';
352
- if($this->orderby){
353
- /*set the ORDER BY clause*/
354
- $query.=$this->orderby.' '.$this->orderbyt;
355
- }else{
356
- /*by default we order by pk desc*/
357
- if(is_array($this->pk)) return '';
358
- $query.=$this->pk.' DESC';
359
- }
360
- return $query;
361
- }
362
-
363
-
364
- function makeJoins(){
365
-
366
- if($this->joins){
367
- $join=' as A';
368
- $arrayLetters=array('B','C','D','E');
369
- foreach($this->joins['tablejoins'] as $table => $fk){
370
- $letter=array_shift($arrayLetters);
371
- $join.=' JOIN `'.$this->getPrefix().$table.'` AS '.$letter." on $letter.$fk=A.".$this->joins['keystart'].' ';
372
- }
373
- /*set the ORDER BY clause*/
374
- return $join;
375
- }else return '';
376
-
377
- }
378
- /**
379
- * make the SQL ORDER BY condition string
380
- * @return string
381
- */
382
- function makeGroupBY(){
383
-
384
- if($this->groupby){
385
- /*set the ORDER BY clause*/
386
- return ' GROUP BY '.$this->groupby;
387
- }else return '';
388
-
389
- }
390
- function groupBy($name){
391
-
392
- if (!is_string($name) OR preg_match('|[^a-z0-9#_.-]|i',$name) !== 0 ){
393
- $this->groupby=false;
394
- }else $this->groupby=$name;
395
- }
396
- function orderBy($name,$type = 'ASC'){
397
-
398
- if(is_array($name) and count($name) > 0) {
399
- // set order by to empty string
400
- $this->orderby = '';
401
- $this->ordert = '';
402
-
403
- // count number of arguments
404
- $count = count($name);
405
-
406
- // build order by query
407
- for($i = 0; $i < $count; $i++) {
408
-
409
- $value = current($name);
410
-
411
- //security escaping
412
- if(!is_string(key($name)) OR preg_match('|[^a-z0-9#_.-]|i',key($name)) !== 0 ){
413
- $orderByCol="";
414
- }else $orderByCol=key($name);
415
- //security escaping
416
- if(!is_string($value) OR preg_match('|[^a-z0-9#_.-]|i',$value) !== 0 ){
417
- $orderByVal="";
418
- }else $orderByVal=$value;
419
-
420
- if($i === ($count - 1)) {
421
- $this->orderby .= $orderByCol;
422
- $this->ordert = $orderByVal;
423
- } else {
424
- $this->orderby .=$orderByCol.' '.$orderByVal;
425
- $this->orderby .= ', ';
426
- next($name);
427
- }
428
- }
429
- } else if(!is_string($name) OR preg_match('|[^a-z0-9#_.-]|i',$name) !== 0 ){
430
- $this->orderby="";
431
- }else {
432
- $this->orderby=$name;
433
- }
434
-
435
- if(!in_array($type,array('DESC','ASC'))) $type = 'DESC';
436
- $this->orderbyt=$type;
437
- }
438
-
439
-
440
-
441
- /**
442
- * prepare for an insert procedure
443
- * @param type $values
444
- */
445
- function insert($values,$ignore=false){
446
- if($ignore)$this->ignore=true;
447
- if($this->setValues($values)){
448
- return $this->save();
449
- }else{
450
- $this->error(sprintf('missing values in model insert : %1$s.', get_class($this)));
451
- }
452
- }
453
-
454
-
455
- function replace($values=array()){
456
- $this->replaceQRY=true;
457
- $this->insert($values);
458
- $this->replaceQRY=false;
459
- }
460
-
461
- /**
462
- * prepare for an update procedure
463
- * @param type $values
464
- * @param type $conditions
465
- */
466
- function update($values=array(),$conditions=array()){
467
-
468
- if($this->setValues($values)){
469
- /*if no condition is set then we set it mannualy based on the primary key*/
470
- if(!$conditions){
471
- if(!$this->conditions){
472
- if(isset($values[$this->pk]) && $values[$this->pk]){
473
-
474
- $this->setConditions(array($this->pk => $values[$this->pk]), true);
475
-
476
- unset($values[$this->pk]);
477
-
478
- return $this->save(true);
479
-
480
- }else{
481
- $this->error(sprintf('missing pk value in model update : %1$s.', get_class($this)));
482
- }
483
- }
484
-
485
- }else{
486
- if($this->setConditions($conditions,true)){
487
- return $this->save(true);
488
- }else{
489
- $this->error(sprintf('missing conditions in model update : %1$s.', get_class($this)));
490
- }
491
- }
492
-
493
- }else{
494
- $this->error(sprintf('missing values in model update : %1$s.', get_class($this)));
495
- }
496
- }
497
-
498
- /**
499
- * UPDATE with a special where condition
500
- * @param type $table
501
- * @param type $data
502
- * @param type $where
503
- * @param type $format
504
- * @param type $where_format
505
- * @return type
506
- */
507
- function specialUpdate( $table, $data, $where, $format = null, $where_format = null ) {
508
- if ( ! is_array( $data ) || ! is_array( $where ) )
509
- return false;
510
-
511
- $formats = $format = (array) $format;
512
- $bits = $wheres = array();
513
-
514
- $i=0;
515
- foreach ( $data as $field => $val) {
516
- $this->_secureFieldVal($field,$val);
517
-
518
- switch($format[$i]){
519
- case "%d":
520
- $bits[] = "`$field` = ".(int)$val;
521
- break;
522
- case '[increment]':
523
- $bits[] = "`$field` = ".$field.'+1';
524
- break;
525
- case '[decrement]':
526
- $bits[] = "`$field` = ".$field.'-1';
527
- break;
528
- default :
529
- $bits[] = "`$field` = '".$val."'";
530
- }
531
- $i++;
532
- }
533
-
534
- $sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . ' ' . $this->makeWhere();
535
- return $this->query( $sql );
536
- }
537
-
538
-
539
- function _secureFieldVal( &$field, &$mixed ) {
540
- if ( ! is_string( $field ) || preg_match( '|[^a-z0-9#_.-]|i', $field ) !== 0 ) {
541
- die('field "'.$field .'" not secured');
542
- }
543
- if ( is_string( $mixed ) || is_numeric( $mixed ) || is_bool( $mixed ) ) {
544
- $mixed = esc_sql( $mixed );
545
- } else {
546
- if(!empty($mixed) && is_array($mixed)){
547
- foreach ( $mixed as $key => &$value ) {
548
- $this->_secureFieldVal( $field, $value );
549
- }
550
- }
551
- }
552
- }
553
- /**
554
- * save information as an update or an insert
555
- * @global type $wpdb
556
- * @param type $update
557
- * @return type
558
- */
559
- function save($update=false){
560
-
561
- if($update)$updateStr='Update';
562
- else $updateStr='Insert';
563
- $beforeSave='before'.$updateStr;
564
- $afterSave='after'.$updateStr;
565
-
566
-
567
-
568
- if(!$update && isset($this->columns['created_at']))$this->values['created_at']=time();
569
- foreach($this->columns as $key => $params){
570
- /*check for auto columns */
571
- if((isset($params['autoup']) && $update) || (!$update && $key!='sent_at')){
572
- if(isset($params['type']) && !isset($this->values[$key])){
573
- switch($params['type']){
574
- case 'date':
575
- $this->values[$key]=time();
576
- break;
577
- case 'ip':
578
- $userHelper=WYSIJA::get("user","helper");
579
- /*record the ip and save the user*/
580
- $this->values[$key]=$userHelper->getIP();
581
- break;
582
- case 'referer':
583
- /*record the ip and save the user*/
584
- $this->values[$key]=$_SERVER['HTTP_REFERER'];
585
- break;
586
- }
587
- }
588
-
589
- }
590
- }
591
-
592
- if(method_exists($this,$beforeSave)){
593
- if(!$this->$beforeSave()){
594
- //$this->error(sprintf('Problem during validation "%2$s" in model : %1$s.', get_class($this), $beforeSave));
595
- return false;
596
- }
597
- }
598
-
599
- /*prepare a format list for the update and insert function*/
600
- $fieldsFormats=array();
601
- if(!is_array($this->pk) && isset($this->values[$this->pk])) unset($this->values[$this->pk]);
602
- foreach($this->values as $key =>$val){
603
- if(!isset($this->columns[$key]['html'])) $this->values[$key]=strip_tags($val);
604
- /* let's correct the type of the values based on the one defined in the model*/
605
- if(in_array($val, array('[increment]','[decrement]'))){
606
- $fieldsFormats[]=$val;
607
- $this->specialUpdate=true;
608
- }else{
609
- //dbg($this->values);
610
- if(!isset($this->columns[$key]['type'])){
611
- $this->columns[$key]['type']='default';
612
- }
613
- switch($this->columns[$key]['type']){
614
- case 'integer':
615
- case 'boolean':
616
- $fieldsFormats[]="%d";
617
- break;
618
- default:
619
- $fieldsFormats[]="%s";
620
-
621
- }
622
- }
623
-
624
- }
625
-
626
- if($this->fieldValid && !$this->validateFields()) {
627
- $this->error(__('Error Validating the fields',WYSIJA),true);
628
- $this->stay=true;
629
- return false;
630
- }
631
-
632
- global $wpdb;
633
-
634
- // if dbg is on we track the duration of the query
635
- if($this->dbg){
636
- $this->timer_start();
637
- }
638
-
639
- if($update){
640
-
641
- if( $this->specialUpdate || isset($this->conditions['equal']) || isset($this->conditions['notequal']) || isset($this->conditions['like'])){
642
-
643
- $resultSave=$this->specialUpdate($this->getPrefix().$this->table_name,$this->values,$this->conditions,$fieldsFormats);
644
- $this->logError();
645
- }else{
646
-
647
- $wpdb->update($this->getPrefix().$this->table_name,$this->values,$this->conditions,$fieldsFormats);
648
- $this->logError();
649
- $resultSave=$wpdb->result;
650
- }
651
-
652
- }else{
653
- if($this->replaceQRY){
654
- $resultSave=$wpdb->replace($this->getPrefix().$this->table_name,$this->values,$fieldsFormats);
655
- $this->logError();
656
- }else{
657
-
658
- if($this->ignore) $resultSave=$wpdb->insert($this->getPrefix().$this->table_name,$this->values,$fieldsFormats);
659
- else $resultSave=$wpdb->insert($this->getPrefix().$this->table_name,$this->values,$fieldsFormats);
660
-
661
- $this->logError();
662
- //dbg('hello');
663
- }
664
-
665
- }
666
-
667
- // if dbg is on we track the duration of the query
668
- if($this->dbg){
669
- $this->timer_stop();
670
- $this->keepQry('save');
671
- }
672
-
673
- if(!$resultSave){
674
- $wpdb->show_errors();
675
- return false;
676
- }else{
677
- if($update){
678
- if(isset($this->conditions[$this->getPk()])){
679
- $resultSave=$this->conditions[$this->getPk()];
680
- }else{
681
- if(isset($this->conditions[$this->getPk(1)])) $resultSave=$this->conditions[$this->getPk(1)];
682
- }
683
-
684
- }else{
685
- $resultSave=$wpdb->insert_id;
686
- }
687
- }
688
-
689
- $wpdb->flush();
690
-
691
- if(method_exists($this,$afterSave)){
692
- if(!$this->$afterSave($resultSave)){
693
- //$this->error(sprintf('Problem during validation "%2$s" in model : %1$s.', get_class($this), $afterSave));
694
- return false;
695
- }
696
- }
697
- return $resultSave;
698
- }
699
-
700
-
701
- function insertMany($values){
702
- $fields=array_keys($values[0]);
703
-
704
- $query='INSERT INTO `'.$this->getPrefix().$this->table_name.'` (`' . implode( '`,`', $fields ) . '`) VALUES ';
705
-
706
- $total=count($values);
707
- $i=1;
708
- foreach($values as &$vals){
709
- foreach($vals as &$v) $v=esc_sql($v);
710
- $query.= "('" . implode( "','", $vals )."')";
711
- if($i<$total) $query.=',';
712
- $i++;
713
- }
714
-
715
- $this->query($query.$myvalues);
716
-
717
- }
718
-
719
- /**
720
- * validate the fields type(defined in each model) in the save procedure
721
- * @return type
722
- */
723
- function validateFields(){
724
- $error=false;
725
- foreach($this->values as $key =>$val){
726
- if(isset($this->columns[$key]['req']) && !$val && $this->columns[$key]['type']!='boolean'){
727
- $this->error(sprintf(__('Field "%1$s" is required in table "%2$s".',WYSIJA), $key,$this->table_name),true);
728
- $error=true;
729
- }
730
- /* let's correct the type of the values based on the one defined in the model*/
731
- switch($this->columns[$key]['type']){
732
- case "email":
733
- $userHelper = WYSIJA::get('user','helper');
734
- if(!$userHelper->validEmail($val)){
735
- $this->error(sprintf(__('Field "%1$s" needs to be a valid Email.',WYSIJA), $key),true);
736
- $error=true;
737
- }
738
- break;
739
- }
740
- }
741
-
742
- if($error) return false;
743
- return true;
744
- }
745
-
746
- /**
747
- * delete procedure
748
- * @global type $wpdb
749
- * @param type $conditions
750
- * @return type
751
- */
752
- function delete($conditions){
753
- $query='DELETE FROM `'.$this->getPrefix().$this->table_name.'`';
754
-
755
- if($this->setConditions($conditions)){
756
- $whereQuery=$this->makeWhere();
757
- if(!$whereQuery){
758
- $this->error('Cannot delete element without conditions in model : '.get_class($this));
759
- }
760
- }else{
761
- $this->error('Cannot delete element without conditions in model : '.get_class($this));
762
- return false;
763
- }
764
- $result=$this->beforeDelete($conditions);
765
- if($result) $result=$this->query($query.$whereQuery);
766
- else return false;
767
- $this->afterDelete();
768
-
769
- return true;
770
- }
771
-
772
- function exists($conditions){
773
-
774
- $query='SELECT '.$this->getPk().' FROM `'.$this->getSelectTableName().'`';
775
-
776
- $query.=$this->makeJoins();
777
- if($this->setConditions($conditions)){
778
- $whereQuery=$this->makeWhere();
779
- if(!$whereQuery){
780
- $this->error('Cannot test element without conditions in model : '.get_class($this));
781
- }
782
- }else{
783
- $this->error('Cannot test element without conditions in model : '.get_class($this));
784
- return false;
785
- }
786
- $res=$this->query('get_res',$query.$whereQuery, ARRAY_A);
787
- if($res) return $res;
788
- else return false;
789
- }
790
-
791
- function getPk($numb=0){
792
- $pk=$this->pk;
793
- if(is_array($pk)) $pk=$pk[$numb];
794
- return $pk;
795
- }
796
-
797
- /**
798
- * set the values after verifying them
799
- * @param type $values
800
- * @return type
801
- */
802
- function setValues($values){
803
- if($this->colCheck && !$this->checkAreColumns($values)) return false;
804
-
805
- $this->values=array();
806
- $this->values=$values;
807
- return true;
808
- }
809
-
810
- /**
811
- *
812
- * @param type $values
813
- * @return type
814
- */
815
- function setJoin($joins){
816
- $this->joins=$joins;
817
- return true;
818
- }
819
-
820
- /**
821
- * set the conditions after verifying them
822
- * @param type $conditions
823
- * @return type
824
- */
825
- function setConditions($conditions,$update=false){
826
- if($conditions && is_array($conditions)){
827
-
828
- $this->conditions=array();
829
- if($update){
830
- foreach($conditions as $key =>$cond){
831
- if($this->colCheck && !$this->checkAreColumns($conditions)) return false;
832
-
833
- if(is_array($cond)){
834
- $this->specialUpdate=true;
835
- $this->conditions=$conditions;
836
-
837
- return true;
838
- }else $this->conditions[$key]=$cond;
839
-
840
- }
841
- } else {
842
- foreach($conditions as $key => $cond) {
843
- if(!in_array($key, $this->comparisonKeys /*array('like','equal','notequal','greater','less','greater_eq','less_eq')*/)){
844
- if($this->colCheck && !$this->checkAreColumns($conditions)) return false;
845
- if(array_key_exists('equal', $this->conditions) === false) $this->conditions['equal'] = array();
846
- $this->conditions['equal'][$key] = $cond;
847
- }else{
848
- if($this->colCheck && !$this->checkAreColumns($cond)) return false;
849
- $this->conditions[$key]=$cond;
850
- }
851
-
852
- }
853
- }
854
-
855
- return true;
856
- }else return false;
857
- }
858
-
859
- /**
860
- * check that the columns corresponds to the columns in the model
861
- * @param type $arrayColumns
862
- * @return type
863
- */
864
- function checkAreColumns($columns){
865
- if($this->noCheck) return true;
866
- foreach($columns as $column => $values) {
867
- // skip when column is a comparison key
868
- if(in_array($column, $this->comparisonKeys)) continue;
869
-
870
- $columnName = $column;
871
- if(!isset($this->columns[$columnName])){
872
- $this->error(sprintf('Column %1$s does not exist in model : %2$s', $columnName, get_class($this)));
873
- return false;
874
- }
875
- }
876
- return true;
877
- }
878
-
879
- function timer_start() {
880
- $this->query_duration = 0;
881
- $this->time_start = microtime( true );
882
- return true;
883
- }
884
-
885
- function timer_stop() {
886
- $this->query_duration = ( microtime( true ) - $this->time_start );
887
- }
888
-
889
- function query($query,$arg2='',$arg3=ARRAY_A){
890
- global $wpdb;
891
- $this->sql_error = false;
892
- if(!$arg2) $query = str_replace(array('[wysija]','[wp]'),array($this->getPrefix(),$wpdb->prefix),$query);
893
- else $arg2 = str_replace(array('[wysija]','[wp]'),array($this->getPrefix(),$wpdb->prefix),$arg2);
894
-
895
- // if dbg is on we track the duration of the query
896
- if($this->dbg){
897
- $this->timer_start();
898
- }
899
-
900
- switch($query){
901
- case 'get_row':
902
- $result = $wpdb->get_row($arg2,$arg3);
903
- $this->logError();
904
- break;
905
- case 'get_res':
906
- $result = $wpdb->get_results($arg2,$arg3);
907
- //$this->escapeQuotesFromRes($results);
908
- $this->logError();
909
- break;
910
- default:
911
- $result = $wpdb->query($query);
912
- $this->logError();
913
-
914
- // get the last insert id if it's an insert query
915
- if(substr($query, 0, 6) == 'INSERT') $result = $wpdb->insert_id;
916
-
917
- }
918
- // if dbg is on we track the duration of the query
919
- if($this->dbg){
920
- $this->timer_stop();
921
- $this->keepQry('query');
922
- }
923
- return $result;
924
- }
925
-
926
- function logError(){
927
- if(defined('WYSIJA_DBG') && WYSIJA_DBG>1){
928
- global $wysija_queries_errors, $wpdb;
929
- if(!$wysija_queries_errors) $wysija_queries_errors = array();
930
-
931
- $this->sql_error = $wpdb->last_error;
932
-
933
- if( $this->sql_error &&
934
- ( empty( $this->last_error ) || $this->last_error != $this->sql_error )) {
935
- $this->last_error = $wysija_queries_errors[] = $this->sql_error;
936
- $this->sql_error = false;
937
- WYSIJA::log('queries_errors' , $this->sql_error , 'query_errors');
938
- }
939
-
940
- }
941
-
942
- }
943
-
944
- function keepQry($from = 'wpdb'){
945
- global $wpdb,$wysija_queries;
946
- $wysija_queries[$from][] = array('duration' => $this->query_duration , 'query' => $wpdb->last_query);
947
- }
948
-
949
- function getAffectedRows(){
950
- global $wpdb;
951
- return $wpdb->rows_affected;
952
- }
953
-
954
- function getErrorMsg(){
955
- global $wpdb;
956
- return $wpdb->show_errors();
957
- }
958
- /**
959
- * get the full prefix for the table
960
- * @global type $wpdb
961
- * @return type
962
- */
963
- function getPrefix(){
964
- if($this->tableWP) return $this->wpprefix.$this->table_prefix;
965
- else return $this->wpprefix.$this->table_prefix.'_';
966
- }
967
-
968
- /**
969
- * this function allows you to get the prefix from the main site on a multisite
970
- * @return type
971
- */
972
- function get_site_prefix($blog_id=1){
973
-
974
- switch_to_blog( $blog_id );
975
- global $wpdb;
976
- $main_site_prefix=$wpdb->prefix;
977
- restore_current_blog();
978
-
979
- if($this->tableWP) return $main_site_prefix.$this->table_prefix;
980
- else return $main_site_prefix.$this->table_prefix.'_';
981
- }
982
-
983
- /**
984
- *
985
- * @param type $field_name name of field which will become a key
986
- * @param array $dataset list of records
987
- * @param boolean $removing_field_name decide if we should remove field name from output dataset
988
- * @param string $field_name_as_value a field in which we consider its value as value of $field_name
989
- * @return array field based indexed dataset
990
- */
991
- protected function indexing_dataset_by_field($field_name, Array $dataset, $removing_field_name = false, $field_name_as_value = null){
992
- if (empty($dataset))
993
- return array();
994
- $tmp = array();
995
- foreach ($dataset as $record){
996
- if (isset($record[$field_name]))
997
- {
998
- if (!empty($field_name_as_value)){
999
- $tmp[$record[$field_name]] = isset($record[$field_name_as_value]) ? $record[$field_name_as_value] : null;
1000
- continue;
1001
- }
1002
- $tmp[$record[$field_name]] = $record;
1003
- if ($removing_field_name)
1004
- unset($tmp[$record[$field_name]][$field_name]);
1005
- }
1006
-
1007
- }
1008
- return $tmp;
1009
- }
1010
-
1011
- function beforeInsert(){
1012
- return true;
1013
- }
1014
-
1015
- function afterInsert($resultSaveID){
1016
- return true;
1017
- }
1018
- function beforeDelete($conditions){
1019
- return true;
1020
- }
1021
-
1022
- function afterDelete(){
1023
- return true;
1024
- }
1025
-
1026
- function beforeUpdate($id = null){
1027
- return true;
1028
- }
1029
-
1030
- function afterUpdate($resultSaveID){
1031
- return true;
1032
- }
 
 
 
 
1033
 
1034
  }
2
  defined('WYSIJA') or die('Restricted access');
3
  class WYSIJA_model extends WYSIJA_object{
4
 
5
+ var $table_prefix='wysija';
6
+ var $table_name='';
7
+ var $pk='';
8
+ var $values=array();
9
+ var $conditions=array();
10
+ var $orderby=array();
11
+ var $groupby=false;
12
+ var $noCheck =false;
13
+ var $replaceQRY=false;
14
+ var $limitON=false;
15
+ var $dbg=false;
16
+ var $colCheck=true;
17
+ var $getFormat=ARRAY_A;
18
+ var $getOne=false;
19
+ var $fieldValid=true;
20
+ var $specialUpdate=false;
21
+ var $escapeFields=array();
22
+ var $escapingOn=false;
23
+ var $tableWP=false;
24
+ var $columns=array();
25
+ var $joins=array();
26
+ var $ignore = false;
27
+ var $sql_error=false;
28
+ var $comparisonKeys = array('equal', 'notequal', 'like', 'greater', 'less', 'greater_eq', 'less_eq', 'is');
29
+ var $time_start = 0;
30
+ var $query_duration = 0;
31
+
32
+ function WYSIJA_model($extensions=''){
33
+ if(defined('WYSIJA_DBG') && WYSIJA_DBG>0) $this->dbg=true;
34
+ global $wpdb;
35
+ $this->wpprefix=$wpdb->prefix;
36
+ if($extensions) $this->table_prefix=$extensions;
37
+ //fix for radiokapi
38
+ //$this->wpprefix=$wpdb->base_prefix;
39
+ }
40
+ /**
41
+ * since we reuse the same objects accross the whole application
42
+ * once in a while for instance between a delete and a select we need to reset the objects to update the conditions
43
+ */
44
+ function reset(){
45
+ $this->values=array();
46
+ $this->conditions=array();
47
+ $this->orderby=array();
48
+ $this->groupby=false;
49
+ $this->getFormat=ARRAY_A;
50
+ $this->getOne=false;
51
+ $this->limitON=false;
52
+ $this->sql_error=false;
53
+ }
54
+
55
+ /**
56
+ *
57
+ * @param type $columnsOrPKval
58
+ * @param type $conditions
59
+ * @return type
60
+ */
61
+ function get($columnsOrPKval=false,$conditions=array()){
62
+ /*then columns becomes the pk value*/
63
+ if(!$conditions){
64
+ $conditions=array('equal'=>array($this->pk=>$columnsOrPKval));
65
+ $columnsOrPKval=false;
66
+ $this->noCheck=true;
67
+ }
68
+
69
+ /* if we pass just the id strong in the get conditions then it's the pk*/
70
+ if($conditions && !is_array($conditions)){
71
+ $conditions=array('equal'=>array($this->pk=>$conditions));
72
+ }
73
+ if($this->setConditions($conditions)){
74
+ if($this->getOne) $results=$this->getRows($columnsOrPKval,0,1);
75
+ else $results=$this->getRows($columnsOrPKval);
76
+ //$this->escapeQuotesFromRes($results);
77
+ if($this->getOne && count($results)==1){
78
+ switch($this->getFormat){
79
+ case ARRAY_A:
80
+ foreach($results as $res)return $res;
81
+ break;
82
+ case OBJECT:
83
+ foreach($results as $res)return $res;
84
+ break;
85
+ }
86
+ }
87
+ else return $results;
88
+ }
89
+
90
+ return false;
91
+ }
92
+
93
+ function getOne($columnsOrPKval=false,$conditions=array()){
94
+ $this->getOne=true;
95
+ $this->limitON=true;
96
+
97
+ return $this->get($columnsOrPKval,$conditions);
98
+ }
99
+
100
+ /**
101
+ * get a list of result based on a select query
102
+ * @global type $wpdb
103
+ * @param type $columns
104
+ * @param type $page
105
+ * @param type $limit
106
+ * @return type
107
+ */
108
+ function getRows($columns=false,$page=0,$limit=false){
109
+
110
+ /*set the columns*/
111
+ if($columns){
112
+ if(is_array($columns)){
113
+ $columns=implode(', ',$columns);
114
+ }
115
+ }else $columns='*';
116
+
117
+
118
+ $query='SELECT '.$columns.' FROM `'.$this->getSelectTableName()."`";
119
+ $query.=$this->makeJoins();
120
+ $query.=$this->makeWhere();
121
+ $query.=$this->makeGroupBY();
122
+ $query.=$this->makeOrderBY();
123
+
124
+ if($this->limitON) $query.=$this->setLimit($page,$limit);
125
+ $results=$this->query('get_res',$query,$this->getFormat);
126
+
127
+ //$this->escapeQuotesFromRes($results);
128
+
129
+ return $results;
130
+ }
131
+
132
+ function escapeQuotesFromRes(&$results){
133
+ if(!$this->escapingOn) return false;
134
+ foreach($results as $k =>$r){
135
+
136
+ if(in_array($this->getFormat,array(ARRAY_A,ARRAY_N))){
137
+ foreach($r as $k1 =>$v1){
138
+ if(in_array($k1,$this->escapeFields)){
139
+ $results[$k][$k1]= stripslashes($v1);
140
+ }
141
+ }
142
+ }
143
+ }
144
+ }
145
+
146
+ function setLimit($page=0,$limit=false){
147
+ /*set the limit of the selection*/
148
+
149
+ if(!$this->getOne){
150
+ if($page==0){
151
+ if(isset($_REQUEST['pagi'])){
152
+ $page=(int)$_REQUEST['pagi'];
153
+ if($page!=0) $page=$page-1;
154
+ }
155
+
156
+ }else $page=$page-1;
157
+ }
158
+
159
+ if(!$limit){
160
+ if(isset($this->limit_pp)) $limit=$this->limit_pp;
161
+ else{
162
+ $config=WYSIJA::get('config','model');
163
+ $limit=$config->getValue('limit_listing');
164
+ }
165
+ }
166
+
167
+ $this->limit=(int)$limit;
168
+ $this->page=$page;
169
+ $this->limit_start=(int)($this->page*$this->limit);
170
+ $this->limit_end=(int)($this->limit_start+$this->limit);
171
+
172
+ return " LIMIT $this->limit_start , $this->limit";
173
+ }
174
+
175
+ /**
176
+ * DEPRECATED
177
+ * to have a custom query through the model and get the result immediately
178
+ * @param type $query
179
+ * @return type
180
+ */
181
+ function getResults($query,$type=ARRAY_A){
182
+ return $this->query('get_res',$query, $type);
183
+ }
184
+
185
+ /**
186
+ * to have a custom query through the model and get the result immediately
187
+ * @param type $query
188
+ * @return type
189
+ */
190
+ public function get_results($query,$type=ARRAY_A){
191
+ return $this->getResults($query,$type);
192
+ }
193
+
194
+
195
+ function getSelectTableName(){
196
+ if($this->joins && isset($this->joins['tablestart'])){
197
+ if(isset($this->joins['prefstart'])) return $this->wpprefix.$this->joins['prefstart'].'_'.$this->joins['tablestart'];
198
+ else return $this->getPrefix().$this->joins['tablestart'];
199
+ }else return $this->getPrefix().$this->table_name;
200
+ }
201
+
202
+ /**
203
+ * simple SQL count
204
+ * @global type $wpdb
205
+ * @return type
206
+ */
207
+ function count($query=false,$keygetcount=false){
208
+ if(!$query){
209
+ $groupBy=$this->makeGroupBY();
210
+ $columnMore='';
211
+ if($groupBy) $columnMore=','.$this->groupby;
212
+ $query='SELECT COUNT('.$this->getPk().') as count '.$columnMore.' FROM `'.$this->getSelectTableName().'`';
213
+ $query.=$this->makeJoins();
214
+
215
+ $query.=$this->makeWhere();
216
+ $query.=$groupBy;
217
+ }
218
+
219
+
220
+ // if dbg is on we track the duration of the query
221
+ if($this->dbg){
222
+ $this->timer_start();
223
+ }
224
+ $results=$this->query('get_res',$query,$this->getFormat);
225
+
226
+ // if dbg is on we track the duration of the query
227
+ if($this->dbg){
228
+ $this->timer_stop();
229
+ $this->keepQry('count');
230
+ }
231
+
232
+ if(!$results || count($results)>1) return $results;
233
+ else {
234
+ if($keygetcount) return $results[0][$keygetcount];
235
+ else{
236
+ foreach($results[0] as $key => $count) return $count;
237
+ }
238
+ }
239
+
240
+
241
+ return $results;
242
+ }
243
+
244
+ /**
245
+ * make the SQL WHERE condition string
246
+ * @return string
247
+ */
248
+ function makeWhere(){
249
+ $query='';
250
+ if($this->conditions){
251
+ /*set the WHERE clause*/
252
+ $conditions=array();
253
+ foreach($this->conditions as $type=>$values){
254
+ if(!in_array($type, $this->comparisonKeys)){
255
+ $conditionsss=$this->conditions;
256
+ $this->conditions=array();
257
+ $this->conditions['equal']=$conditionsss;
258
+
259
+ break;
260
+ }
261
+ }
262
+ foreach($this->conditions as $type=>$values){
263
+ if($type=='like' && count($values)>1){
264
+ if(is_array($values)){
265
+ $total=count($values);
266
+ $i=1;
267
+ $likeCond='';
268
+ foreach($values as $qfield => $qval){
269
+ $likeCond.=$qfield." LIKE '%".mysql_real_escape_string(addcslashes($qval, '%_' ))."%'";
270
+ if($i<$total){
271
+ $likeCond.=' OR ';
272
+ }
273
+ $i++;
274
+ }
275
+ $conditions[]='('.$likeCond.')';
276
+ }
277
+ continue;
278
+ }
279
+ foreach($values as $condK => $condVal){
280
+
281
+ //secure from injections
282
+ $this->_secureFieldVal($condK, $condVal);
283
+
284
+ switch($type){
285
+ case 'equal':
286
+ if(is_array($condVal)){
287
+ $conditions[]=$condK.' IN ("'.implode('","', $condVal).'")';
288
+ }else{
289
+ if(is_null($condVal)) {
290
+ $conditions[] = $condK.' IS NULL';
291
+ } else {
292
+ if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
293
+ $conditions[] = $condK.'='.$condVal;
294
+ }
295
+ }
296
+ break;
297
+ case 'notequal':
298
+ if(is_array($condVal)){
299
+ $conditions[]=$condK.' NOT IN ("'.implode('","', $condVal).'")';
300
+ }else{
301
+ //this means that if I delete something with a list of ids and the array happens to be empty array of ids it will just delete everything by
302
+ if(is_null($condVal)) {
303
+ $conditions[] = $condK.' IS NOT NULL';
304
+ } else {
305
+ if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
306
+ $conditions[] = $condK.' != '.$condVal;
307
+ }
308
+ }
309
+ break;
310
+ case 'like':
311
+ $conditions[]=$condK." LIKE '%".mysql_real_escape_string(addcslashes($condVal, '%_' ))."%'";
312
+ break;
313
+ case 'greater':
314
+ if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
315
+ $conditions[]=$condK.' > '.$condVal;
316
+ break;
317
+ case 'less':
318
+ if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
319
+ $conditions[]=$condK.' < '.$condVal;
320
+ break;
321
+ case 'greater_eq':
322
+ if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
323
+ $conditions[]=$condK.' >= '.$condVal;
324
+ break;
325
+ case 'less_eq':
326
+ if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
327
+ $conditions[]=$condK.' <= '.$condVal;
328
+ break;
329
+ case 'is':
330
+
331
+ $conditions[]=$condK.' '.$condVal;
332
+ break;
333
+ }
334
+ }
335
+
336
+ }
337
+
338
+ $query.=' WHERE '.implode(' AND ',$conditions);
339
+ }
340
+
341
+ return $query;
342
+ }
343
+
344
+ /**
345
+ * make the SQL ORDER BY condition string
346
+ * @return string
347
+ */
348
+ function makeOrderBY(){
349
+ $query=' ORDER BY ';
350
+ if($this->orderby){
351
+ /*set the ORDER BY clause*/
352
+ $query.=$this->orderby.' '.$this->orderbyt;
353
+ }else{
354
+ /*by default we order by pk desc*/
355
+ if(is_array($this->pk)) return '';
356
+ $query.=$this->pk.' DESC';
357
+ }
358
+ return $query;
359
+ }
360
+
361
+
362
+ function makeJoins(){
363
+
364
+ if($this->joins){
365
+ $join=' as A';
366
+ $arrayLetters=array('B','C','D','E');
367
+ foreach($this->joins['tablejoins'] as $table => $fk){
368
+ $letter=array_shift($arrayLetters);
369
+ $join.=' JOIN `'.$this->getPrefix().$table.'` AS '.$letter." on $letter.$fk=A.".$this->joins['keystart'].' ';
370
+ }
371
+ /*set the ORDER BY clause*/
372
+ return $join;
373
+ }else return '';
374
+
375
+ }
376
+ /**
377
+ * make the SQL ORDER BY condition string
378
+ * @return string
379
+ */
380
+ function makeGroupBY(){
381
+
382
+ if($this->groupby){
383
+ /*set the ORDER BY clause*/
384
+ return ' GROUP BY '.$this->groupby;
385
+ }else return '';
386
+
387
+ }
388
+ function groupBy($name){
389
+
390
+ if (!is_string($name) OR preg_match('|[^a-z0-9#_.-]|i',$name) !== 0 ){
391
+ $this->groupby=false;
392
+ }else $this->groupby=$name;
393
+ }
394
+ function orderBy($name,$type = 'ASC'){
395
+
396
+ if(is_array($name) and count($name) > 0) {
397
+ // set order by to empty string
398
+ $this->orderby = '';
399
+ $this->ordert = '';
400
+
401
+ // count number of arguments
402
+ $count = count($name);
403
+
404
+ // build order by query
405
+ for($i = 0; $i < $count; $i++) {
406
+
407
+ $value = current($name);
408
+
409
+ //security escaping
410
+ if(!is_string(key($name)) OR preg_match('|[^a-z0-9#_.-]|i',key($name)) !== 0 ){
411
+ $orderByCol="";
412
+ }else $orderByCol=key($name);
413
+ //security escaping
414
+ if(!is_string($value) OR preg_match('|[^a-z0-9#_.-]|i',$value) !== 0 ){
415
+ $orderByVal="";
416
+ }else $orderByVal=$value;
417
+
418
+ if($i === ($count - 1)) {
419
+ $this->orderby .= $orderByCol;
420
+ $this->ordert = $orderByVal;
421
+ } else {
422
+ $this->orderby .=$orderByCol.' '.$orderByVal;
423
+ $this->orderby .= ', ';
424
+ next($name);
425
+ }
426
+ }
427
+ } else if(!is_string($name) OR preg_match('|[^a-z0-9#_.-]|i',$name) !== 0 ){
428
+ $this->orderby="";
429
+ }else {
430
+ $this->orderby=$name;
431
+ }
432
+
433
+ if(!in_array($type,array('DESC','ASC'))) $type = 'DESC';
434
+ $this->orderbyt=$type;
435
+ }
436
+
437
+
438
+
439
+ /**
440
+ * prepare for an insert procedure
441
+ * @param type $values
442
+ */
443
+ function insert($values,$ignore=false){
444
+ if($ignore)$this->ignore=true;
445
+ if($this->setValues($values)){
446
+ return $this->save();
447
+ }else{
448
+ $this->error(sprintf('missing values in model insert : %1$s.', get_class($this)));
449
+ }
450
+ }
451
+
452
+
453
+ function replace($values=array()){
454
+ $this->replaceQRY=true;
455
+ $this->insert($values);
456
+ $this->replaceQRY=false;
457
+ }
458
+
459
+ /**
460
+ * prepare for an update procedure
461
+ * @param type $values
462
+ * @param type $conditions
463
+ */
464
+ function update($values=array(),$conditions=array()){
465
+
466
+ if($this->setValues($values)){
467
+ /*if no condition is set then we set it mannualy based on the primary key*/
468
+ if(!$conditions){
469
+ if(!$this->conditions){
470
+ if(isset($values[$this->pk]) && $values[$this->pk]){
471
+
472
+ $this->setConditions(array($this->pk => $values[$this->pk]), true);
473
+
474
+ unset($values[$this->pk]);
475
+
476
+ return $this->save(true);
477
+
478
+ }else{
479
+ $this->error(sprintf('missing pk value in model update : %1$s.', get_class($this)));
480
+ }
481
+ }
482
+
483
+ }else{
484
+ if($this->setConditions($conditions,true)){
485
+ return $this->save(true);
486
+ }else{
487
+ $this->error(sprintf('missing conditions in model update : %1$s.', get_class($this)));
488
+ }
489
+ }
490
+
491
+ }else{
492
+ $this->error(sprintf('missing values in model update : %1$s.', get_class($this)));
493
+ }
494
+ }
495
+
496
+ /**
497
+ * UPDATE with a special where condition
498
+ * @param type $table
499
+ * @param type $data
500
+ * @param type $where
501
+ * @param type $format
502
+ * @param type $where_format
503
+ * @return type
504
+ */
505
+ function specialUpdate( $table, $data, $where, $format = null, $where_format = null ) {
506
+ if ( ! is_array( $data ) || ! is_array( $where ) )
507
+ return false;
508
+
509
+ $formats = $format = (array) $format;
510
+ $bits = $wheres = array();
511
+
512
+ $i=0;
513
+ foreach ( $data as $field => $val) {
514
+ $this->_secureFieldVal($field,$val);
515
+
516
+ switch($format[$i]){
517
+ case "%d":
518
+ $bits[] = "`$field` = ".(int)$val;
519
+ break;
520
+ case '[increment]':
521
+ $bits[] = "`$field` = ".$field.'+1';
522
+ break;
523
+ case '[decrement]':
524
+ $bits[] = "`$field` = ".$field.'-1';
525
+ break;
526
+ default :
527
+ $bits[] = "`$field` = '".$val."'";
528
+ }
529
+ $i++;
530
+ }
531
+
532
+ $sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . ' ' . $this->makeWhere();
533
+ return $this->query( $sql );
534
+ }
535
+
536
+
537
+ function _secureFieldVal(&$field,&$val){
538
+ if (!is_string($field) OR preg_match('|[^a-z0-9#_.-]|i',$field) !== 0 ){
539
+ die('field "'.$field .'" not secured');
540
+ }
541
+ global $wpdb;
542
+ if(is_string($val)) $val=mysql_real_escape_string($val,$wpdb->dbh);
543
+ else{
544
+ if(is_array($val)){
545
+ foreach($val as $k=>$v){
546
+ if(is_string($v)) $val[$k]=mysql_real_escape_string($v,$wpdb->dbh);
547
+ }
548
+ }elseif(is_object($val)){
549
+ foreach($val as $k=>$v){
550
+ if(is_string($v)) $val->$k=mysql_real_escape_string($v,$wpdb->dbh);
551
+ }
552
+ }
553
+ }
554
+ }
555
+ /**
556
+ * save information as an update or an insert
557
+ * @global type $wpdb
558
+ * @param type $update
559
+ * @return type
560
+ */
561
+ function save($update=false){
562
+
563
+ if($update)$updateStr='Update';
564
+ else $updateStr='Insert';
565
+ $beforeSave='before'.$updateStr;
566
+ $afterSave='after'.$updateStr;
567
+
568
+
569
+
570
+ if(!$update && isset($this->columns['created_at']))$this->values['created_at']=time();
571
+ foreach($this->columns as $key => $params){
572
+ /*check for auto columns */
573
+ if((isset($params['autoup']) && $update) || (!$update && $key!='sent_at')){
574
+ if(isset($params['type']) && !isset($this->values[$key])){
575
+ switch($params['type']){
576
+ case 'date':
577
+ $this->values[$key]=time();
578
+ break;
579
+ case 'ip':
580
+ $userHelper=WYSIJA::get("user","helper");
581
+ /*record the ip and save the user*/
582
+ $this->values[$key]=$userHelper->getIP();
583
+ break;
584
+ case 'referer':
585
+ /*record the ip and save the user*/
586
+ $this->values[$key]=$_SERVER['HTTP_REFERER'];
587
+ break;
588
+ }
589
+ }
590
+
591
+ }
592
+ }
593
+
594
+ if(method_exists($this,$beforeSave)){
595
+ if(!$this->$beforeSave()){
596
+ //$this->error(sprintf('Problem during validation "%2$s" in model : %1$s.', get_class($this), $beforeSave));
597
+ return false;
598
+ }
599
+ }
600
+
601
+ /*prepare a format list for the update and insert function*/
602
+ $fieldsFormats=array();
603
+ if(!is_array($this->pk) && isset($this->values[$this->pk])) unset($this->values[$this->pk]);
604
+ foreach($this->values as $key =>$val){
605
+ if(!isset($this->columns[$key]['html'])) $this->values[$key]=strip_tags($val);
606
+ /* let's correct the type of the values based on the one defined in the model*/
607
+ if(in_array($val, array('[increment]','[decrement]'))){
608
+ $fieldsFormats[]=$val;
609
+ $this->specialUpdate=true;
610
+ }else{
611
+ //dbg($this->values);
612
+ if(!isset($this->columns[$key]['type'])){
613
+ $this->columns[$key]['type']='default';
614
+ }
615
+ switch($this->columns[$key]['type']){
616
+ case 'integer':
617
+ case 'boolean':
618
+ $fieldsFormats[]="%d";
619
+ break;
620
+ default:
621
+ $fieldsFormats[]="%s";
622
+
623
+ }
624
+ }
625
+
626
+ }
627
+
628
+ if($this->fieldValid && !$this->validateFields()) {
629
+ $this->error(__('Error Validating the fields',WYSIJA),true);
630
+ $this->stay=true;
631
+ return false;
632
+ }
633
+
634
+ global $wpdb;
635
+
636
+ // if dbg is on we track the duration of the query
637
+ if($this->dbg){
638
+ $this->timer_start();
639
+ }
640
+
641
+ if($update){
642
+
643
+ if( $this->specialUpdate || isset($this->conditions['equal']) || isset($this->conditions['notequal']) || isset($this->conditions['like'])){
644
+
645
+ $resultSave=$this->specialUpdate($this->getPrefix().$this->table_name,$this->values,$this->conditions,$fieldsFormats);
646
+ $this->logError();
647
+ }else{
648
+
649
+ $wpdb->update($this->getPrefix().$this->table_name,$this->values,$this->conditions,$fieldsFormats);
650
+ $this->logError();
651
+ $resultSave=$wpdb->result;
652
+ }
653
+
654
+ }else{
655
+ if($this->replaceQRY){
656
+ $resultSave=$wpdb->replace($this->getPrefix().$this->table_name,$this->values,$fieldsFormats);
657
+ $this->logError();
658
+ }else{
659
+
660
+ if($this->ignore) $resultSave=$wpdb->insert($this->getPrefix().$this->table_name,$this->values,$fieldsFormats);
661
+ else $resultSave=$wpdb->insert($this->getPrefix().$this->table_name,$this->values,$fieldsFormats);
662
+
663
+ $this->logError();
664
+ //dbg('hello');
665
+ }
666
+
667
+ }
668
+
669
+ // if dbg is on we track the duration of the query
670
+ if($this->dbg){
671
+ $this->timer_stop();
672
+ $this->keepQry('save');
673
+ }
674
+
675
+ if(!$resultSave){
676
+ $wpdb->show_errors();
677
+ return false;
678
+ }else{
679
+ if($update){
680
+ if(isset($this->conditions[$this->getPk()])){
681
+ $resultSave=$this->conditions[$this->getPk()];
682
+ }else{
683
+ if(isset($this->conditions[$this->getPk(1)])) $resultSave=$this->conditions[$this->getPk(1)];
684
+ }
685
+
686
+ }else{
687
+ $resultSave=$wpdb->insert_id;
688
+ }
689
+ }
690
+
691
+ $wpdb->flush();
692
+
693
+ if(method_exists($this,$afterSave)){
694
+ if(!$this->$afterSave($resultSave)){
695
+ //$this->error(sprintf('Problem during validation "%2$s" in model : %1$s.', get_class($this), $afterSave));
696
+ return false;
697
+ }
698
+ }
699
+ return $resultSave;
700
+ }
701
+
702
+
703
+ function insertMany($values){
704
+ $fields=array_keys($values[0]);
705
+
706
+ $query='INSERT INTO `'.$this->getPrefix().$this->table_name.'` (`' . implode( '`,`', $fields ) . '`) VALUES ';
707
+
708
+ $total=count($values);
709
+ $i=1;
710
+ foreach($values as &$vals){
711
+ foreach($vals as &$v) $v=mysql_real_escape_string($v);
712
+ $query.= "('" . implode( "','", $vals )."')";
713
+ if($i<$total) $query.=',';
714
+ $i++;
715
+ }
716
+
717
+ $this->query($query.$myvalues);
718
+
719
+ }
720
+
721
+ /**
722
+ * validate the fields type(defined in each model) in the save procedure
723
+ * @return type
724
+ */
725
+ function validateFields(){
726
+ $error=false;
727
+ foreach($this->values as $key =>$val){
728
+ if(isset($this->columns[$key]['req']) && !$val && $this->columns[$key]['type']!='boolean'){
729
+ $this->error(sprintf(__('Field "%1$s" is required in table "%2$s".',WYSIJA), $key,$this->table_name),true);
730
+ $error=true;
731
+ }
732
+ /* let's correct the type of the values based on the one defined in the model*/
733
+ switch($this->columns[$key]['type']){
734
+ case "email":
735
+ $userHelper = WYSIJA::get('user','helper');
736
+ if(!$userHelper->validEmail($val)){
737
+ $this->error(sprintf(__('Field "%1$s" needs to be a valid Email.',WYSIJA), $key),true);
738
+ $error=true;
739
+ }
740
+ break;
741
+ }
742
+ }
743
+
744
+ if($error) return false;
745
+ return true;
746
+ }
747
+
748
+ /**
749
+ * delete procedure
750
+ * @global type $wpdb
751
+ * @param type $conditions
752
+ * @return type
753
+ */
754
+ function delete($conditions){
755
+ $query='DELETE FROM `'.$this->getPrefix().$this->table_name.'`';
756
+
757
+ if($this->setConditions($conditions)){
758
+ $whereQuery=$this->makeWhere();
759
+ if(!$whereQuery){
760
+ $this->error('Cannot delete element without conditions in model : '.get_class($this));
761
+ }
762
+ }else{
763
+ $this->error('Cannot delete element without conditions in model : '.get_class($this));
764
+ return false;
765
+ }
766
+ $result=$this->beforeDelete($conditions);
767
+ if($result) $result=$this->query($query.$whereQuery);
768
+ else return false;
769
+ $this->afterDelete();
770
+
771
+ return true;
772
+ }
773
+
774
+ function exists($conditions){
775
+
776
+ $query='SELECT '.$this->getPk().' FROM `'.$this->getSelectTableName().'`';
777
+
778
+ $query.=$this->makeJoins();
779
+ if($this->setConditions($conditions)){
780
+ $whereQuery=$this->makeWhere();
781
+ if(!$whereQuery){
782
+ $this->error('Cannot test element without conditions in model : '.get_class($this));
783
+ }
784
+ }else{
785
+ $this->error('Cannot test element without conditions in model : '.get_class($this));
786
+ return false;
787
+ }
788
+ $res=$this->query('get_res',$query.$whereQuery, ARRAY_A);
789
+ if($res) return $res;
790
+ else return false;
791
+ }
792
+
793
+ function getPk($numb=0){
794
+ $pk=$this->pk;
795
+ if(is_array($pk)) $pk=$pk[$numb];
796
+ return $pk;
797
+ }
798
+
799
+ /**
800
+ * set the values after verifying them
801
+ * @param type $values
802
+ * @return type
803
+ */
804
+ function setValues($values){
805
+ if($this->colCheck && !$this->checkAreColumns($values)) return false;
806
+
807
+ $this->values=array();
808
+ $this->values=$values;
809
+ return true;
810
+ }
811
+
812
+ /**
813
+ *
814
+ * @param type $values
815
+ * @return type
816
+ */
817
+ function setJoin($joins){
818
+ $this->joins=$joins;
819
+ return true;
820
+ }
821
+
822
+ /**
823
+ * set the conditions after verifying them
824
+ * @param type $conditions
825
+ * @return type
826
+ */
827
+ function setConditions($conditions,$update=false){
828
+ if($conditions && is_array($conditions)){
829
+
830
+ $this->conditions=array();
831
+ if($update){
832
+ foreach($conditions as $key =>$cond){
833
+ if($this->colCheck && !$this->checkAreColumns($conditions)) return false;
834
+
835
+ if(is_array($cond)){
836
+ $this->specialUpdate=true;
837
+ $this->conditions=$conditions;
838
+
839
+ return true;
840
+ }else $this->conditions[$key]=$cond;
841
+
842
+ }
843
+ } else {
844
+ foreach($conditions as $key => $cond) {
845
+ if(!in_array($key, $this->comparisonKeys /*array('like','equal','notequal','greater','less','greater_eq','less_eq')*/)){
846
+ if($this->colCheck && !$this->checkAreColumns($conditions)) return false;
847
+ if(array_key_exists('equal', $this->conditions) === false) $this->conditions['equal'] = array();
848
+ $this->conditions['equal'][$key] = $cond;
849
+ }else{
850
+ if($this->colCheck && !$this->checkAreColumns($cond)) return false;
851
+ $this->conditions[$key]=$cond;
852
+ }
853
+
854
+ }
855
+ }
856
+
857
+ return true;
858
+ }else return false;
859
+ }
860
+
861
+ /**
862
+ * check that the columns corresponds to the columns in the model
863
+ * @param type $arrayColumns
864
+ * @return type
865
+ */
866
+ function checkAreColumns($columns){
867
+ if($this->noCheck) return true;
868
+ foreach($columns as $column => $values) {
869
+ // skip when column is a comparison key
870
+ if(in_array($column, $this->comparisonKeys)) continue;
871
+
872
+ $columnName = $column;
873
+ if(!isset($this->columns[$columnName])){
874
+ $this->error(sprintf('Column %1$s does not exist in model : %2$s', $columnName, get_class($this)));
875
+ return false;
876
+ }
877
+ }
878
+ return true;
879
+ }
880
+
881
+ function timer_start() {
882
+ $this->query_duration = 0;
883
+ $this->time_start = microtime( true );
884
+ return true;
885
+ }
886
+
887
+ function timer_stop() {
888
+ $this->query_duration = ( microtime( true ) - $this->time_start );
889
+ }
890
+
891
+ function query($query,$arg2='',$arg3=ARRAY_A){
892
+ global $wpdb;
893
+ $this->sql_error = false;
894
+ if(!$arg2) $query = str_replace(array('[wysija]','[wp]'),array($this->getPrefix(),$wpdb->prefix),$query);
895
+ else $arg2 = str_replace(array('[wysija]','[wp]'),array($this->getPrefix(),$wpdb->prefix),$arg2);
896
+
897
+ // if dbg is on we track the duration of the query
898
+ if($this->dbg){
899
+ $this->timer_start();
900
+ }
901
+
902
+ switch($query){
903
+ case 'get_row':
904
+ $result = $wpdb->get_row($arg2,$arg3);
905
+ $this->logError();
906
+ break;
907
+ case 'get_res':
908
+ $result = $wpdb->get_results($arg2,$arg3);
909
+ //$this->escapeQuotesFromRes($results);
910
+ $this->logError();
911
+ break;
912
+ default:
913
+ $result = $wpdb->query($query);
914
+ $this->logError();
915
+
916
+ // get the last insert id if it's an insert query
917
+ if(substr($query, 0, 6) == 'INSERT') $result = $wpdb->insert_id;
918
+
919
+ }
920
+ // if dbg is on we track the duration of the query
921
+ if($this->dbg){
922
+ $this->timer_stop();
923
+ $this->keepQry('query');
924
+ }
925
+ return $result;
926
+ }
927
+
928
+ function logError(){
929
+ if(defined('WYSIJA_DBG') && WYSIJA_DBG>1){
930
+ global $wysija_queries_errors, $wpdb;
931
+ if(!$wysija_queries_errors) $wysija_queries_errors=array();
932
+
933
+ $this->sql_error=mysql_error($wpdb->dbh);
934
+
935
+ if($this->sql_error) {
936
+ $wysija_queries_errors[]=$this->sql_error;
937
+ WYSIJA::log('queries_errors',$this->sql_error,'query_errors');
938
+ }
939
+
940
+ }
941
+
942
+ }
943
+
944
+ function keepQry($from='wpdb'){
945
+ global $wpdb,$wysija_queries;
946
+
947
+ //if($qry) $wysija_queries['[FROM '.$from.']'] = array('duration' => $this->query_duration , 'query' => $qry);
948
+ //else
949
+ $wysija_queries[$from][] = array('duration' => $this->query_duration , 'query' => $wpdb->last_query);
950
+ }
951
+
952
+ function getAffectedRows(){
953
+ global $wpdb;
954
+ return $wpdb->rows_affected;
955
+ //return mysql_affected_rows( $this->dbh );
956
+ }
957
+
958
+ function getErrorMsg(){
959
+ global $wpdb;
960
+ return $wpdb->show_errors();
961
+ }
962
+ /**
963
+ * get the full prefix for the table
964
+ * @global type $wpdb
965
+ * @return type
966
+ */
967
+ function getPrefix(){
968
+ if($this->tableWP) return $this->wpprefix.$this->table_prefix;
969
+ else return $this->wpprefix.$this->table_prefix.'_';
970
+ }
971
+
972
+ /**
973
+ * this function allows you to get the prefix from the main site on a multisite
974
+ * @return type
975
+ */
976
+ function get_site_prefix($blog_id=1){
977
+
978
+ switch_to_blog( $blog_id );
979
+ global $wpdb;
980
+ $main_site_prefix=$wpdb->prefix;
981
+ restore_current_blog();
982
+
983
+ if($this->tableWP) return $main_site_prefix.$this->table_prefix;
984
+ else return $main_site_prefix.$this->table_prefix.'_';
985
+ }
986
+
987
+ /**
988
+ *
989
+ * @param type $field_name name of field which will become a key
990
+ * @param array $dataset list of records
991
+ * @param boolean $removing_field_name decide if we should remove field name from output dataset
992
+ * @param string $field_name_as_value a field in which we consider its value as value of $field_name
993
+ * @return array field based indexed dataset
994
+ */
995
+ protected function indexing_dataset_by_field($field_name, Array $dataset, $removing_field_name = false, $field_name_as_value = null){
996
+ if (empty($dataset))
997
+ return array();
998
+ $tmp = array();
999
+ foreach ($dataset as $record){
1000
+ if (isset($record[$field_name]))
1001
+ {
1002
+ if (!empty($field_name_as_value)){
1003
+ $tmp[$record[$field_name]] = isset($record[$field_name_as_value]) ? $record[$field_name_as_value] : null;
1004
+ continue;
1005
+ }
1006
+ $tmp[$record[$field_name]] = $record;
1007
+ if ($removing_field_name)
1008
+ unset($tmp[$record[$field_name]][$field_name]);
1009
+ }
1010
+
1011
+ }
1012
+ return $tmp;
1013
+ }
1014
+
1015
+ function beforeInsert(){
1016
+ return true;
1017
+ }
1018
+
1019
+ function afterInsert($resultSaveID){
1020
+ return true;
1021
+ }
1022
+ function beforeDelete($conditions){
1023
+ return true;
1024
+ }
1025
+
1026
+ function afterDelete(){
1027
+ return true;
1028
+ }
1029
+
1030
+ function beforeUpdate($id = null){
1031
+ return true;
1032
+ }
1033
+
1034
+ function afterUpdate($resultSaveID){
1035
+ return true;
1036
+ }
1037
 
1038
  }
core/module/module.php CHANGED
@@ -3,19 +3,19 @@
3
  defined('WYSIJA') or die('Restricted access');
4
 
5
  class WYSIJA_module extends WYSIJA_control{
6
-
7
  /**
8
  * ID of module
9
  * @var string
10
  */
11
  protected $name;
12
-
13
  /**
14
  * view class of module
15
  * @var string
16
  */
17
  public $view;
18
-
19
  /**
20
  * instance of view class of module
21
  * @var string
@@ -27,74 +27,74 @@ class WYSIJA_module extends WYSIJA_control{
27
  * action/view of a hook
28
  * @var string
29
  */
30
-
31
  protected $view_show;
32
-
33
  /**
34
  * data which view class will pull from
35
  * @var array
36
  */
37
  protected $data;
38
-
39
  protected $extended_plugin='wysija-newsletters';
40
-
41
 
42
 
43
  /**
44
  * Define hook name and list of modules of each hook
45
  * @var Array
46
  * @todo: implement hook management which allows to manage hooks from admin side
47
- */
48
-
49
  protected $is_premium = false;
50
-
51
  public static $hooks = array(
52
  'hook_stats' => array(
53
  // 'stats_newsletters_in_time',
54
- 'stats_top_newsletters',
55
  'stats_top_subscribers',
56
  'stats_top_links',
57
  'stats_new_subscribers',
58
  'stats_subscriptions',
59
  'stats_top_domains'
60
  ),
61
-
62
  // the left block in the page "subscriber detail"
63
  'hook_subscriber_left' => array(
64
  ),
65
-
66
  // the righ block in the page "subscriber detail"
67
  'hook_subscriber_right' => array(
68
  'stats_subscriber'
69
- ),
70
  'hook_subscriber_bottom' => array(
71
  'stats_subscribers_std',
72
  // 'stats_newsletters_in_time' // not in use
73
  ),
74
  // top of newsletter (viewstats) page
75
  'hook_newsletter_top' => array(
76
-
77
  'stats_newsletter_std',
78
  'stats_newsletter',
79
  // 'stats_reportcards_std'
80
  ),
81
-
82
  // Newsletters >> Newsletter detail: bottom block
83
  'hook_newsletter_bottom' => array(
84
  //'stats_newsletter_std',
85
  // 'stats_newsletters_in_time'
86
  ),
87
-
88
  // the block "super advanced" in Settings >> Advanced tab
89
  'hook_settings_super_advanced' => array(
90
  'archive_std'
91
  ),
92
-
93
  // event: before saving settings (Admin)
94
  'hook_settings_before_save' => array(
95
  'archive_std'
96
  )
97
- );
98
  /**
99
  * Constructor
100
  * This is neccessary to override default action of WYSIJA_control::WYSIJA_control(),
@@ -110,16 +110,16 @@ class WYSIJA_module extends WYSIJA_control{
110
  if (!empty($this->view_obj) && !empty($this->model_obj)){
111
  $this->view_obj->model = $this->model_obj;
112
  }
113
-
114
  $this->data['module_name'] = $this->name;
115
-
116
-
117
  $model_config=WYSIJA::get('config','model');
118
  if($model_config->getValue('premium_key'))
119
  $this->is_premium = true;
120
  $this->data['is_premium'] = $this->is_premium;
121
  }
122
-
123
  /**
124
  * get name of module
125
  * @return string
@@ -127,7 +127,7 @@ class WYSIJA_module extends WYSIJA_control{
127
  public function get_name(){
128
  return $this->name;
129
  }
130
-
131
  /**
132
  * Get unique link to the module and hook. This link will be displayed as an independent page and actually it renders [wysijap] postype
133
  * @param string $module_name
@@ -147,7 +147,7 @@ class WYSIJA_module extends WYSIJA_control{
147
  ));
148
  return WYSIJA::get_permalink($model_config->getValue('confirm_email_link'),$params);
149
  }
150
-
151
  /**
152
  * Return Hooks List
153
  * @param string $hook_name name of hook
@@ -161,7 +161,7 @@ class WYSIJA_module extends WYSIJA_control{
161
  return isset($modules[$module_name]) ? array($modules[$module_name]) : array();
162
  return $modules;
163
  }
164
-
165
  /**
166
  * Get all registered hooks and modules
167
  * @return Array
@@ -175,9 +175,9 @@ class WYSIJA_module extends WYSIJA_control{
175
  * @param string $hook_name
176
  * @param string $params
177
  * @param string $extended_plugin
178
- *
179
- * @todo Performance factor:
180
- * We are calling the same method for free / Premium version.
181
  * Some modules don't exist at free side.
182
  * Some modules don't exist at Premium side.
183
  * This fact leads to an other fact: we have to check_exist() in both cases.
@@ -190,23 +190,23 @@ class WYSIJA_module extends WYSIJA_control{
190
  foreach (self::$hooks[$hook_name] as $module_name){
191
  $module = WYSIJA::get($module_name,'module',false,$extended_plugin);
192
  if(!empty($module) && method_exists($module, $hook_name))
193
- $hook_output .= $module->$hook_name($params);
194
  }
195
  }
196
  return $hook_output;
197
  }
198
-
199
  /**
200
  * get an instance of a module class
201
  * @param string $module_name module to be loaded
202
  * @param type $extended_plugin : used only when calling the url from a different plugin it is used watch those files :
203
  * -core/controller.php line 21, 23 ,24
204
  * @return an instance of WYSIJA_module or its derived classes
205
- */
206
  public static function get_instance_by_name($module_name,$extended_plugin='wysija-newsletters'){
207
  return WYSIJA::get($module_name,'module',false, $extended_plugin);
208
  }
209
-
210
  /**
211
  * Render a view/action
212
  * @return string
@@ -226,22 +226,22 @@ class WYSIJA_module extends WYSIJA_control{
226
  }
227
  }
228
  }
229
-
230
  /**
231
  * initialize WYSIJA_view instance
232
  * @return WYSIJA_view
233
  */
234
  protected function get_view_obj(){
235
  require_once(WYSIJA_CORE.'view.php');
236
- require_once(WYSIJA_VIEWS.WYSIJA_SIDE.'.php');
237
  if (empty($this->view_obj)){
238
-
239
- $view_dir=WYSIJA_PLG_DIR.$this->extended_plugin.DS.'modules'.DS.$this->name; // quickfix, @todo
240
  $class_path=$view_dir.DS.$this->view.'.php';// @todo: check exists
241
  $class_name = strtoupper('wysija').'_module_view_'.$this->view;
242
  require_once(WYSIJA_CORE.'view.php');
243
  require_once($class_path);
244
- $this->view_obj = new $class_name();
245
  }
246
  return $this->view_obj;
247
  }
3
  defined('WYSIJA') or die('Restricted access');
4
 
5
  class WYSIJA_module extends WYSIJA_control{
6
+
7
  /**
8
  * ID of module
9
  * @var string
10
  */
11
  protected $name;
12
+
13
  /**
14
  * view class of module
15
  * @var string
16
  */
17
  public $view;
18
+
19
  /**
20
  * instance of view class of module
21
  * @var string
27
  * action/view of a hook
28
  * @var string
29
  */
30
+
31
  protected $view_show;
32
+
33
  /**
34
  * data which view class will pull from
35
  * @var array
36
  */
37
  protected $data;
38
+
39
  protected $extended_plugin='wysija-newsletters';
40
+
41
 
42
 
43
  /**
44
  * Define hook name and list of modules of each hook
45
  * @var Array
46
  * @todo: implement hook management which allows to manage hooks from admin side
47
+ */
48
+
49
  protected $is_premium = false;
50
+
51
  public static $hooks = array(
52
  'hook_stats' => array(
53
  // 'stats_newsletters_in_time',
54
+ 'stats_top_newsletters',
55
  'stats_top_subscribers',
56
  'stats_top_links',
57
  'stats_new_subscribers',
58
  'stats_subscriptions',
59
  'stats_top_domains'
60
  ),
61
+
62
  // the left block in the page "subscriber detail"
63
  'hook_subscriber_left' => array(
64
  ),
65
+
66
  // the righ block in the page "subscriber detail"
67
  'hook_subscriber_right' => array(
68
  'stats_subscriber'
69
+ ),
70
  'hook_subscriber_bottom' => array(
71
  'stats_subscribers_std',
72
  // 'stats_newsletters_in_time' // not in use
73
  ),
74
  // top of newsletter (viewstats) page
75
  'hook_newsletter_top' => array(
76
+
77
  'stats_newsletter_std',
78
  'stats_newsletter',
79
  // 'stats_reportcards_std'
80
  ),
81
+
82
  // Newsletters >> Newsletter detail: bottom block
83
  'hook_newsletter_bottom' => array(
84
  //'stats_newsletter_std',
85
  // 'stats_newsletters_in_time'
86
  ),
87
+
88
  // the block "super advanced" in Settings >> Advanced tab
89
  'hook_settings_super_advanced' => array(
90
  'archive_std'
91
  ),
92
+
93
  // event: before saving settings (Admin)
94
  'hook_settings_before_save' => array(
95
  'archive_std'
96
  )
97
+ );
98
  /**
99
  * Constructor
100
  * This is neccessary to override default action of WYSIJA_control::WYSIJA_control(),
110
  if (!empty($this->view_obj) && !empty($this->model_obj)){
111
  $this->view_obj->model = $this->model_obj;
112
  }
113
+
114
  $this->data['module_name'] = $this->name;
115
+
116
+
117
  $model_config=WYSIJA::get('config','model');
118
  if($model_config->getValue('premium_key'))
119
  $this->is_premium = true;
120
  $this->data['is_premium'] = $this->is_premium;
121
  }
122
+
123
  /**
124
  * get name of module
125
  * @return string
127
  public function get_name(){
128
  return $this->name;
129
  }
130
+
131
  /**
132
  * Get unique link to the module and hook. This link will be displayed as an independent page and actually it renders [wysijap] postype
133
  * @param string $module_name
147
  ));
148
  return WYSIJA::get_permalink($model_config->getValue('confirm_email_link'),$params);
149
  }
150
+
151
  /**
152
  * Return Hooks List
153
  * @param string $hook_name name of hook
161
  return isset($modules[$module_name]) ? array($modules[$module_name]) : array();
162
  return $modules;
163
  }
164
+
165
  /**
166
  * Get all registered hooks and modules
167
  * @return Array
175
  * @param string $hook_name
176
  * @param string $params
177
  * @param string $extended_plugin
178
+ *
179
+ * @todo Performance factor:
180
+ * We are calling the same method for free / Premium version.
181
  * Some modules don't exist at free side.
182
  * Some modules don't exist at Premium side.
183
  * This fact leads to an other fact: we have to check_exist() in both cases.
190
  foreach (self::$hooks[$hook_name] as $module_name){
191
  $module = WYSIJA::get($module_name,'module',false,$extended_plugin);
192
  if(!empty($module) && method_exists($module, $hook_name))
193
+ $hook_output .= $module->$hook_name($params);
194
  }
195
  }
196
  return $hook_output;
197
  }
198
+
199
  /**
200
  * get an instance of a module class
201
  * @param string $module_name module to be loaded
202
  * @param type $extended_plugin : used only when calling the url from a different plugin it is used watch those files :
203
  * -core/controller.php line 21, 23 ,24
204
  * @return an instance of WYSIJA_module or its derived classes
205
+ */
206
  public static function get_instance_by_name($module_name,$extended_plugin='wysija-newsletters'){
207
  return WYSIJA::get($module_name,'module',false, $extended_plugin);
208
  }
209
+
210
  /**
211
  * Render a view/action
212
  * @return string
226
  }
227
  }
228
  }
229
+
230
  /**
231
  * initialize WYSIJA_view instance
232
  * @return WYSIJA_view
233
  */
234
  protected function get_view_obj(){
235
  require_once(WYSIJA_CORE.'view.php');
236
+ require_once(WYSIJA_VIEWS.WYSIJA_SIDE.'.php');
237
  if (empty($this->view_obj)){
238
+
239
+ $view_dir=WYSIJA_PLG_DIR.$this->extended_plugin.DS.'modules'.DS.$this->name; // quickfix, @todo
240
  $class_path=$view_dir.DS.$this->view.'.php';// @todo: check exists
241
  $class_name = strtoupper('wysija').'_module_view_'.$this->view;
242
  require_once(WYSIJA_CORE.'view.php');
243
  require_once($class_path);
244
+ $this->view_obj = new $class_name();
245
  }
246
  return $this->view_obj;
247
  }
core/view.php CHANGED
@@ -193,13 +193,7 @@ class WYSIJA_view extends WYSIJA_object{
193
 
194
  if(count($messages)>0){
195
  foreach($messages as $msg){
196
- // check type of msg variable
197
- if(is_array($msg)) {
198
- $msg = var_export($msg, true);
199
- }
200
-
201
- // display message
202
- $html.='<li>'.$msg.'</li>';
203
  }
204
  }
205
 
193
 
194
  if(count($messages)>0){
195
  foreach($messages as $msg){
196
+ $html.='<li>'.$msg.'</li>';
 
 
 
 
 
 
197
  }
198
  }
199
 
css/admin-campaigns-dividers.css CHANGED
@@ -1 +1 @@
1
- .wysija_popup_content.divider{width:620px}.dividers ul{height:350px;width:620px;overflow:auto;margin:0 0 20px 0}.dividers li{text-align:center;padding:5px 2px}.dividers li a{padding:2px;display:block}.dividers li a.selected{padding:0;border:2px solid #DD561A}.dividers li img{vertical-align:middle}
1
+ .wysija_popup_content.divider{width:620px}.dividers ul{height:400px;width:620px;overflow:auto;margin:0 0 20px 0}.dividers li{text-align:center;padding:5px 2px}.dividers li a{padding:2px;display:block}.dividers li a.selected{padding:0;border:2px solid #DD561A}.dividers li img{vertical-align:middle}
css/admin-campaigns-medias.css CHANGED
@@ -1 +1 @@
1
- .swfupload{vertical-align:middle}ul#sidemenu{bottom:-1px;float:none !important;font-weight:normal;left:0;margin:0 5px;overflow:hidden;float:none !important}.wysija-thumb{float:left;height:150px;margin:10px;width:150px;position:relative;border:2px dashed transparent;filter:alpha(opacity=60);-moz-opacity:0.6;opacity:0.6;margin:8px}.wysija-thumb:hover,.wysija-thumb.selected:hover{border-color:#000;border-style:dashed}.wysija-thumb.selected{border-color:#4a5b04;border-style:solid;filter:alpha(opacity=100);-moz-opacity:1;opacity:1}.wysija-thumb img{cursor:pointer;max-height:150px;max-width:150px}.wysija-thumb span.delete{background:url("../img/controls/icons.png") no-repeat scroll -100px 0 transparent;cursor:pointer;height:20px;text-indent:-9999px;display:block;width:20px}.wysija-thumb span.delete-wrap{background-color:#DFDFDF;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);border:1px solid #CCCCCC;border-radius:2px 2px 2px 2px;box-shadow:0 1px 0 rgba(0,0,0,0.15),0 0 2px 1px #fff inset;height:20px;position:absolute;right:2px;top:2px;margin:5px 3px 0 0;width:20px;display:none}.wysija-thumb span.thumb_url,.wysija-thumb span.url,.wysija-thumb span.width,.wysija-thumb span.height,.wysija-thumb span.identifier{display:none}.wysija-thumb:hover span.delete-wrap{display:block}.wysija-thumb span.delete:hover{background-position:-100px -20px}.clear{clear:both}.tablenav{margin-right:20px}#media-items{overflow:auto}.media-wp-upload #media-items{display:none}.media-browse #media-items{width:100%;height:340px;margin:0 0 10px 0}.media-wp-browse #media-items{width:100%;height:340px;margin:0 0 10px 0}#media-items em{margin:0 0 0 20px}#media-items,.ml-submit{float:left}.ml-submit{margin-top:15px;margin-left:15px}#loader{left:50%;position:relative;top:50%}#overlay{background-color:#FFFFFF;height:100%;opacity:0.8;position:absolute;width:100%;z-index:999;display:none}#flash-upload-ui{padding:10px 25px}.after-file-upload{padding:0 25px}.after-file-upload,.upload-flash-bypass,.howto{display:none}.wysija-thumb .slidetoggle,.wysija-thumb .toggle{display:none}.max-upload-size{margin:10px 0;display:block}
1
+ .swfupload{vertical-align:middle}ul#sidemenu{bottom:-1px;float:none !important;font-weight:normal;left:0;margin:0 5px;overflow:hidden;float:none !important}.wysija-thumb{float:left;height:150px;margin:10px;width:150px;position:relative;border:2px dashed transparent;filter:alpha(opacity=60);-moz-opacity:0.6;opacity:0.6;margin:8px}.wysija-thumb:hover,.wysija-thumb.selected:hover{border-color:#000;border-style:dashed}.wysija-thumb.selected{border-color:#4a5b04;border-style:solid;filter:alpha(opacity=100);-moz-opacity:1;opacity:1}.wysija-thumb img{max-height:150px;max-width:150px}.wysija-thumb span.delete{background:url("../img/controls/icons.png") no-repeat scroll -100px 0 transparent;cursor:pointer;height:20px;text-indent:-9999px;display:block;width:20px}.wysija-thumb span.delete-wrap{background-color:#DFDFDF;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);border:1px solid #CCCCCC;border-radius:2px 2px 2px 2px;box-shadow:0 1px 0 rgba(0,0,0,0.15),0 0 2px 1px #fff inset;height:20px;position:absolute;right:2px;top:2px;margin:5px 3px 0 0;width:20px;display:none}.wysija-thumb span.thumb_url,.wysija-thumb span.url,.wysija-thumb span.width,.wysija-thumb span.height,.wysija-thumb span.identifier{display:none}.wysija-thumb:hover span.delete-wrap{display:block}.wysija-thumb span.delete:hover{background-position:-100px -20px}.clear{clear:both}.tablenav{margin-right:20px}#media-items{overflow:auto}.media-wp-upload #media-items{display:none}.media-browse #media-items{width:100%;height:340px;margin:0 0 10px 0}.media-wp-browse #media-items{width:100%;height:340px;margin:0 0 10px 0}#media-items em{margin:0 0 0 20px}#media-items,.ml-submit{float:left}.ml-submit{margin-top:15px;margin-left:15px}#loader{left:50%;position:relative;top:50%}#overlay{background-color:#FFFFFF;height:100%;opacity:0.8;position:absolute;width:100%;z-index:999;display:none}#flash-upload-ui{padding:10px 25px}.after-file-upload{padding:0 25px}.after-file-upload,.upload-flash-bypass,.howto{display:none}.wysija-thumb .slidetoggle,.wysija-thumb .toggle{display:none}.max-upload-size{margin:10px 0;display:block}
css/admin-campaigns-viewstats.css CHANGED
@@ -1 +1 @@
1
- #posts-filter{margin-top:40px}#hook_newsletter_top{margin-top:20px}#hook_newsletter_top .left{float:left;width:50%}#hook_newsletter_top .right{float:right}#hook_newsletter_top .actions{width:45%;margin-bottom:20px;padding-left:10px}.action_buttons a:first-child{margin-left:0}.action_buttons{display:block}table.newsletter-stats-block{margin-top:10px}table.newsletter-stats-block td.label{width:25%;font-weight:bold}.wrap .button-secondary2{top:auto !important}.googletrackingcode .action_buttons{padding-left:0}.googletrackingcode{padding-top:10px}.wrap .button-secondary2:first-child{margin-left:0}
1
+ #posts-filter{margin-top:40px}#hook_newsletter_top{margin-top:20px}#hook_newsletter_top .actions{width:25%;margin-bottom:20px;padding-left:10px}.action_buttons a:first-child{margin-left:0}.action_buttons{display:block}.wrap .button-secondary2{top:auto !important}.googletrackingcode .action_buttons{padding-left:0}.googletrackingcode{padding-top:10px}.wrap .button-secondary2:first-child{margin-left:0}
css/admin-campaigns.css CHANGED
@@ -1 +1 @@
1
- #wysija-app{padding-top:10px}.icon32{margin-top:0px !important}#posts-filter{clear:both}#wysija-app h2{display:inline}#icon-edit-news{background:url(../img/mail-big.png) no-repeat scroll 0 5px transparent}#TB_window{display:block}.moredetails{display:none}.sending,.scheduled{background-color:#d5f0e6}.autonl.sending{background-color:#D7E6F2}#wysija-campaign .listmissing{background-color:#EFD5D5}#preview-receiver{width:230px;vertical-align:middle;margin:0 5px 0 0}.ml-submit{margin:15px 15px 0 15px}.automatic-nl{display:none}#titlediv .titlebox{font-size:1.7em;background-color:#FFFFFF;border-color:#CCCCCC;line-height:100%;outline:medium none;padding:3px 8px;width:100%}label .description{cursor:auto}.about-wrap .feature-section.three-col div{float:left;width:28%}#socials-block div{float:none;margin:5px 5px 2px 0;width:100%}.progress_bar{padding-bottom:10px}.progress_bar .bar{display:block;width:100%;height:22px;float:left;margin-right:10px;background:#eef6fc;border:1px solid #bbbbbb;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;line-height:22px;position:relative}.progress_bar .progress{display:block;background:#69b1e9;height:100%}.progress_bar .percent{height:100%;position:absolute;top:0px;left:10px}#wysija-badge{position:absolute;top:0;right:0;color:#fff;text-shadow:0 1px 0 rgba(0,0,0,0.3);padding-top:91px;height:50px;width:173px;font-weight:bold;font-size:14px;text-align:center;margin:0 -5px;background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/wysija-badge.png") no-repeat}#review-follow{position:relative;height:177px}#review-follow div{float:left;top:0}#review-follow .review-left{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/save-the-kitten.jpg") no-repeat;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef;padding-right:10px}#review-follow h4{margin:0 !important}#review-follow .review-left.small{width:450px}#review-follow .review-left.medium{width:490px}#review-follow .review-left.large{width:540px}#review-follow .small .description{margin-top:24px}#review-follow .medium .description{margin-top:20px}#review-follow .large .description{margin-top:18px}#review-follow .review-left p{margin-left:20px}#review-follow .review-right{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow_middle.jpg") no-repeat scroll -30px 0 #f8f8f8;border-bottom:1px solid #EFEFEF;border-top:1px solid #EFEFEF;height:175px;width:24px}#review-follow #mailpoet-subscribe{margin-left:0px;margin-top:10px}#review-follow .subscribe-middle{width:220px;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef}#review-follow .socials{margin-left:30px}#review-follow .follow-left{width:220px;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef}#review-follow .follow-right{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow_right.jpg") no-repeat;width:100px;height:175px}#review-follow .follow-right38{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow-right-38.jpg") no-repeat;width:100px;height:175px}#review-follow .review-left .description{margin-left:146px}#review-follow .link-cat-review{height:140px;left:20px;position:absolute;top:21px;width:120px;outline:medium none}a.ctaupdate,span.ctaupdate{font-size:12px}.pds-links,.pds-totalvotes-outer{display:none !important}#polldaddy_embed_0{width:680px;margin-left:-30px}span.local_time{margin-left:10px}#hook_newsletter_top .hook-column{width:50%}.card-title{font-weight:bold}.report-card{padding-top:10px}.googletrackingcode .action_buttons{padding-left:44px;padding-top:5px}.googletrackingcode span{font-weight:bold}.mpoet-page h1{font-size:34px}.mpoet-page h1,.mpoet-page h2,.mpoet-page h3,.mpoet-page h4{color:#626262;font-weight:bold}.mpoet-page h1 span.version{color:#5e869b}
1
+ #wysija-app{padding-top:10px}.icon32{margin-top:0px !important}#posts-filter{clear:both}#wysija-app h2{display:inline}#icon-edit-news{background:url(../img/mail-big.png) no-repeat scroll 0 5px transparent}#TB_window{display:block}.moredetails{display:none}.sending,.scheduled{background-color:#d5f0e6}.autonl.sending{background-color:#D7E6F2}#wysija-campaign .listmissing{background-color:#EFD5D5}#preview-receiver{width:230px;vertical-align:middle;margin:0 5px 0 0}.ml-submit{margin:15px 15px 0 15px}.automatic-nl{display:none}#titlediv .titlebox{font-size:1.7em;background-color:#FFFFFF;border-color:#CCCCCC;line-height:100%;outline:medium none;padding:3px 8px;width:100%}label .description{cursor:auto}.about-wrap .feature-section.three-col div{float:left;width:28%}#socials-block div{float:none;margin:5px 5px 2px 0;width:100%}.progress_bar{padding-bottom:10px}.progress_bar .bar{display:block;width:100%;height:22px;float:left;margin-right:10px;background:#eef6fc;border:1px solid #bbbbbb;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;line-height:22px;position:relative}.progress_bar .progress{display:block;background:#69b1e9;height:100%}.progress_bar .percent{height:100%;position:absolute;top:0px;left:10px}#wysija-badge{position:absolute;top:0;right:0;color:#fff;text-shadow:0 1px 0 rgba(0,0,0,0.3);padding-top:91px;height:50px;width:173px;font-weight:bold;font-size:14px;text-align:center;margin:0 -5px;background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/wysija-badge.png") no-repeat}#review-follow{position:relative;height:177px}#review-follow div{float:left;top:0}#review-follow .review-left{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/save-the-kitten.jpg") no-repeat;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef;padding-right:10px}#review-follow h4{margin:0 !important}#review-follow .review-left.small{width:450px}#review-follow .review-left.medium{width:490px}#review-follow .review-left.large{width:540px}#review-follow .small .description{margin-top:24px}#review-follow .medium .description{margin-top:20px}#review-follow .large .description{margin-top:18px}#review-follow .review-left p{margin-left:20px}#review-follow .review-right{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow_middle.jpg") no-repeat;width:62px;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef}#review-follow .subscribe-middle{width:220px;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef}#review-follow .socials{margin-left:30px}#review-follow .follow-left{width:220px;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef}#review-follow .follow-right{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow_right.jpg") no-repeat;width:100px;height:175px}#review-follow .follow-right38{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow-right-38.jpg") no-repeat;width:100px;height:175px}#review-follow .review-left .description{margin-left:146px}#review-follow .link-cat-review{height:140px;left:20px;position:absolute;top:21px;width:120px;outline:medium none}a.ctaupdate,span.ctaupdate{font-size:12px}.pds-links,.pds-totalvotes-outer{display:none !important}#polldaddy_embed_0{width:680px;margin-left:-30px}span.local_time{margin-left:10px}#hook_newsletter_top .hook-column{width:50%}.card-title{font-weight:bold}.report-card{padding-top:10px}.googletrackingcode .action_buttons{padding-left:44px;padding-top:5px}.googletrackingcode span{font-weight:bold}.mpoet-page h1{font-size:34px}.mpoet-page h1,.mpoet-page h2,.mpoet-page h3,.mpoet-page h4{color:#626262;font-family:"Arial","Open Sans",sans-serif;font-weight:bold}.mpoet-page h1 span.version{color:#5e869b}
css/admin-config.css CHANGED
@@ -1 +1 @@
1
- tr.title_row>td{padding-left:0}#wysija-tabs a{font-size:14px}#wysija-tabs a:focus{outline:0 none}#wysija-settings .premium_activated{color:#0074A2;font-size:1.2em;padding:15px 0 20px 0}#wysija-settings .premium_activated i{font-size:1.5em;margin:0 6px 3px 0;vertical-align:bottom}p.submit{padding:1em 1.4em 1em 0}span.title{font-size:16px;margin:0;color:#000}.mailpoet-frequency_inner_texting{padding:0 10px}.mailpoet-frequency_warning{margin-top:10px}#wysija-settings input[type="checkbox"],#wysija-settings input[type="radio"]{margin-right:6px;vertical-align:baseline}#wysija-settings label input[type="checkbox"],#cron_page_hit_trigger-1{margin-left:0}#wysija-settings .button-secondary{margin-left:6px}#wysija-settings .form-table th{width:300px}#wysija-settings .form-table th.row{border:1px solid #AAAAAA}#warning-msg-frequency{background-color:#FFFFE0;border-color:#E6DB55}#warning-msg-frequency{border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;margin:5px 15px 2px;padding:0 0.6em}#warning-msg-frequency ul{margin:0}#wysija-settings .form-table th.rolestitle{padding:10px 0 10px 10px;text-align:left;vertical-align:middle;width:220px}#wysija-settings .form-table th.rolestable{padding:3px;text-align:center;vertical-align:middle;width:110px;word-wrap:break-word}#wysija-settings .form-table td.rolestable{padding:6px 0;text-align:center}#wysija-settings .form-table td.title{padding:10px 0 10px 10px;text-align:left;vertical-align:middle}#wysija-settings .form-table td.title p{margin:0}#wysija-settings .form-table td{vertical-align:top}#wysija-settings #bounce .intro{margin:10px 0 20px 10px}#wysija-settings #bounce #bounce-process-auto,#wysija-settings #bounce #bounce-connector{margin-left:0 !important}#wysija-settings #sendingmethod .methods{border-bottom:1px solid #000}#wysija-settings #sendingmethod .choice-sending-method-site{border-top:1px solid #cccccc}#wysija-settings #sendingmethod .choice-sending-method-site th,#wysija-settings #sendingmethod .choice-sending-method-site td{padding-top:18px}label.dkim{margin-right:20px}.cronleft,.cronright{float:left}.cronleft{width:20px;margin-right:10px}#cron_manual_linkname p{margin:0}.labelcheck{float:left;margin-right:15px}.checkbox_optin_label{margin:6px 6px 0 0;float:left}.checkbox_optin_value{float:left;width:500px}#smtp-rest-label{display:none;margin-left:10px}#wysija-settings #multisite #form-ms-config th{width:455px}#wysija-settings #multisite #ms-sendingmethod th{width:300px}#wysija-settings #multisite .intro{margin:0 0 0 10px}#wysija-settings #sendingmethod .methods input,#wysija-settings #multisite .methods input{margin:0 5px 0 0;float:left}#wysija-settings #sendingmethod .methods h3,#wysija-settings #multisite .methods p.title{float:left;margin:0 !important}#wysija-settings #multisite .choice-one-for-all{display:none}#wysija-settings a.view_all{font-style:italic}#wysija-settings .cronright label{display:block;margin-bottom:10px}#wysija-settings .cronright label span{margin-left:36px}#wysija-settings .capabilities_form{width:400px}span.icon{display:block;height:20px;width:20px;cursor:pointer}.geeky-option a,.geeky-option span{float:left}.show-more-geeky-options span{background:url(../img/controls/icons.png) no-repeat -200px 0}.show-more-geeky-options:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.hide-geeky-options span{background:url(../img/controls/icons.png) no-repeat -220px 0}.hide-geeky-options:hover span{background:url(../img/controls/icons.png) no-repeat -220px -20px}@-webkit-keyframes opacity{0%{opacity:1}100%{opacity:0}}@-moz-keyframes opacity{0%{opacity:1}100%{opacity:0}}.wysija-button-loading{text-align:center;margin:100px 0 0 0}.wysija-button-loading span{-webkit-animation-name:opacity;-webkit-animation-duration:1s;-webkit-animation-iteration-count:infinite;-moz-animation-name:opacity;-moz-animation-duration:1s;-moz-animation-iteration-count:infinite}.wysija-button-loading span:nth-child(2){-webkit-animation-delay:100ms;-moz-animation-delay:100ms}.wysija-button-loading span:nth-child(3){-webkit-animation-delay:300ms;-moz-animation-delay:300ms}.links-page{display:none;margin-left:10px}.new_form{margin:16px 0}.new_form a{font-size:16px !important}
1
+ tr.title_row>td{padding-left:0}#wysija-tabs a{font-size:14px}#wysija-tabs a.tab-premium{background-color:#d7e6f2;font-weight:bold}p.submit{padding:1em 1.4em 1em 0}span.title{font-size:16px;margin:0;color:#000}.choice-under15,.ms-choice-under15{float:right;display:block;width:360px}#wysija-settings input[type="checkbox"],#wysija-settings input[type="radio"]{margin-right:6px;vertical-align:baseline}#wysija-settings label input[type="checkbox"],#cron_page_hit_trigger-1{margin-left:0}#wysija-settings .button-secondary{margin-left:6px}#wysija-settings .form-table th{width:300px}#wysija-settings .form-table th.row{border:1px solid #AAAAAA}#warning-msg-frequency{background-color:#FFFFE0;border-color:#E6DB55}#warning-msg-frequency{border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;margin:5px 15px 2px;padding:0 0.6em}#warning-msg-frequency ul{margin:0}#wysija-settings .form-table th.rolestitle{padding:10px 0 10px 10px;text-align:left;vertical-align:middle;width:220px}#wysija-settings .form-table th.rolestable{padding:3px;text-align:center;vertical-align:middle;width:110px;word-wrap:break-word}#wysija-settings .form-table td.rolestable{padding:6px 0;text-align:center}#wysija-settings .form-table td.title{padding:10px 0 10px 10px;text-align:left;vertical-align:middle}#wysija-settings .form-table td.title p{margin:0}#wysija-settings .form-table td{vertical-align:top}#wysija-settings #bounce .intro{margin:10px 0 20px 10px}#wysija-settings #bounce #bounce-process-auto,#wysija-settings #bounce #bounce-connector{margin-left:0 !important}#wysija-settings #sendingmethod .methods{border-bottom:1px solid #000}#wysija-settings #sendingmethod .choice-sending-method-site{border-top:1px solid #cccccc}#wysija-settings #sendingmethod .choice-sending-method-site th,#wysija-settings #sendingmethod .choice-sending-method-site td{padding-top:18px}label.dkim{margin-right:20px}.cronleft,.cronright{float:left}.cronleft{width:20px;margin-right:10px}#cron_manual_linkname p{margin:0}.labelcheck{float:left;margin-right:15px}.checkbox_optin_label{margin:6px 6px 0 0;float:left}.checkbox_optin_value{float:left;width:500px}#smtp-rest-label{display:none;margin-left:10px}#wysija-settings #multisite #form-ms-config th{width:455px}#wysija-settings #multisite #ms-sendingmethod th{width:300px}#wysija-settings #multisite .intro{margin:0 0 0 10px}#wysija-settings #sendingmethod .methods input,#wysija-settings #multisite .methods input{margin:0 5px 0 0;float:left}#wysija-settings #sendingmethod .methods h3,#wysija-settings #multisite .methods p.title{float:left;margin:0 !important}#wysija-settings #multisite .choice-one-for-all{display:none}#wysija-settings a.view_all{font-style:italic}#wysija-settings .cronright label{display:block;margin-bottom:10px}#wysija-settings .cronright label span{margin-left:36px}#wysija-settings .capabilities_form{width:400px}span.icon{display:block;height:20px;width:20px;cursor:pointer}.geeky-option a,.geeky-option span{float:left}.show-more-geeky-options span{background:url(../img/controls/icons.png) no-repeat -200px 0}.show-more-geeky-options:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.hide-geeky-options span{background:url(../img/controls/icons.png) no-repeat -220px 0}.hide-geeky-options:hover span{background:url(../img/controls/icons.png) no-repeat -220px -20px}@-webkit-keyframes opacity{0%{opacity:1}100%{opacity:0}}@-moz-keyframes opacity{0%{opacity:1}100%{opacity:0}}.wysija-button-loading{text-align:center;margin:100px 0 0 0}.wysija-button-loading span{-webkit-animation-name:opacity;-webkit-animation-duration:1s;-webkit-animation-iteration-count:infinite;-moz-animation-name:opacity;-moz-animation-duration:1s;-moz-animation-iteration-count:infinite}.wysija-button-loading span:nth-child(2){-webkit-animation-delay:100ms;-moz-animation-delay:100ms}.wysija-button-loading span:nth-child(3){-webkit-animation-delay:300ms;-moz-animation-delay:300ms}.links-page{display:none;margin-left:10px}.new_form{margin:16px 0}.new_form a{font-size:16px !important}
css/admin-global.css CHANGED
@@ -1 +1 @@
1
- .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}.hide{display:none}.wysija-version{margin:0 20px 0 165px;padding-bottom:45px}.wysija-footer h2{color:#21759B;cursor:pointer}.wysija-footer h2:hover{text-decoration:underline}.wysija-version{font-size:12px;color:#777777}.wysija-version .social-foot div{float:left;margin-right:10px}.wysija-version .version{float:left}.wysija-version .help{float:left;margin-left:20px}.wysija-version .social-foot .textsocial{margin-left:8px;margin-top:3px;padding-top:0}.wysija-version .social-foot{clear:both;display:inline-block}.wysija-version .version{float:left;margin-bottom:5px}#upperfoot{display:block;float:none}#submitexport label input[type="checkbox"]{margin-left:0px !important}.clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}.wysija-footer,.wysija-version{margin:0 20px 0 165px;padding-bottom:45px}.wysija-footer h2{color:#21759B;cursor:pointer}.wysija-footer h2:hover{text-decoration:underline}.wysija-version{font-size:12px;color:#777777;height:65px;border-top:1px solid #DFDFDF}.wysija-version .social-foot div{float:left;margin-right:10px}.social-foot .fb{width:80px}.wysija-version .version{float:left}.wysija-version .help{float:left;margin-left:20px}.wysija-version .social-foot .textsocial{margin-left:8px;margin-top:3px;padding-top:0}.wysija-version .social-foot{clear:both;display:inline-block;float:left;margin-top:2px;padding:6px 13px}.wysija-version .social-foot .socials div{margin-left:20px}.wysija-version .social-foot .socials{margin-left:0px}.wysija-version .social-foot .socials .fb,.wysija-version .social-foot .socials .fb div{margin-left:0px}.wysija-version .version{float:left;margin-bottom:5px}.wysija-version .socials{padding-top:9px}#hidesocials{margin-top:2px;font-size:12px}.social-foot .gplus{width:70px}#upperfoot{display:block;float:none}#wysija-app .form-table td{vertical-align:top}#submitexport label input[type="checkbox"]{margin-left:0px !important}.hook-column{float:left;display:block}#wysija-app div.warning{margin:5px 0 15px;background-color:#FFFFE0;border-color:#E6DB55;border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;padding:10px}.submit-box{border-top:1px solid #dbdbdb;background-color:#FFFFFF;bottom:0;height:50px;left:0;margin:0;padding:0;position:fixed;text-align:right;width:100%}#loading-icon{width:20px;height:20px;position:absolute;left:16px;top:16px}.loading #loading-icon{background:url(../img/wpspin_light.gif) no-repeat 0 0 #fff}.counting #loading-icon{background:url(../img/controls/icons.png) no-repeat -140px -20px #fff}.submit-box #loading-message{font-family:"Trebuchet MS";font-size:14px;left:39px;position:absolute;top:17px}.submit-box #insert-selection,.submit-box #back-selection{margin:10px 10px 0 0}.submit-box #back-selection{display:none}#icon-stats{background:url("../img/stats-icon.png") no-repeat scroll 0 0 transparent}
1
+ .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}.hide{display:none}.wysija-version{margin:0 20px 0 165px;padding-bottom:45px}.wysija-footer h2{color:#21759B;cursor:pointer}.wysija-footer h2:hover{text-decoration:underline}.wysija-version{font-size:12px;color:#777777}.wysija-version .social-foot div{float:left;margin-right:10px}.wysija-version .version{float:left}.wysija-version .help{float:left;margin-left:20px}.wysija-version .social-foot .textsocial{margin-left:8px;margin-top:3px;padding-top:0}.wysija-version .social-foot{clear:both;display:inline-block}.wysija-version .version{float:left;margin-bottom:5px}#upperfoot{display:block;float:none}#submitexport label input[type="checkbox"]{margin-left:0px !important}.clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}.wysija-footer,.wysija-version{margin:0 20px 0 165px;padding-bottom:45px}.wysija-footer h2{color:#21759B;cursor:pointer}.wysija-footer h2:hover{text-decoration:underline}.wysija-version{font-size:12px;color:#777777;height:65px;border-top:1px solid #DFDFDF}.wysija-version .social-foot div{float:left;margin-right:10px}.social-foot .fb{width:80px}.wysija-version .version{float:left}.wysija-version .help{float:left;margin-left:20px}.wysija-version .social-foot .textsocial{margin-left:8px;margin-top:3px;padding-top:0}.wysija-version .social-foot{clear:both;display:inline-block;float:left;margin-top:2px;padding:6px 13px}.wysija-version .social-foot .socials div{margin-left:20px}.wysija-version .social-foot .socials{margin-left:0px}.wysija-version .social-foot .socials .fb,.wysija-version .social-foot .socials .fb div{margin-left:0px}.wysija-version .version{float:left;margin-bottom:5px}.wysija-version .socials{padding-top:9px}#hidesocials{margin-top:2px;font-size:12px}.social-foot .gplus{width:70px}#upperfoot{display:block;float:none}#wysija-app .form-table td{vertical-align:top}#submitexport label input[type="checkbox"]{margin-left:0px !important}.hook-column{float:left;display:block}#wysija-app div.warning{margin:5px 0 15px;background-color:#FFFFE0;border-color:#E6DB55;border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;padding:10px}.submit-box{border-top:1px solid #dbdbdb;background-color:#FFFFFF;bottom:0;height:50px;left:0;margin:0;padding:0;position:fixed;text-align:right;width:100%}#loading-icon{width:20px;height:20px;position:absolute;left:16px;top:16px}.loading #loading-icon{background:url(../img/wpspin_light.gif) no-repeat 0 0 #fff}.counting #loading-icon{background:url(../img/controls/icons.png) no-repeat -140px -20px #fff}.submit-box #loading-message{font-family:"Trebuchet MS";font-size:14px;left:39px;position:absolute;top:17px}.submit-box #insert-selection,.submit-box #back-selection{margin:10px 10px 0 0}.submit-box #back-selection{display:none}#icon-stats{background:url("../img/stats-icon.png") no-repeat scroll 0 0 transparent}.search-field input{height:auto !important}
css/admin-premium.css CHANGED
@@ -1 +1 @@
1
- #mainmenu .premium{background:url(../img/ui-bg_glass_premium_1x400.png) repeat-x scroll 50% 50% #e6e6e6;border:1px solid #a9abc3}#mainmenu .premium:hover{background:url(../img/ui-bg_glass_premium_hover_1x400.png) repeat-x scroll 50% 50% #e6e6e6;border:1px solid #9c9eb2}#mainmenu .premium a{font-weight:700;color:#5d5e76}#mainmenu .premium a:hover{color:#4b4d69}#mainmenu .ui-state-active{background:white !important;border:1px solid #d8d9e6}.mpoet-page h2{color:#4b4d69;font-size:1.8em;font-weight:200;line-height:1.2em;margin:0}.wysija-premium-wrapper{margin:0 0 20px 0}.wysija-premium-actions{position:fixed;width:1028px;bottom:0;background-color:#eee;border-top:1px solid #ccc;border-left:1px solid #ccc;border-right:1px solid #ccc;-webkit-border-top-left-radius:7px;-webkit-border-top-right-radius:7px;-moz-border-radius-topleft:7px;-moz-border-radius-topright:7px;border-top-left-radius:7px;border-top-right-radius:7px;z-index:999;padding:10px 10px 0}.wysija-premium-actions .licence{margin-right:15px}.wysija-premium-actions p{margin:0px 0px 10px 0;text-align:center}.wysija-premium-actions span.conditions{font-size:12px;margin-right:15px}.wysija-premium-actions .button-primary.wysija-premium-activate{float:none}.wysija-premium-actions-kim{position:fixed;width:1066px;bottom:0;background-color:#eee;border-top:1px solid #ccc;border-left:1px solid #ccc;border-right:1px solid #ccc;z-index:999;margin-left:-30px;padding:10px 10px;text-align:center}.mpoet-page .feature-section.three-col>div{width:29%}.mpoet-page .three-col img{margin:0.5em 0;max-width:100%}a.wysija-premium-purchase{background-color:#FFB30D !important;background:-webkit-gradient(linear, left top, left bottom, from(#fecb19), to(#ff9c00)) !important;background:-webkit-linear-gradient(#fecb19, #ff9c00) !important;background:-moz-linear-gradient(center top, #fecb19 0%, #ff9c00 100%) !important;background:-moz-gradient(center top, #fecb19 0%, #ff9c00 100%) !important;border:1px solid #ff9c00 !important;color:#ffffff;font-family:"Amaranth", Arial, sans-serif;font-style:italic;font-size:15px !important;font-weight:normal;letter-spacing:1px;text-decoration:none;text-shadow:0 1px 0 #434343;padding:10px 30px;border-radius:7px;-moz-border-radius:7px;-webkit-border-radius:7px;box-shadow:none !important;text-shadow:0px 2px 1px rgba(0,0,0,0.3) !important;display:inline-block;text-align:center;width:auto}a.wysija-premium-purchase:hover{box-shadow:none !important}a.wysija-premium-purchase:hover,a.wysija-premium-purchase:active{text-decoration:none !important;background:#ffd547;background:-webkit-gradient(linear, left top, left bottom, from(#ffd648), to(#ffbe38));background:-webkit-linear-gradient(#ffd648, #ffbe38);background:-moz-linear-gradient(center top, #ffd648 20%, #ffbe38 100%);background:-moz-gradient(center top, #ffd648 20%, #ffbe38 100%)}a.wysija-premium-purchase,a.wysija-premium-activate{margin:10px 0}.mpoet-page .bullet-hold{width:600px;margin:15px 30px 15px 5px}.mpoet-page div.description h3{margin:5px 0 4px 0;font-family:"HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue",sans-serif;font-size:20px;font-weight:normal;color:black}.mpoet-page div.description p{margin:0}#prices_table{margin-top:55px}#prices_table .one-third{display:block;float:left;width:284px}#prices_table #prices_names{height:63px}#prices_table #prices_names .one-third{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;background:none repeat-x scroll left top rgba(0,0,0,0);border-color:#414141 -moz-use-text-color #414141 #414141;border-image:none;border-style:solid none solid solid;border-width:1px 0 1px 1px;height:61px;text-align:center}#prices_table #prices_names{display:block}#prices_table #prices_names h3{color:#FFF !important;line-height:1em !important}#prices_table #prices_names .blogger{background-color:#0074A2}#prices_table #prices_names .freelance{background-color:#026187}#prices_table #prices_names .agency{background-color:#014661;border-right:1px solid #414141}#prices_table #prices_cost{height:177px}#prices_table #prices_cost p{margin:0}#prices_table #prices_cost .one-third{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;border-color:-moz-use-text-color -moz-use-text-color #849A97 #849A97;border-image:none;border-style:none none solid solid;border-width:0 0 1px 1px;font-family:'Amaranth',Arial,sans-serif;height:176px}#prices_table #prices_cost .agency{border-right:1px solid #849A97}#prices_table #prices_cost span{display:block}#prices_table #prices_cost .dollars{font-size:80px;height:80px;line-height:normal;padding:20px 55px 0;text-align:center}#prices_table #prices_cost .per_year{font-size:18px;padding:0 60px;text-align:right}#prices_table #prices_cost .blogger .dollars{padding:20px 75px 0}#prices_table #prices_cost .blogger .per_year{padding:0 80px}#prices_table #prices_description{height:62px}#prices_table #prices_description .one-third{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;border-color:-moz-use-text-color -moz-use-text-color #849A97 #849A97;border-image:none;border-style:none none solid solid;border-width:0 0 1px 1px;font-size:22px;height:61px}#prices_table #prices_description .agency{border-right:1px solid #849A97}#prices_table #prices_description .agency p{display:block;margin:-15px 62px 0 0;text-align:right;font-size:.5em}#prices_table #prices_description span{display:block;padding:17px 0;text-align:center}#prices_table #prices_content{height:158px}#prices_table #prices_content .prices_content{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;border-color:-moz-use-text-color #849A97 #849A97;border-image:none;border-right:1px solid #849A97;border-style:none solid solid;border-width:0 1px 1px;color:#414141;font-size:17px;padding:16px 0}#prices_table #prices_content .prices_content span{display:block;padding:2px 0;text-align:center}a.buy-button{background:none repeat scroll 0 0 #2EA2CC;border-color:#0074A2;box-shadow:0 1px 0 rgba(120,200,230,0.5) inset,0 1px 0 rgba(0,0,0,0.15);color:#FFFFFF;-moz-box-sizing:border-box;border-radius:3px;border-style:solid;border-width:1px;cursor:pointer;display:inline-block;font-size:20px;margin-top:20px;margin-bottom:60px;padding:7px 10px 7px;text-decoration:none;white-space:nowrap}a.buy-button:hover{color:#ecf3fe}.mpoet-page h1{font-size:34px}#wysija-app .mpoet-page h2{font-size:25px}.mpoet-page h1,.mpoet-page h2,.mpoet-page h3,.mpoet-page h4{color:#626262;font-weight:bold}.mpoet-page h3{margin-top:5px;line-height:24px}.mpoet-page .three-col .argument-cta{display:table;margin-top:5px}#premium-content-b .pick-licence{margin-bottom:15px}.mpoet-page hr{margin-bottom:20px}#premium-content-b .price{font-weight:bold}#footer-upgrade,#footer-left,#wpfooter .alignright,.wysija-footer{display:none}.about-wrap div.updated,.about-wrap div.error{display:block !important}#wysija-app .about-wrap .feature-section{margin-top:20px}
1
+ #mainmenu .premium{background:url(../img/ui-bg_glass_premium_1x400.png) repeat-x scroll 50% 50% #e6e6e6;border:1px solid #a9abc3}#mainmenu .premium:hover{background:url(../img/ui-bg_glass_premium_hover_1x400.png) repeat-x scroll 50% 50% #e6e6e6;border:1px solid #9c9eb2}#mainmenu .premium a{font-weight:700;color:#5d5e76}#mainmenu .premium a:hover{color:#4b4d69}#mainmenu .ui-state-active{background:white !important;border:1px solid #d8d9e6}.mpoet-page h2{color:#4b4d69;font-family:sans-serif;font-size:1.8em;font-weight:200;line-height:1.2em;margin:0}.wysija-premium-wrapper{margin:0 0 20px 0}.wysija-premium-actions{position:fixed;width:1028px;bottom:0;background-color:#eee;border-top:1px solid #ccc;border-left:1px solid #ccc;border-right:1px solid #ccc;-webkit-border-top-left-radius:7px;-webkit-border-top-right-radius:7px;-moz-border-radius-topleft:7px;-moz-border-radius-topright:7px;border-top-left-radius:7px;border-top-right-radius:7px;z-index:999;padding:10px 10px 0}.wysija-premium-actions .licence{margin-right:15px}.wysija-premium-actions p{margin:0px 0px 10px 0;text-align:center}.wysija-premium-actions span.conditions{font-size:12px;margin-right:15px}.wysija-premium-actions .button-primary.wysija-premium-activate{float:none}.wysija-premium-actions-kim{position:fixed;width:1066px;bottom:0;background-color:#eee;border-top:1px solid #ccc;border-left:1px solid #ccc;border-right:1px solid #ccc;z-index:999;margin-left:-30px;padding:10px 10px;text-align:center}.mpoet-page .feature-section.three-col>div{width:29%}.mpoet-page .three-col img{margin:0.5em 0;max-width:100%}a.wysija-premium-purchase{background-color:#FFB30D !important;background:-webkit-gradient(linear, left top, left bottom, from(#fecb19), to(#ff9c00)) !important;background:-webkit-linear-gradient(#fecb19, #ff9c00) !important;background:-moz-linear-gradient(center top, #fecb19 0%, #ff9c00 100%) !important;background:-moz-gradient(center top, #fecb19 0%, #ff9c00 100%) !important;border:1px solid #ff9c00 !important;color:#ffffff;font-family:"Amaranth", Arial, sans-serif;font-style:italic;font-size:15px !important;font-weight:normal;letter-spacing:1px;text-decoration:none;text-shadow:0 1px 0 #434343;padding:10px 30px;border-radius:7px;-moz-border-radius:7px;-webkit-border-radius:7px;box-shadow:none !important;text-shadow:0px 2px 1px rgba(0,0,0,0.3) !important;display:inline-block;text-align:center;width:auto}a.wysija-premium-purchase:hover{box-shadow:none !important}a.wysija-premium-purchase:hover,a.wysija-premium-purchase:active{text-decoration:none !important;background:#ffd547;background:-webkit-gradient(linear, left top, left bottom, from(#ffd648), to(#ffbe38));background:-webkit-linear-gradient(#ffd648, #ffbe38);background:-moz-linear-gradient(center top, #ffd648 20%, #ffbe38 100%);background:-moz-gradient(center top, #ffd648 20%, #ffbe38 100%)}a.wysija-premium-purchase,a.wysija-premium-activate{margin:10px 0}.mpoet-page .bullet-hold{width:600px;margin:15px 30px 15px 5px}.mpoet-page div.description h3{margin:5px 0 4px 0;font-family:"HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue",sans-serif;font-size:20px;font-weight:normal;color:black}.mpoet-page div.description p{margin:0}#prices_table{margin-top:55px}#prices_table .one-third{display:block;float:left;width:284px}#prices_table #prices_names{height:63px}#prices_table #prices_names .one-third{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;background:none repeat-x scroll left top rgba(0,0,0,0);border-color:#414141 -moz-use-text-color #414141 #414141;border-image:none;border-style:solid none solid solid;border-width:1px 0 1px 1px;height:61px;text-align:center}#prices_table #prices_names{display:block}#prices_table #prices_names h3{color:#FFF !important;line-height:1em !important}#prices_table #prices_names .blogger{background-color:#0074A2}#prices_table #prices_names .freelance{background-color:#026187}#prices_table #prices_names .agency{background-color:#014661;border-right:1px solid #414141}#prices_table #prices_cost{height:177px}#prices_table #prices_cost p{margin:0}#prices_table #prices_cost .one-third{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;border-color:-moz-use-text-color -moz-use-text-color #849A97 #849A97;border-image:none;border-style:none none solid solid;border-width:0 0 1px 1px;font-family:'Amaranth',Arial,sans-serif;height:176px}#prices_table #prices_cost .agency{border-right:1px solid #849A97}#prices_table #prices_cost span{display:block}#prices_table #prices_cost .dollars{font-size:80px;height:80px;line-height:normal;padding:20px 55px 0;text-align:center}#prices_table #prices_cost .per_year{font-size:18px;padding:0 60px;text-align:right}#prices_table #prices_cost .blogger .dollars{padding:20px 75px 0}#prices_table #prices_cost .blogger .per_year{padding:0 80px}#prices_table #prices_description{height:62px}#prices_table #prices_description .one-third{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;border-color:-moz-use-text-color -moz-use-text-color #849A97 #849A97;border-image:none;border-style:none none solid solid;border-width:0 0 1px 1px;font-size:22px;height:61px}#prices_table #prices_description .agency{border-right:1px solid #849A97}#prices_table #prices_description .agency p{display:block;margin:-15px 62px 0 0;text-align:right;font-size:.5em}#prices_table #prices_description span{display:block;padding:17px 0;text-align:center}#prices_table #prices_content{height:158px}#prices_table #prices_content .prices_content{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;border-color:-moz-use-text-color #849A97 #849A97;border-image:none;border-right:1px solid #849A97;border-style:none solid solid;border-width:0 1px 1px;color:#414141;font-size:17px;padding:16px 0}#prices_table #prices_content .prices_content span{display:block;padding:2px 0;text-align:center}a.buy-button{background:none repeat scroll 0 0 #2EA2CC;border-color:#0074A2;box-shadow:0 1px 0 rgba(120,200,230,0.5) inset,0 1px 0 rgba(0,0,0,0.15);color:#FFFFFF;-moz-box-sizing:border-box;border-radius:3px;border-style:solid;border-width:1px;cursor:pointer;display:inline-block;font-size:20px;margin-top:20px;margin-bottom:60px;padding:7px 10px 7px;text-decoration:none;white-space:nowrap}a.buy-button:hover{color:#ecf3fe}.mpoet-page h1{font-size:34px}#wysija-app .mpoet-page h2{font-size:25px}.mpoet-page h1,.mpoet-page h2,.mpoet-page h3,.mpoet-page h4{color:#626262;font-family:"Arial","Open Sans",sans-serif;font-weight:bold}.mpoet-page h3{margin-top:5px;line-height:24px}.mpoet-page .three-col .argument-cta{display:table;margin-top:5px}#premium-content-b .pick-licence{margin-bottom:15px}.mpoet-page hr{margin-bottom:20px}#premium-content-b .price{font-weight:bold}#footer-upgrade,#footer-left,#wpfooter .alignright,.wysija-footer{display:none}.about-wrap div.updated,.about-wrap div.error{display:block !important}
css/admin-statistics.css CHANGED
@@ -1 +1 @@
1
- .stats_date_filter{padding-top:10px}.statistic-title{clear:both;margin-top:5px}.cl{clear:both}#hook_stats .container{clear:both;padding-top:1px;margin-top:20px}#stats-filter .reset{background:none;border:none;cursor:pointer}#stats-filter .reset:hover{text-decoration:underline}.custom_date{margin-right:10px}.spinner{float:left !important}.hook{margin-top:10px;clear:both}.container-top-links .link_column{width:20%}.container-top-links .click_column{width:6%}.container .check-column{width:2.5em}.container-top-subscribers table th.subscriber{width:30%}.container-top-subscribers table th.clicks{width:7%}.container-top-subscribers table th.opens{width:7%}.container-top-subscribers table th.lists{width:41%}.container-top-subscribers table th.date{width:15%}.container-top-links a.newsletter{display:block;padding-top:5px}.container-top-newsletters th.newsletter{width:19%}.container-top-newsletters th.sent{width:8%}.container-top-newsletters th.opens{width:8%}.container-top-newsletters th.clicks{width:7%}.container-top-newsletters th.unsubscribes{width:11%}.container-top-newsletters th.rates{width:18%}.container-top-newsletters th.sent_at{width:12%}.container-top-newsletters th.lists{width:14%}.container-top-newsletters td a.stats{display:none}.container-top-newsletters td.newsletter:hover a.stats{display:block}.container-top-subscribers th.desc:hover span.sorting-indicator,.container-top-newsletters th.desc:hover span.sorting-indicator{background-position:-7px 0}.stats_feedback{font-weight:bold;margin-top:20px;clear:both}.tip{font-style:italic}.stats_subscriptions-container .tip{margin-left:70px}.container-top-newsletters th.desc:hover span.sorting-indicator:before,.container-top-subscribers th.desc:hover span.sorting-indicator:before,.container-top-newsletters th.asc span.sorting-indicator:before,.container-top-subscribers th.asc span.sorting-indicator:before{content:'\f140'}
1
+ .stats_date_filter{padding-top:10px}.statistic-title{clear:both;margin-top:5px}.cl{clear:both}#hook_stats .container{clear:both;padding-top:1px;margin-top:20px}#stats-filter .reset{background:none;border:none;cursor:pointer}#stats-filter .reset:hover{text-decoration:underline}.custom_date{margin-right:10px}.spinner{float:left !important}.hook{margin-top:10px;clear:both}.container-top-links .link_column{width:20%}.container-top-links .click_column{width:6%}.container .check-column{width:2.5em}.container-top-subscribers table th.subscriber{width:30%}.container-top-subscribers table th.clicks{width:7%}.container-top-subscribers table th.opens{width:7%}.container-top-subscribers table th.lists{width:41%}.container-top-subscribers table th.date{width:15%}.container-top-links a.newsletter{display:block;padding-top:5px}.container-top-newsletters th.newsletter{width:19%}.container-top-newsletters th.sent{width:8%}.container-top-newsletters th.opens{width:8%}.container-top-newsletters th.clicks{width:7%}.container-top-newsletters th.unsubscribes{width:11%}.container-top-newsletters th.rates{width:18%}.container-top-newsletters th.sent_at{width:12%}.container-top-newsletters th.lists{width:14%}.container-top-newsletters td a.stats{display:none}.container-top-newsletters td.newsletter:hover a.stats{display:block}.container-top-subscribers th.desc:hover span.sorting-indicator,.container-top-newsletters th.desc:hover span.sorting-indicator{background-position:-7px 0}.stats_feedback{font-weight:bold;margin-top:20px;clear:both}.tip{font-style:italic}.stats_subscriptions-container .tip{margin-left:70px}
css/admin.css CHANGED
@@ -1 +1 @@
1
- .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}#wysija-app .column-date{width:125px}#wysija-app .column-clic,#wysija-app .column-opened,#wysija-app .column-emails{width:80px}#wysija-app .column-list-names{width:120px}#wysija-app .menuslinks{margin:20px 0}#statscontainer{height:200px;width:400px}#wysistats1{width:400px}#wysistats1 h3{text-align:center}#wysistats2,#wysistats3{width:200px;padding:30px 0 0 20px}#wysistats3{height:200px;overflow:auto}#wysistats2 ul li,#wysistats .title{font-weight:bold;font-size:14px;margin-top:0}#wysistats3 ol li{font-style:italic;font-size:10px;color:#444}#wysistats3 ol li em{font-size:11px;font-weight:bold}th.sorted,th.sortable{cursor:pointer}div#wysija-app .xdetailed-updated li,div#wysija-app .xdetailed-errors li,div#wysija-app .updated li,div#wysija-app .error li{margin:6px 0}.xdetailed-errors,.xdetailed-updated{border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;margin:5px 15px 2px;padding:0 0.6em}.xdetailed-updated{background-color:#FFFFE0;border-color:#E6DB55;color:#000;display:none}.xdetailed-errors{background-color:#FFEBE8;border-color:#888888;color:#000;display:none}label input[type="checkbox"],label input[type="radio"]{margin:0 5px 0 15px}label:first-child input[type="checkbox"],label:first-child input[type="radio"]{margin-left:0}label.title{font-weight:bold;font-size:14px}.wrap .button-secondary2{background-color:#6697BF;font-family:sans-serif;font-size:12px;color:#FFFFFF;text-decoration:none;text-shadow:0 1px 0 #777777;box-shadow:1px 1px 0 #AAAAAA;margin-left:4px;padding:3px 8px;position:relative;top:-3px;border-radius:3px;-moz-border-radius:3px;-khtml-border-radius:3px;-webkit-border-radius:3px}.wrap .button-secondary2:hover,.wrap .wcurrent{background-color:#1C73B5}.wrap #theme-view .button-secondary2{top:2px}.dots{margin:0 4px}#wysija-pagination{text-align:center}.tablenav .tablenav-pages a,.tablenav-pages span.current{margin:0 2px}.total-pages{padding:0px 3px}input.searchbox{width:225px}.wysija-premium img{display:none}#TB_load,#TB_window,#TB_overlay,.ui-dialog{z-index:100000 !important}.ui-widget-overlay{z-index:9998 !important;background-image:none !important}p.label{font-size:13px}.wysija_popup_content{padding:10px 20px 0 20px}.wysija_popup_content h3{margin:0 0 20px 0}a.linkignore{color:#BC0B0B}a.linkignore:hover,a.submitsynch:hover{color:#FF0000}a.submitsynch{color:#52aa05}body{min-width:0 !important}.warning-msg{background-color:#FFFFE0;border-color:#E6DB55}.warning-msg{border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;margin:5px 15px 2px;padding:0 0.6em}.warning-msg ul{margin:0}span.warning-msg{padding:7px}.about-wrap h3{padding-top:0px}.about-text{margin-bottom:1em;margin-top:0;min-height:20px}.wysija-unsubscribed-on{color:#bbb}.clear_select_all,.force_to_select_all_link{text-align:center}.batch-select{background-color:#E0E0E0;color:#555555;border-bottom:1px solid #e5e5e5}.clear_select_all a:hover,.force_to_select_all_link a:hover{text-decoration:underline;cursor:pointer !important}#wysija-app .notice-msg{background-color:#FFFFE0;border-color:#E6DB55}#wysija-app .error-msg{background-color:#FFEBE8;border-color:#CC0000}#wysija-app .wysija-msg .notice-msg,#wysija-app .wysija-msg .error-msg{border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;margin:5px 0 15px;padding:0 0.6em}.mpoet-page .changelog .review-follow-kitten{overflow:visible}
1
+ .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}#wysija-app .column-date{width:125px}#wysija-app .column-clic,#wysija-app .column-opened,#wysija-app .column-emails{width:80px}#wysija-app .column-list-names{width:120px}#wysija-app .menuslinks{margin:20px 0}#statscontainer{height:200px;width:400px}#wysistats1{width:400px}#wysistats1 h3{text-align:center}#wysistats2,#wysistats3{width:200px;padding:30px 0 0 20px}#wysistats3{height:200px;overflow:auto}.left{float:left}#wysistats2 ul li,#wysistats .title{font-weight:bold;font-size:14px;margin-top:0}#wysistats3 ol li{font-style:italic;font-size:10px;color:#444}#wysistats3 ol li em{font-size:11px;font-weight:bold}th.sorted,th.sortable{cursor:pointer}div#wysija-app .xdetailed-updated li,div#wysija-app .xdetailed-errors li,div#wysija-app .updated li,div#wysija-app .error li{margin:6px 0}.xdetailed-errors,.xdetailed-updated{border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;margin:5px 15px 2px;padding:0 0.6em}.xdetailed-updated{background-color:#FFFFE0;border-color:#E6DB55;color:#000;display:none}.xdetailed-errors{background-color:#FFEBE8;border-color:#888888;color:#000;display:none}label input[type="checkbox"],label input[type="radio"]{margin:0 5px 0 15px}label:first-child input[type="checkbox"],label:first-child input[type="radio"]{margin-left:0}label.title{font-weight:bold;font-size:14px}.wrap .button-secondary2{background-color:#6697BF;font-family:sans-serif;font-size:12px;color:#FFFFFF;text-decoration:none;text-shadow:0 1px 0 #777777;box-shadow:1px 1px 0 #AAAAAA;margin-left:4px;padding:3px 8px;position:relative;top:-3px;border-radius:3px;-moz-border-radius:3px;-khtml-border-radius:3px;-webkit-border-radius:3px}.wrap .button-secondary2:hover,.wrap .wcurrent{background-color:#1C73B5}.wrap #theme-view .button-secondary2{top:2px}.dots{margin:0 4px}#wysija-pagination{text-align:center}.tablenav .tablenav-pages a,.tablenav-pages span.current{margin:0 2px}.total-pages{padding:0px 3px}input.searchbox{width:225px}.wysija-premium img{display:none}#TB_load,#TB_window,#TB_overlay,.ui-dialog{z-index:100000 !important}.ui-widget-overlay{z-index:9998 !important;background-image:none !important}p.label{font-size:13px}.wysija_popup_content{padding:10px 20px 0 20px}.wysija_popup_content h3{margin:0 0 20px 0}a.linkignore{color:#BC0B0B}a.linkignore:hover,a.submitsynch:hover{color:#FF0000}a.submitsynch{color:#52aa05}body{min-width:0 !important}.warning-msg{background-color:#FFFFE0;border-color:#E6DB55}.warning-msg{border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;margin:5px 15px 2px;padding:0 0.6em}.warning-msg ul{margin:0}span.warning-msg{padding:7px}.about-wrap h3{padding-top:0px}.about-text{margin-bottom:1em;margin-top:0;min-height:20px}.wysija-unsubscribed-on{color:#bbb}.clear_select_all,.force_to_select_all_link{text-align:center}.clear_select_all a:hover,.force_to_select_all_link a:hover{text-decoration:underline;cursor:pointer !important}#wysija-app .notice-msg{background-color:#FFFFE0;border-color:#E6DB55}#wysija-app .error-msg{background-color:#FFEBE8;border-color:#CC0000}#wysija-app .wysija-msg .notice-msg,#wysija-app .wysija-msg .error-msg{border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;margin:5px 0 15px;padding:0 0.6em}
css/adminPopup.css CHANGED
@@ -1 +1 @@
1
- html{overflow:hidden;overflow-y:auto;height:auto !important}html.wp-toolbar{padding:0 !important}#wpadminbar{display:none}body{-webkit-backface-visibility:hidden}.popup_content{margin:10px 10px 0 10px}.popup_content.addlink{width:300px}.popup_content.articles{width:700px}.popup_content.dividers{width:620px}.popup_content.autopost{width:700px;min-height:380px}.popup_content.themes{width:800px}.popup_content.bookmarks{width:620px}.popup_content.media-browse,.popup_content.media-wp-browse,.popup_content.media-wp-upload{width:715px}.popup_content.form_widget_settings{width:405px}.popup_content.widget_text,.popup_content.widget_html{width:450px}.popup_content.widget_list{width:450px}p.align-right{text-align:right;margin-bottom:0 !important}div.updated,div.error{margin:10px !important}.popup_content.inline_form label{line-height:2em;font-weight:bold}.popup_content.inline_form p input,.popup_content.inline_form p select,.popup_content.inline_form p .group{float:left;width:200px}.submit_button{text-align:right;margin:20px 10px 20px 0}.popup_content.inline_form .submit_button{margin:20px 4px 0 0}.popup_content.inline_form p input[type="submit"],.popup_content.inline_form .group label,.popup_content.inline_form .group input,.popup_content.inline_form .group select{float:none;clear:none;width:auto}.popup_content.inline_form label.radio,.popup_content.inline_form .group label{font-weight:normal}.popup_content.inline_form input[type="radio"],.popup_content.inline_form input[type="checkbox"]{width:16px;height:16px;margin:0 3px 0 0;padding:0}.popup_content.inline_form input[type="radio"]{-webkit-appearance:radio}.popup_content.inline_form input[type="radio"]:checked:before,.popup_content.inline_form input[type="checkbox"]:checked:before{background:none;content:''}.popup_content.inline_form input[type="checkbox"]{-webkit-appearance:checkbox}.popup_content.inline_form textarea,.popup_content.inline_form input[type="text"],.popup_content.inline_form input[type="password"],.popup_content.inline_form input[type="email"],.popup_content.inline_form input[type="number"],.popup_content.inline_form input[type="search"],.popup_content.inline_form input[type="tel"],.popup_content.inline_form input[type="url"],.popup_content.inline_form select{font-size:13px;line-height:15px;padding:3px 5px}
1
+ html{overflow:hidden;overflow-y:auto;height:auto !important}html.wp-toolbar{padding:0 !important}body{-webkit-backface-visibility:hidden}.popup_content{margin:10px 10px 0 10px}.popup_content.addlink{width:300px}.popup_content.articles{width:700px}.popup_content.dividers{width:620px}.popup_content.autopost{width:700px}.popup_content.themes{width:800px}.popup_content.bookmarks{width:620px}.popup_content.media-browse,.popup_content.media-wp-browse,.popup_content.media-wp-upload{width:715px}.popup_content.form_widget_settings{width:405px}.popup_content.widget_text,.popup_content.widget_html{width:450px}.popup_content.widget_list{width:450px}p.align-right{text-align:right;margin-bottom:0 !important}div.updated,div.error{margin:10px !important}.popup_content.inline_form label{line-height:2em;font-weight:bold}.popup_content.inline_form p input,.popup_content.inline_form p select,.popup_content.inline_form p .group{float:left;width:200px}.submit_button{text-align:right;margin:20px 10px 20px 0}.popup_content.inline_form .submit_button{margin:20px 4px 0 0}.popup_content.inline_form p input[type="submit"],.popup_content.inline_form .group label,.popup_content.inline_form .group input,.popup_content.inline_form .group select{float:none;clear:none;width:auto}.popup_content.inline_form label.radio,.popup_content.inline_form .group label{font-weight:normal}.popup_content.inline_form input[type="radio"],.popup_content.inline_form input[type="checkbox"]{width:16px;height:16px;margin:0 3px 0 0;padding:0}.popup_content.inline_form input[type="radio"]{-webkit-appearance:radio}.popup_content.inline_form input[type="radio"]:checked:before,.popup_content.inline_form input[type="checkbox"]:checked:before{background:none;content:''}.popup_content.inline_form input[type="checkbox"]{-webkit-appearance:checkbox}.popup_content.inline_form textarea,.popup_content.inline_form input[type="text"],.popup_content.inline_form input[type="password"],.popup_content.inline_form input[type="email"],.popup_content.inline_form input[type="number"],.popup_content.inline_form input[type="search"],.popup_content.inline_form input[type="tel"],.popup_content.inline_form input[type="url"],.popup_content.inline_form select{font-size:13px;line-height:15px;padding:3px 5px}
css/qtip2/jquery.qtip.min.css ADDED
@@ -0,0 +1,2 @@
 
 
1
+ /* qTip2 v2.2.0 basic css3 | qtip2.com | Licensed MIT, GPL | Fri Nov 29 2013 13:08:37 */
2
+ .qtip{position:absolute;left:-28000px;top:-28000px;display:none;max-width:280px;min-width:50px;font-size:10.5px;line-height:12px;direction:ltr;box-shadow:none;padding:0}.qtip-content{position:relative;padding:5px 9px;overflow:hidden;text-align:left;word-wrap:break-word}.qtip-titlebar{position:relative;padding:5px 35px 5px 10px;overflow:hidden;border-width:0 0 1px;font-weight:700}.qtip-titlebar+.qtip-content{border-top-width:0!important}.qtip-close{position:absolute;right:-9px;top:-9px;cursor:pointer;outline:medium none;border-width:1px;border-style:solid;border-color:transparent}.qtip-titlebar .qtip-close{right:4px;top:50%;margin-top:-9px}* html .qtip-titlebar .qtip-close{top:16px}.qtip-titlebar .ui-icon,.qtip-icon .ui-icon{display:block;text-indent:-1000em;direction:ltr}.qtip-icon,.qtip-icon .ui-icon{-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;text-decoration:none}.qtip-icon .ui-icon{width:18px;height:14px;line-height:14px;text-align:center;text-indent:0;font:400 bold 10px/13px Tahoma,sans-serif;color:inherit;background:transparent none no-repeat -100em -100em}.qtip-focus{}.qtip-hover{}.qtip-default{border-width:1px;border-style:solid;border-color:#F1D031;background-color:#FFFFA3;color:#555}.qtip-default .qtip-titlebar{background-color:#FFEF93}.qtip-default .qtip-icon{border-color:#CCC;background:#F1F1F1;color:#777}.qtip-default .qtip-titlebar .qtip-close{border-color:#AAA;color:#111} .qtip-light{background-color:#fff;border-color:#E2E2E2;color:#454545}.qtip-light .qtip-titlebar{background-color:#f1f1f1} .qtip-dark{background-color:#505050;border-color:#303030;color:#f3f3f3}.qtip-dark .qtip-titlebar{background-color:#404040}.qtip-dark .qtip-icon{border-color:#444}.qtip-dark .qtip-titlebar .ui-state-hover{border-color:#303030} .qtip-cream{background-color:#FBF7AA;border-color:#F9E98E;color:#A27D35}.qtip-cream .qtip-titlebar{background-color:#F0DE7D}.qtip-cream .qtip-close .qtip-icon{background-position:-82px 0} .qtip-red{background-color:#F78B83;border-color:#D95252;color:#912323}.qtip-red .qtip-titlebar{background-color:#F06D65}.qtip-red .qtip-close .qtip-icon{background-position:-102px 0}.qtip-red .qtip-icon{border-color:#D95252}.qtip-red .qtip-titlebar .ui-state-hover{border-color:#D95252} .qtip-green{background-color:#CAED9E;border-color:#90D93F;color:#3F6219}.qtip-green .qtip-titlebar{background-color:#B0DE78}.qtip-green .qtip-close .qtip-icon{background-position:-42px 0} .qtip-blue{background-color:#E5F6FE;border-color:#ADD9ED;color:#5E99BD}.qtip-blue .qtip-titlebar{background-color:#D0E9F5}.qtip-blue .qtip-close .qtip-icon{background-position:-2px 0}.qtip-shadow{-webkit-box-shadow:1px 1px 3px 1px rgba(0,0,0,.15);-moz-box-shadow:1px 1px 3px 1px rgba(0,0,0,.15);box-shadow:1px 1px 3px 1px rgba(0,0,0,.15)}.qtip-rounded,.qtip-tipsy,.qtip-bootstrap{-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.qtip-rounded .qtip-titlebar{-moz-border-radius:4px 4px 0 0;-webkit-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.qtip-youtube{-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 0 3px #333;-moz-box-shadow:0 0 3px #333;box-shadow:0 0 3px #333;color:#fff;border-width:0;background:#4A4A4A;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0,#4A4A4A),color-stop(100%,#000));background-image:-webkit-linear-gradient(top,#4A4A4A 0,#000 100%);background-image:-moz-linear-gradient(top,#4A4A4A 0,#000 100%);background-image:-ms-linear-gradient(top,#4A4A4A 0,#000 100%);background-image:-o-linear-gradient(top,#4A4A4A 0,#000 100%)}.qtip-youtube .qtip-titlebar{background-color:#4A4A4A;background-color:rgba(0,0,0,0)}.qtip-youtube .qtip-content{padding:.75em;font:12px arial,sans-serif;filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#4a4a4a, EndColorStr=#000000);-ms-filter:"progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#4a4a4a, EndColorStr=#000000);"}.qtip-youtube .qtip-icon{border-color:#222}.qtip-youtube .qtip-titlebar .ui-state-hover{border-color:#303030}.qtip-jtools{background:#232323;background:rgba(0,0,0,.7);background-image:-webkit-gradient(linear,left top,left bottom,from(#717171),to(#232323));background-image:-moz-linear-gradient(top,#717171,#232323);background-image:-webkit-linear-gradient(top,#717171,#232323);background-image:-ms-linear-gradient(top,#717171,#232323);background-image:-o-linear-gradient(top,#717171,#232323);border:2px solid #ddd;border:2px solid rgba(241,241,241,1);-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 0 12px #333;-moz-box-shadow:0 0 12px #333;box-shadow:0 0 12px #333}.qtip-jtools .qtip-titlebar{background-color:transparent;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#717171, endColorstr=#4A4A4A);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#717171, endColorstr=#4A4A4A)"}.qtip-jtools .qtip-content{filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#4A4A4A, endColorstr=#232323);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#4A4A4A, endColorstr=#232323)"}.qtip-jtools .qtip-titlebar,.qtip-jtools .qtip-content{background:transparent;color:#fff;border:0 dashed transparent}.qtip-jtools .qtip-icon{border-color:#555}.qtip-jtools .qtip-titlebar .ui-state-hover{border-color:#333}.qtip-cluetip{-webkit-box-shadow:4px 4px 5px rgba(0,0,0,.4);-moz-box-shadow:4px 4px 5px rgba(0,0,0,.4);box-shadow:4px 4px 5px rgba(0,0,0,.4);background-color:#D9D9C2;color:#111;border:0 dashed transparent}.qtip-cluetip .qtip-titlebar{background-color:#87876A;color:#fff;border:0 dashed transparent}.qtip-cluetip .qtip-icon{border-color:#808064}.qtip-cluetip .qtip-titlebar .ui-state-hover{border-color:#696952;color:#696952}.qtip-tipsy{background:#000;background:rgba(0,0,0,.87);color:#fff;border:0 solid transparent;font-size:11px;font-family:'Lucida Grande',sans-serif;font-weight:700;line-height:16px;text-shadow:0 1px #000}.qtip-tipsy .qtip-titlebar{padding:6px 35px 0 10px;background-color:transparent}.qtip-tipsy .qtip-content{padding:6px 10px}.qtip-tipsy .qtip-icon{border-color:#222;text-shadow:none}.qtip-tipsy .qtip-titlebar .ui-state-hover{border-color:#303030}.qtip-tipped{border:3px solid #959FA9;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;background-color:#F9F9F9;color:#454545;font-weight:400;font-family:serif}.qtip-tipped .qtip-titlebar{border-bottom-width:0;color:#fff;background:#3A79B8;background-image:-webkit-gradient(linear,left top,left bottom,from(#3A79B8),to(#2E629D));background-image:-webkit-linear-gradient(top,#3A79B8,#2E629D);background-image:-moz-linear-gradient(top,#3A79B8,#2E629D);background-image:-ms-linear-gradient(top,#3A79B8,#2E629D);background-image:-o-linear-gradient(top,#3A79B8,#2E629D);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#3A79B8, endColorstr=#2E629D);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#3A79B8, endColorstr=#2E629D)"}.qtip-tipped .qtip-icon{border:2px solid #285589;background:#285589}.qtip-tipped .qtip-icon .ui-icon{background-color:#FBFBFB;color:#555}.qtip-bootstrap{font-size:14px;line-height:20px;color:#333;padding:1px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,.2);-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,.2);box-shadow:0 5px 10px rgba(0,0,0,.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box}.qtip-bootstrap .qtip-titlebar{padding:8px 14px;margin:0;font-size:14px;font-weight:400;line-height:18px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;-webkit-border-radius:5px 5px 0 0;-moz-border-radius:5px 5px 0 0;border-radius:5px 5px 0 0}.qtip-bootstrap .qtip-titlebar .qtip-close{right:11px;top:45%;border-style:none}.qtip-bootstrap .qtip-content{padding:9px 14px}.qtip-bootstrap .qtip-icon{background:transparent}.qtip-bootstrap .qtip-icon .ui-icon{width:auto;height:auto;float:right;font-size:20px;font-weight:700;line-height:18px;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.qtip-bootstrap .qtip-icon .ui-icon:hover{color:#000;text-decoration:none;cursor:pointer;opacity:.4;filter:alpha(opacity=40)}.qtip:not(.ie9haxors) div.qtip-content,.qtip:not(.ie9haxors) div.qtip-titlebar{filter:none;-ms-filter:none}.qtip .qtip-tip{margin:0 auto;overflow:hidden;z-index:10}x:-o-prefocus,.qtip .qtip-tip{visibility:hidden}.qtip .qtip-tip,.qtip .qtip-tip .qtip-vml,.qtip .qtip-tip canvas{position:absolute;color:#123456;background:transparent;border:0 dashed transparent}.qtip .qtip-tip canvas{top:0;left:0}.qtip .qtip-tip .qtip-vml{behavior:url(#default#VML);display:inline-block;visibility:visible}#qtip-overlay{position:fixed;left:0;top:0;width:100%;height:100%}#qtip-overlay.blurs{cursor:pointer}#qtip-overlay div{position:absolute;left:0;top:0;width:100%;height:100%;background-color:#000;opacity:.7;filter:alpha(opacity=70);-ms-filter:"alpha(Opacity=70)"}.qtipmodal-ie6fix{position:absolute!important}
css/rtl.css CHANGED
@@ -1 +1 @@
1
- body{direction:rtl;unicode-bidi:embed}input#url{direction:ltr}.xdetailed-errors,.xdetailed-updated{margin:2px 15px 5px}.wysija-footer,.wysija-version{margin:0 165px 0 20px}label input[type="checkbox"],label input[type="radio"]{margin:0 15px 0 5px}input.searchsub.button{float:none}a.button-primary.install{float:none}#review-follow div{float:right}.about-wrap .feature-section.three-col div{float:right}#wysija-badge{left:0;right:auto}.dividers ul{overflow-x:auto;overflow-y:auto}.submit-box{text-align:left}.submit-box #insert-selection,.submit-box #back-selection{margin:10px 0 0 10px}#toggle-advanced{left:10px;top:0;right:auto}.articles #basic .search-box{float:left}.articles #basic .filters-box{float:right}.articles #search-submit{margin:0 0 0 14px}.articles .cpt-type{left:0;right:auto;border-right:1px solid #ccc;border-left:0 none}#advanced div.block{padding:0.8em 1em 0.8em 0}#advanced label{float:right}#image_width_slider{float:right}#slider_info{float:right}#advanced label.radio{float:right;margin:0 0 0 9px}#advanced label.radio input{margin:0 0 0 2px}#advanced div.group{float:right}#results .thumbnail{float:right;margin:0 0 0 10px}#results li .checkbox{cursor:pointer;margin:0 11px 0 0}#results li .checkbox_container{float:right}#results li label{float:right}#loading-icon{left:auto;right:16px;top:16px}.submit-box #loading-message{left:auto;right:39px}.wysija-footer,.wysija-version{margin:0 165px 0 20px}.wysija-version .social-foot{float:right}body.rtl #wysija_wrapper{right:0 !important}#wysija_popup_title h3{float:right;margin-right:10px}#wysija_popup_close{float:left;margin-left:10px}#wysija_toolbar{right:657px}.wj_images li,.wj_themes li{float:right}.wj_images #wj_images_preview,.wj_themes #wj_themes_preview{left:295px;right:auto}.wj_content a.wysija_item,.wysija_widget{padding:0 10px 0 0}.wj_styles form label{margin:0 3px 0 0}.wj_styles #aUnderlineInput{margin-right:10px !important}.wysija_item_settings{left:15px;right:auto}#wysija_toggle_images{left:5px;right:auto}#review-follow .review-left.large{float:right}#review-follow .review-left{background-position:100% 0}#review-follow div{float:right}#review-follow .review-left .description{margin-right:146px;margin-left:0px}#review-follow .review-right{background-image:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow_middle-rtl.jpg");background-position:100% 0}#review-follow .follow-right{background-image:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow_right-rtl.jpg");background-position:100% 0}#review-follow .follow-right38{background-image:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow-right-38-rtl.jpg");background-position:100% 0}#wysija-settings input[type="checkbox"],#wysija-settings input[type="radio"],#wysija-settings label input[type="checkbox"]{margin-left:6px}label:first-child input[type="checkbox"],label:first-child input[type="radio"],label input[type="checkbox"],label input[type="radio"]{margin:0 15px 0 5px}.linknamecboxes,.labelcheck,.geeky-option a,.geeky-option span{float:right}.checkbox_optin_label{margin:6px 0 0 6px;float:right}.checkbox_optin_value{float:right}#wysija-settings .form-table th.rolestitle{text-align:right}.cronleft{float:right;margin:0 0 0 10px}.popup_content.autopost{width:auto}.popup_content{margin:10px 10px 0 10px}#wysija-settings #sendingmethod .methods h3,#wysija-settings #multisite .methods p.title{float:right}#wysija-settings #sendingmethod .methods input,#wysija-settings #multisite .methods input{float:right;margin:0 0 0 5px}h2.title span,h2.title form{float:right;margin-left:5px;margin-right:0px}#wysija_form_toolbar{right:679px !important;left:auto !important}#wysija_form_toolbar a.wysija_form_item,.wysija_form_widget{padding-right:7px}.form_widget_settings p label{float:right;clear:right;width:200px}.form_widget_settings .selection .is_selected{float:right;margin:3px 6px 0 0 !important}.form_widget_settings .selection label{float:right;margin:0 5px 0 0}.form_widget_settings .selection .handle,.form_widget_settings .selection .remove{float:left;margin:3px 0 0 3px}.popup_content.inline_form p input,.popup_content.inline_form p select,.popup_content.inline_form p .group{float:right}.submit_button{margin:20px 0 20px 10px;text-align:left}.popup_content.inline_form .submit_button{margin:20px 0 0 4px}.popup_content.inline_form label.radio,.popup_content.inline_form .group label{float:right}.popup_content.inline_form input[type="radio"],.popup_content.inline_form input[type="checkbox"]{margin:0 0 0 3px}.wysija_form_item_settings{left:35px;right:auto !important}.wysija_form_item_delete{left:15px;right:auto !important}.bookmarks .networks label,.bookmarks .networks input{float:right}#results li .checkbox{margin-left:10px}.add span{float:right}.themes #wj_paginator{float:left;margin-right:0;margin-left:10px}
1
+ body{direction:rtl;unicode-bidi:embed}input#url{direction:ltr}.xdetailed-errors,.xdetailed-updated{margin:2px 15px 5px}.wysija-footer,.wysija-version{margin:0 165px 0 20px}label input[type="checkbox"],label input[type="radio"]{margin:0 15px 0 5px}input.searchsub.button{float:none}a.button-primary.install{float:none}#review-follow div{float:right}.about-wrap .feature-section.three-col div{float:right}#wysija-badge{left:0;right:auto}.dividers ul{overflow-x:auto;overflow-y:auto}.submit-box{text-align:left}.submit-box #insert-selection,.submit-box #back-selection{margin:10px 0 0 10px}#toggle-advanced{left:10px;top:0;right:auto}.articles #basic .search-box{float:left}.articles #basic .filters-box{float:right}.articles #search-submit{margin:0 0 0 14px}.articles .cpt-type{left:0;right:auto;border-right:1px solid #ccc;border-left:0 none}#advanced div.block{padding:0.8em 1em 0.8em 0}#advanced label{float:right}#image_width_slider{float:right}#slider_info{float:right}#advanced label.radio{float:right;margin:0 0 0 9px}#advanced label.radio input{margin:0 0 0 2px}#advanced div.group{float:right}#results .thumbnail{float:right;margin:0 0 0 10px}#results li .checkbox{cursor:pointer;margin:0 11px 0 0}#results li .checkbox_container{float:right}#results li label{float:right}#loading-icon{left:auto;right:16px;top:16px}.submit-box #loading-message{left:auto;right:39px}.wysija-footer,.wysija-version{margin:0 165px 0 20px}.wysija-version .social-foot{float:right}body.rtl #wysija_wrapper{right:0 !important}#wysija_popup_title h3{float:right;margin-right:10px}#wysija_popup_close{float:left;margin-left:10px}#wysija_toolbar{right:657px}.wj_images li,.wj_themes li{float:right}.wj_images #wj_images_preview,.wj_themes #wj_themes_preview{left:295px;right:auto}.wj_content a.wysija_item,.wysija_widget{padding:0 10px 0 0}.wj_styles form label{margin:0 3px 0 0}.wj_styles #aUnderlineInput{margin-right:10px !important}.wysija_item_settings{left:15px;right:auto}#wysija_toggle_images{left:5px;right:auto}#review-follow .review-left.large{float:right}#review-follow .review-left{background-position:100% 0}#review-follow div{float:right}#review-follow .review-left .description{margin-right:146px;margin-left:0px}#review-follow .review-right{background-image:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow_middle-rtl.jpg");background-position:100% 0}#review-follow .follow-right{background-image:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow_right-rtl.jpg");background-position:100% 0}#review-follow .follow-right38{background-image:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow-right-38-rtl.jpg");background-position:100% 0}#wysija-settings input[type="checkbox"],#wysija-settings input[type="radio"],#wysija-settings label input[type="checkbox"]{margin-left:6px}label:first-child input[type="checkbox"],label:first-child input[type="radio"],label input[type="checkbox"],label input[type="radio"]{margin:0 15px 0 5px}.linknamecboxes,.labelcheck,.geeky-option a,.geeky-option span{float:right}.checkbox_optin_label{margin:6px 0 0 6px;float:right}.checkbox_optin_value{float:right}#wysija-settings .form-table th.rolestitle{text-align:right}.cronleft{float:right;margin:0 0 0 10px}.popup_content.autopost{width:auto}.popup_content{margin:10px 10px 0 10px}#wysija-settings #sendingmethod .methods h3,#wysija-settings #multisite .methods p.title{float:right}#wysija-settings #sendingmethod .methods input,#wysija-settings #multisite .methods input{float:right;margin:0 0 0 5px}h2.title span,h2.title form{float:right;margin-left:5px;margin-right:0px}#wysija_form_toolbar{right:679px !important;left:auto !important}#wysija_form_toolbar a.wysija_form_item,.wysija_form_widget{padding-right:7px}.form_widget_settings p label{float:right;clear:right;width:200px}.form_widget_settings .selection .is_selected{float:right;margin:3px 6px 0 0 !important}.form_widget_settings .selection label{float:right;margin:0 5px 0 0}.form_widget_settings .selection .handle,.form_widget_settings .selection .remove{float:left;margin:3px 0 0 3px}.popup_content.inline_form p input,.popup_content.inline_form p select,.popup_content.inline_form p .group{float:right}.submit_button{margin:20px 0 20px 10px;text-align:left}.popup_content.inline_form .submit_button{margin:20px 0 0 4px}.popup_content.inline_form label.radio,.popup_content.inline_form .group label{float:right}.popup_content.inline_form input[type="radio"],.popup_content.inline_form input[type="checkbox"]{margin:0 0 0 3px}.wysija_form_item_settings{left:35px;right:auto !important}.wysija_form_item_delete{left:15px;right:auto !important}.bookmarks .networks label,.bookmarks .networks input{float:right}#results li .checkbox{margin-left:10px}.chosen-container-multi .chosen-choices li{float:right}.chosen-container-multi .chosen-choices li.search-choice{margin-right:5px}.add span{float:right}.themes #wj_paginator{float:left;margin-right:0;margin-left:10px}
css/select2/select2.css DELETED
@@ -1,615 +0,0 @@
1
- /*
2
- Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
3
- */
4
- .select2-container {
5
- margin: 0;
6
- position: relative;
7
- display: inline-block;
8
- /* inline-block for ie7 */
9
- zoom: 1;
10
- *display: inline;
11
- vertical-align: middle;
12
- }
13
-
14
- .select2-container,
15
- .select2-drop,
16
- .select2-search,
17
- .select2-search input {
18
- /*
19
- Force border-box so that % widths fit the parent
20
- container without overlap because of margin/padding.
21
-
22
- More Info : http://www.quirksmode.org/css/box.html
23
- */
24
- -webkit-box-sizing: border-box; /* webkit */
25
- -moz-box-sizing: border-box; /* firefox */
26
- box-sizing: border-box; /* css3 */
27
- }
28
-
29
- .select2-container .select2-choice {
30
- display: block;
31
- height: 26px;
32
- padding: 0 0 0 8px;
33
- overflow: hidden;
34
- position: relative;
35
-
36
- border: 1px solid #aaa;
37
- white-space: nowrap;
38
- line-height: 26px;
39
- color: #444;
40
- text-decoration: none;
41
-
42
- border-radius: 4px;
43
-
44
- background-clip: padding-box;
45
-
46
- -webkit-touch-callout: none;
47
- -webkit-user-select: none;
48
- -moz-user-select: none;
49
- -ms-user-select: none;
50
- user-select: none;
51
-
52
- background-color: #fff;
53
- background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.5, #fff));
54
- background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 50%);
55
- background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 50%);
56
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#eeeeee', GradientType = 0);
57
- background-image: linear-gradient(top, #fff 0%, #eee 50%);
58
- }
59
-
60
- .select2-container.select2-drop-above .select2-choice {
61
- border-bottom-color: #aaa;
62
-
63
- border-radius: 0 0 4px 4px;
64
-
65
- background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.9, #fff));
66
- background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 90%);
67
- background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 90%);
68
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0);
69
- background-image: linear-gradient(top, #eee 0%, #fff 90%);
70
- }
71
-
72
- .select2-container.select2-allowclear .select2-choice .select2-chosen {
73
- margin-right: 42px;
74
- }
75
-
76
- .select2-container .select2-choice > .select2-chosen {
77
- margin-right: 26px;
78
- display: block;
79
- overflow: hidden;
80
-
81
- white-space: nowrap;
82
-
83
- text-overflow: ellipsis;
84
- }
85
-
86
- .select2-container .select2-choice abbr {
87
- display: none;
88
- width: 12px;
89
- height: 12px;
90
- position: absolute;
91
- right: 24px;
92
- top: 8px;
93
-
94
- font-size: 1px;
95
- text-decoration: none;
96
-
97
- border: 0;
98
- background: url('../../img/select2/select2.png') right top no-repeat;
99
- cursor: pointer;
100
- outline: 0;
101
- }
102
-
103
- .select2-container.select2-allowclear .select2-choice abbr {
104
- display: inline-block;
105
- }
106
-
107
- .select2-container .select2-choice abbr:hover {
108
- background-position: right -11px;
109
- cursor: pointer;
110
- }
111
-
112
- .select2-drop-mask {
113
- border: 0;
114
- margin: 0;
115
- padding: 0;
116
- position: fixed;
117
- left: 0;
118
- top: 0;
119
- min-height: 100%;
120
- min-width: 100%;
121
- height: auto;
122
- width: auto;
123
- opacity: 0;
124
- z-index: 9998;
125
- /* styles required for IE to work */
126
- background-color: #fff;
127
- filter: alpha(opacity=0);
128
- }
129
-
130
- .select2-drop {
131
- width: 100%;
132
- margin-top: -1px;
133
- position: absolute;
134
- z-index: 9999;
135
- top: 100%;
136
-
137
- background: #fff;
138
- color: #000;
139
- border: 1px solid #aaa;
140
- border-top: 0;
141
-
142
- border-radius: 0 0 4px 4px;
143
-
144
- -webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
145
- box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
146
- }
147
-
148
- .select2-drop-auto-width {
149
- border-top: 1px solid #aaa;
150
- width: auto;
151
- }
152
-
153
- .select2-drop-auto-width .select2-search {
154
- padding-top: 4px;
155
- }
156
-
157
- .select2-drop.select2-drop-above {
158
- margin-top: 1px;
159
- border-top: 1px solid #aaa;
160
- border-bottom: 0;
161
-
162
- border-radius: 4px 4px 0 0;
163
-
164
- -webkit-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
165
- box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
166
- }
167
-
168
- .select2-drop-active {
169
- border: 1px solid #5897fb;
170
- border-top: none;
171
- }
172
-
173
- .select2-drop.select2-drop-above.select2-drop-active {
174
- border-top: 1px solid #5897fb;
175
- }
176
-
177
- .select2-container .select2-choice .select2-arrow {
178
- display: inline-block;
179
- width: 18px;
180
- height: 100%;
181
- position: absolute;
182
- right: 0;
183
- top: 0;
184
-
185
- border-left: 1px solid #aaa;
186
- border-radius: 0 4px 4px 0;
187
-
188
- background-clip: padding-box;
189
-
190
- background: #ccc;
191
- background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee));
192
- background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%);
193
- background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%);
194
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee', endColorstr = '#cccccc', GradientType = 0);
195
- background-image: linear-gradient(top, #ccc 0%, #eee 60%);
196
- }
197
-
198
- .select2-container .select2-choice .select2-arrow b {
199
- display: block;
200
- width: 100%;
201
- height: 100%;
202
- background: url('../../img/select2/select2.png') no-repeat 0 1px;
203
- }
204
-
205
- .select2-search {
206
- display: inline-block;
207
- width: 100%;
208
- min-height: 26px;
209
- margin: 0;
210
- padding-left: 4px;
211
- padding-right: 4px;
212
-
213
- position: relative;
214
- z-index: 10000;
215
-
216
- white-space: nowrap;
217
- }
218
-
219
- .select2-search input {
220
- width: 100%;
221
- height: auto !important;
222
- min-height: 26px;
223
- padding: 4px 20px 4px 5px;
224
- margin: 0;
225
-
226
- outline: 0;
227
- font-family: sans-serif;
228
- font-size: 1em;
229
-
230
- border: 1px solid #aaa;
231
- border-radius: 0;
232
-
233
- -webkit-box-shadow: none;
234
- box-shadow: none;
235
-
236
- background: #fff url('../../img/select2/select2.png') no-repeat 100% -22px;
237
- background: url('../../img/select2/select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
238
- background: url('../../img/select2/select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
239
- background: url('../../img/select2/select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
240
- background: url('../../img/select2/select2.png') no-repeat 100% -22px, linear-gradient(top, #fff 85%, #eee 99%);
241
- }
242
-
243
- .select2-drop.select2-drop-above .select2-search input {
244
- margin-top: 4px;
245
- }
246
-
247
- .select2-search input.select2-active {
248
- background: #fff url('../../img/select2/select2-spinner.gif') no-repeat 100%;
249
- background: url('../../img/select2/select2-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
250
- background: url('../../img/select2/select2-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
251
- background: url('../../img/select2/select2-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
252
- background: url('../../img/select2/select2-spinner.gif') no-repeat 100%, linear-gradient(top, #fff 85%, #eee 99%);
253
- }
254
-
255
- .select2-container-active .select2-choice,
256
- .select2-container-active .select2-choices {
257
- border: 1px solid #5897fb;
258
- outline: none;
259
-
260
- -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
261
- box-shadow: 0 0 5px rgba(0, 0, 0, .3);
262
- }
263
-
264
- .select2-dropdown-open .select2-choice {
265
- border-bottom-color: transparent;
266
- -webkit-box-shadow: 0 1px 0 #fff inset;
267
- box-shadow: 0 1px 0 #fff inset;
268
-
269
- border-bottom-left-radius: 0;
270
- border-bottom-right-radius: 0;
271
-
272
- background-color: #eee;
273
- background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #fff), color-stop(0.5, #eee));
274
- background-image: -webkit-linear-gradient(center bottom, #fff 0%, #eee 50%);
275
- background-image: -moz-linear-gradient(center bottom, #fff 0%, #eee 50%);
276
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
277
- background-image: linear-gradient(top, #fff 0%, #eee 50%);
278
- }
279
-
280
- .select2-dropdown-open.select2-drop-above .select2-choice,
281
- .select2-dropdown-open.select2-drop-above .select2-choices {
282
- border: 1px solid #5897fb;
283
- border-top-color: transparent;
284
-
285
- background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(0.5, #eee));
286
- background-image: -webkit-linear-gradient(center top, #fff 0%, #eee 50%);
287
- background-image: -moz-linear-gradient(center top, #fff 0%, #eee 50%);
288
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
289
- background-image: linear-gradient(bottom, #fff 0%, #eee 50%);
290
- }
291
-
292
- .select2-dropdown-open .select2-choice .select2-arrow {
293
- background: transparent;
294
- border-left: none;
295
- filter: none;
296
- }
297
- .select2-dropdown-open .select2-choice .select2-arrow b {
298
- background-position: -18px 1px;
299
- }
300
-
301
- /* results */
302
- .select2-results {
303
- max-height: 200px;
304
- padding: 0 0 0 4px;
305
- margin: 4px 4px 4px 0;
306
- position: relative;
307
- overflow-x: hidden;
308
- overflow-y: auto;
309
- -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
310
- }
311
-
312
- .select2-results ul.select2-result-sub {
313
- margin: 0;
314
- padding-left: 0;
315
- }
316
-
317
- .select2-results ul.select2-result-sub > li .select2-result-label { padding-left: 20px }
318
- .select2-results ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 40px }
319
- .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 60px }
320
- .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 80px }
321
- .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 100px }
322
- .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 110px }
323
- .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 120px }
324
-
325
- .select2-results li {
326
- list-style: none;
327
- display: list-item;
328
- background-image: none;
329
- }
330
-
331
- .select2-results li.select2-result-with-children > .select2-result-label {
332
- font-weight: bold;
333
- }
334
-
335
- .select2-results .select2-result-label {
336
- padding: 3px 7px 4px;
337
- margin: 0;
338
- cursor: pointer;
339
-
340
- min-height: 1em;
341
-
342
- -webkit-touch-callout: none;
343
- -webkit-user-select: none;
344
- -moz-user-select: none;
345
- -ms-user-select: none;
346
- user-select: none;
347
- }
348
-
349
- .select2-results .select2-highlighted {
350
- background: #3875d7;
351
- color: #fff;
352
- }
353
-
354
- .select2-results li em {
355
- background: #feffde;
356
- font-style: normal;
357
- }
358
-
359
- .select2-results .select2-highlighted em {
360
- background: transparent;
361
- }
362
-
363
- .select2-results .select2-highlighted ul {
364
- background: #fff;
365
- color: #000;
366
- }
367
-
368
-
369
- .select2-results .select2-no-results,
370
- .select2-results .select2-searching,
371
- .select2-results .select2-selection-limit {
372
- background: #f4f4f4;
373
- display: list-item;
374
- }
375
-
376
- /*
377
- disabled look for disabled choices in the results dropdown
378
- */
379
- .select2-results .select2-disabled.select2-highlighted {
380
- color: #666;
381
- background: #f4f4f4;
382
- display: list-item;
383
- cursor: default;
384
- }
385
- .select2-results .select2-disabled {
386
- background: #f4f4f4;
387
- display: list-item;
388
- cursor: default;
389
- }
390
-
391
- .select2-results .select2-selected {
392
- display: none;
393
- }
394
-
395
- .select2-more-results.select2-active {
396
- background: #f4f4f4 url('../../img/select2/select2-spinner.gif') no-repeat 100%;
397
- }
398
-
399
- .select2-more-results {
400
- background: #f4f4f4;
401
- display: list-item;
402
- }
403
-
404
- /* disabled styles */
405
-
406
- .select2-container.select2-container-disabled .select2-choice {
407
- background-color: #f4f4f4;
408
- background-image: none;
409
- border: 1px solid #ddd;
410
- cursor: default;
411
- }
412
-
413
- .select2-container.select2-container-disabled .select2-choice .select2-arrow {
414
- background-color: #f4f4f4;
415
- background-image: none;
416
- border-left: 0;
417
- }
418
-
419
- .select2-container.select2-container-disabled .select2-choice abbr {
420
- display: none;
421
- }
422
-
423
-
424
- /* multiselect */
425
-
426
- .select2-container-multi .select2-choices {
427
- height: auto !important;
428
- height: 1%;
429
- margin: 0;
430
- padding: 0;
431
- position: relative;
432
-
433
- border: 1px solid #aaa;
434
- cursor: text;
435
- overflow: hidden;
436
-
437
- background-color: #fff;
438
- background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eee), color-stop(15%, #fff));
439
- background-image: -webkit-linear-gradient(top, #eee 1%, #fff 15%);
440
- background-image: -moz-linear-gradient(top, #eee 1%, #fff 15%);
441
- background-image: linear-gradient(top, #eee 1%, #fff 15%);
442
- }
443
-
444
- .select2-locked {
445
- padding: 3px 5px 3px 5px !important;
446
- }
447
-
448
- .select2-container-multi .select2-choices {
449
- min-height: 26px;
450
- }
451
-
452
- .select2-container-multi.select2-container-active .select2-choices {
453
- border: 1px solid #5897fb;
454
- outline: none;
455
-
456
- -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
457
- box-shadow: 0 0 5px rgba(0, 0, 0, .3);
458
- }
459
- .select2-container-multi .select2-choices li {
460
- float: left;
461
- list-style: none;
462
- }
463
- .select2-container-multi .select2-choices .select2-search-field {
464
- margin: 0;
465
- padding: 0;
466
- white-space: nowrap;
467
- }
468
-
469
- .select2-container-multi .select2-choices .select2-search-field input {
470
- padding: 5px;
471
- margin: 1px 0;
472
-
473
- font-family: sans-serif;
474
- font-size: 100%;
475
- color: #666;
476
- outline: 0;
477
- border: 0;
478
- -webkit-box-shadow: none;
479
- box-shadow: none;
480
- background: transparent !important;
481
- }
482
-
483
- .select2-container-multi .select2-choices .select2-search-field input.select2-active {
484
- background: #fff url('../../img/select2/select2-spinner.gif') no-repeat 100% !important;
485
- }
486
-
487
- .select2-default {
488
- color: #999 !important;
489
- }
490
-
491
- .select2-container-multi .select2-choices .select2-search-choice {
492
- padding: 3px 5px 3px 18px;
493
- margin: 3px 0 3px 5px;
494
- position: relative;
495
-
496
- line-height: 13px;
497
- color: #333;
498
- cursor: default;
499
- border: 1px solid #aaaaaa;
500
-
501
- border-radius: 3px;
502
-
503
- -webkit-box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
504
- box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
505
-
506
- background-clip: padding-box;
507
-
508
- -webkit-touch-callout: none;
509
- -webkit-user-select: none;
510
- -moz-user-select: none;
511
- -ms-user-select: none;
512
- user-select: none;
513
-
514
- background-color: #e4e4e4;
515
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#f4f4f4', GradientType=0);
516
- background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eee));
517
- background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
518
- background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
519
- background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
520
- }
521
- .select2-container-multi .select2-choices .select2-search-choice .select2-chosen {
522
- cursor: default;
523
- }
524
- .select2-container-multi .select2-choices .select2-search-choice-focus {
525
- background: #d4d4d4;
526
- }
527
-
528
- .select2-search-choice-close {
529
- display: block;
530
- width: 12px;
531
- height: 13px;
532
- position: absolute;
533
- right: 3px;
534
- top: 4px;
535
-
536
- font-size: 1px;
537
- outline: none;
538
- background: url('../../img/select2/select2.png') right top no-repeat;
539
- }
540
-
541
- .select2-container-multi .select2-search-choice-close {
542
- left: 3px;
543
- }
544
-
545
- .select2-container-multi .select2-choices .select2-search-choice .select2-search-choice-close:hover {
546
- background-position: right -11px;
547
- }
548
- .select2-container-multi .select2-choices .select2-search-choice-focus .select2-search-choice-close {
549
- background-position: right -11px;
550
- }
551
-
552
- /* disabled styles */
553
- .select2-container-multi.select2-container-disabled .select2-choices {
554
- background-color: #f4f4f4;
555
- background-image: none;
556
- border: 1px solid #ddd;
557
- cursor: default;
558
- }
559
-
560
- .select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice {
561
- padding: 3px 5px 3px 5px;
562
- border: 1px solid #ddd;
563
- background-image: none;
564
- background-color: #f4f4f4;
565
- }
566
-
567
- .select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice .select2-search-choice-close { display: none;
568
- background: none;
569
- }
570
- /* end multiselect */
571
-
572
-
573
- .select2-result-selectable .select2-match,
574
- .select2-result-unselectable .select2-match {
575
- text-decoration: underline;
576
- }
577
-
578
- .select2-offscreen, .select2-offscreen:focus {
579
- clip: rect(0 0 0 0) !important;
580
- width: 1px !important;
581
- height: 1px !important;
582
- border: 0 !important;
583
- margin: 0 !important;
584
- padding: 0 !important;
585
- overflow: hidden !important;
586
- position: absolute !important;
587
- outline: 0 !important;
588
- left: 0px !important;
589
- top: 0px !important;
590
- }
591
-
592
- .select2-display-none {
593
- display: none;
594
- }
595
-
596
- .select2-measure-scrollbar {
597
- position: absolute;
598
- top: -10000px;
599
- left: -10000px;
600
- width: 100px;
601
- height: 100px;
602
- overflow: scroll;
603
- }
604
- /* Retina-ize icons */
605
-
606
- @media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) {
607
- .select2-search input, .select2-search-choice-close, .select2-container .select2-choice abbr, .select2-container .select2-choice .select2-arrow b {
608
- background-image: url('../../img/select2/select2x2.png') !important;
609
- background-repeat: no-repeat !important;
610
- background-size: 60px 40px !important;
611
- }
612
- .select2-search input {
613
- background-position: 100% -21px !important;
614
- }
615
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
css/tmce/editor.css DELETED
@@ -1,2317 +0,0 @@
1
-
2
- /*------------------------------------------------------------------------------
3
-
4
- TinyMCE and Quicklinks toolbars
5
- ------------------------------------------------------------------------------*/
6
-
7
- /* wp_theme/ui.css */
8
- .wp_themeSkin table,
9
- .wp_themeSkin tbody,
10
- .wp_themeSkin a,
11
- .wp_themeSkin img,
12
- .wp_themeSkin tr,
13
- .wp_themeSkin div,
14
- .wp_themeSkin td,
15
- .wp_themeSkin iframe,
16
- .wp_themeSkin span,
17
- .wp_themeSkin *,
18
- .wp_themeSkin .mceText {
19
- border: 0;
20
- margin: 0;
21
- padding: 0;
22
- white-space: nowrap;
23
- text-decoration: none;
24
- font-weight: normal;
25
- cursor: default;
26
- vertical-align: baseline;
27
- width: auto;
28
- border-collapse: separate;
29
- }
30
-
31
- .wp_themeSkin a:hover,
32
- .wp_themeSkin a:link,
33
- .wp_themeSkin a:visited,
34
- .wp_themeSkin a:active {
35
- text-decoration: none;
36
- font-weight: normal;
37
- cursor: default;
38
- }
39
-
40
- .wp_themeSkin table td {
41
- vertical-align: middle;
42
- }
43
-
44
- .wp_themeSkin *,
45
- .wp_themeSkin a:hover,
46
- .wp_themeSkin a:link,
47
- .wp_themeSkin a:visited,
48
- .wp_themeSkin a:active {
49
- color: #555;
50
- }
51
-
52
- /* These are part of TinyMCE, used in TinyMCE Advanced, but not WordPress. These are not updated for 3.8's design. */
53
- .wp_themeSkin span.mce_sup,
54
- .wp_themeSkin span.mce_sub,
55
- .wp_themeSkin span.mce_media,
56
- .wp_themeSkin span.mce_styleprops,
57
- .wp_themeSkin span.mce_search,
58
- .wp_themeSkin span.mce_emotions,
59
- .wp_themeSkin span.mce_print,
60
- .wp_themeSkin span.mce_attribs,
61
- .wp_themeSkin span.mce_hr,
62
- .wp_themeSkin span.mce_cut,
63
- .wp_themeSkin span.mce_copy,
64
- .wp_themeSkin span.mce_paste,
65
- .wp_themeSkin span.mce_cite,
66
- .wp_themeSkin span.mce_visualchars,
67
- .wp_themeSkin span.mce_advhr,
68
- .wp_themeSkin span.mce_insertdate,
69
- .wp_themeSkin span.mce_anchor,
70
- .wp_themeSkin span.mce_visualaid,
71
- .wp_themeSkin span.mce_cleanup,
72
- .wp_themeSkin span.mce_table,
73
- .wp_themeSkin span.mce_row_props,
74
- .wp_themeSkin span.mce_cell_props,
75
- .wp_themeSkin span.mce_row_before,
76
- .wp_themeSkin span.mce_row_after,
77
- .wp_themeSkin span.mce_delete_row,
78
- .wp_themeSkin span.mce_col_before,
79
- .wp_themeSkin span.mce_col_after,
80
- .wp_themeSkin span.mce_delete_col,
81
- .wp_themeSkin span.mce_split_cells,
82
- .wp_themeSkin span.mce_merge_cells,
83
- .wp_themeSkin span.mce_delete_table,
84
- .wp_themeSkin span.mce_ins,
85
- .wp_themeSkin span.mce_abbr,
86
- .wp_themeSkin span.mce_acronym,
87
- .wp_themeSkin span.mce_del,
88
- .wp_themeSkin span.mce_replace,
89
- .wp_themeSkin span.mce_code,
90
- .wp_themeSkin span.mce_nonbreaking,
91
- .wp_themeSkin span.mce_inserttime,
92
- .wp_themeSkin span.mce_insertlayer,
93
- .wp_themeSkin span.mce_moveforward,
94
- .wp_themeSkin span.mce_movebackward,
95
- .wp_themeSkin span.mce_absolute {
96
- -moz-transition: none;
97
- -webkit-transition: none;
98
- transition: none;
99
- background: url("../js/tinymce/skins/wordpress/images/icons.gif") no-repeat 20px 20px;
100
- }
101
-
102
- .wp_themeSkin span.mce_code:after {
103
- content: '\f475';
104
- font-family: 'dashicons';
105
- }
106
-
107
- /* No @font-face support */
108
- .no-font-face .wp_themeSkin span.mce_undo,
109
- .no-font-face .wp_themeSkin span.mce_redo,
110
- .no-font-face .wp_themeSkin span.mce_bullist,
111
- .no-font-face .wp_themeSkin span.mce_numlist,
112
- .no-font-face .wp_themeSkin span.mce_blockquote,
113
- .no-font-face .wp_themeSkin span.mce_charmap,
114
- .no-font-face .wp_themeSkin span.mce_bold,
115
- .no-font-face .wp_themeSkin span.mce_italic,
116
- .no-font-face .wp_themeSkin span.mce_underline,
117
- .no-font-face .wp_themeSkin span.mce_justifyleft,
118
- .no-font-face .wp_themeSkin span.mce_justifyright,
119
- .no-font-face .wp_themeSkin span.mce_justifycenter,
120
- .no-font-face .wp_themeSkin span.mce_justifyfull,
121
- .no-font-face .wp_themeSkin span.mce_indent,
122
- .no-font-face .wp_themeSkin span.mce_outdent,
123
- .no-font-face .wp_themeSkin span.mce_link,
124
- .no-font-face .wp_themeSkin span.mce_unlink,
125
- .no-font-face .wp_themeSkin span.mce_help,
126
- .no-font-face .wp_themeSkin span.mce_removeformat,
127
- .no-font-face .wp_themeSkin span.mce_fullscreen,
128
- .no-font-face .wp_themeSkin span.mce_wp_fullscreen,
129
- .no-font-face .wp_themeSkin span.mce_media,
130
- .no-font-face .wp_themeSkin span.mce_pastetext,
131
- .no-font-face .wp_themeSkin span.mce_pasteword,
132
- .no-font-face .wp_themeSkin span.mce_wp_help,
133
- .no-font-face .wp_themeSkin span.mce_wp_adv,
134
- .no-font-face .wp_themeSkin span.mce_wp_more,
135
- .no-font-face .wp_themeSkin span.mce_strikethrough,
136
- .no-font-face .wp_themeSkin span.mce_spellchecker,
137
- .no-font-face .wp_themeSkin span.mce_forecolor,
138
- .no-font-face .wp_themeSkin .mce_forecolorpicker,
139
- .no-font-face .wp_themeSkin .mceSplitButton .mce_spellchecker span.mce_spellchecker,
140
- .no-font-face .wp_themeSkin .mceSplitButton .mce_forecolor span.mce_forecolor,
141
- .no-font-face .wp_themeSkin .mceSplitButton span.mce_numlist,
142
- .no-font-face .wp_themeSkin .mceSplitButton span.mce_bullist {
143
- -moz-transition: none;
144
- -webkit-transition: none;
145
- transition: none;
146
- background-image: url('../images/wpicons.png?ver=20120720');
147
- }
148
-
149
- /* Theme */
150
- .no-font-face .wp_themeSkin span.mce_undo {background-position:-500px -20px}
151
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_undo,
152
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_undo {background-position:-500px 0}
153
-
154
- .no-font-face .wp_themeSkin span.mce_redo {background-position:-480px -20px}
155
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_redo,
156
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_redo {background-position:-480px 0}
157
-
158
- .no-font-face .wp_themeSkin span.mce_bullist {background-position:-40px -20px}
159
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_bullist,
160
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_bullist,
161
- .no-font-face .wp_themeSkin .mceSplitButton:hover span.mce_bullist {background-position:-40px 0}
162
-
163
- .no-font-face .wp_themeSkin span.mce_numlist {background-position:-60px -20px}
164
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_numlist,
165
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_numlist,
166
- .no-font-face .wp_themeSkin .mceSplitButton:hover span.mce_numlist {background-position:-60px 0}
167
-
168
- .no-font-face .wp_themeSkin span.mce_blockquote {background-position:-80px -20px}
169
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_blockquote,
170
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_blockquote {background-position:-80px 0}
171
-
172
- .no-font-face .wp_themeSkin span.mce_charmap {background-position:-420px -20px}
173
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_charmap,
174
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_charmap {background-position:-420px 0}
175
-
176
- .no-font-face .wp_themeSkin span.mce_bold {background-position:0 -20px}
177
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_bold,
178
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_bold {background-position:0 0}
179
-
180
- .no-font-face .wp_themeSkin span.mce_italic {background-position:-20px -20px}
181
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_italic,
182
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_italic {background-position:-20px 0}
183
-
184
- .no-font-face .wp_themeSkin span.mce_underline {background-position:-280px -20px}
185
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_underline,
186
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_underline {background-position:-280px 0}
187
-
188
- .no-font-face .wp_themeSkin span.mce_justifyleft {background-position:-100px -20px}
189
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_justifyleft,
190
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_justifyleft {background-position:-100px 0}
191
-
192
- .no-font-face .wp_themeSkin span.mce_justifyright {background-position:-140px -20px}
193
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_justifyright,
194
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_justifyright {background-position:-140px 0}
195
-
196
- .no-font-face .wp_themeSkin span.mce_justifycenter {background-position:-120px -20px}
197
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_justifycenter,
198
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_justifycenter {background-position:-120px 0}
199
-
200
- .no-font-face .wp_themeSkin span.mce_justifyfull {background-position:-300px -20px}
201
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_justifyfull,
202
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_justifyfull {background-position:-300px 0}
203
-
204
- .no-font-face .wp_themeSkin span.mce_indent {background-position:-460px -20px}
205
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_indent,
206
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_indent {background-position:-460px 0}
207
-
208
- .no-font-face .wp_themeSkin span.mce_outdent {background-position:-440px -20px}
209
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_outdent,
210
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_outdent {background-position:-440px 0}
211
-
212
- .no-font-face .wp_themeSkin span.mce_link {background-position:-160px -20px}
213
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_link,
214
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_link {background-position:-160px 0}
215
-
216
- .no-font-face .wp_themeSkin span.mce_unlink {background-position:-180px -20px}
217
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_unlink,
218
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_unlink {background-position:-180px 0}
219
-
220
- .no-font-face .wp_themeSkin span.mce_help {background-position:-520px -20px}
221
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_help,
222
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_help {background-position:-520px 0}
223
-
224
- .no-font-face .wp_themeSkin span.mce_removeformat {background-position:-380px -20px}
225
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_removeformat,
226
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_removeformat {background-position:-380px 0}
227
-
228
- .no-font-face .wp_themeSkin span.mce_strikethrough {background-position:-540px -20px;}
229
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_strikethrough,
230
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_strikethrough {background-position:-540px 0}
231
-
232
- .no-font-face .wp_themeSkin .mceSplitButton .mce_forecolor span.mce_forecolor {background-position:-320px -20px}
233
- .no-font-face .wp_themeSkin .mceSplitButtonEnabled:hover span.mce_forecolor,
234
- .no-font-face .wp_themeSkin .mceSplitButtonSelected span.mce_forecolor {background-position:-320px 0}
235
-
236
- .no-font-face .wp_themeSkin .mce_forecolorpicker {background-position:-320px -20px}
237
-
238
- /* Plugins in WP */
239
- .no-font-face .wp_themeSkin span.mce_fullscreen {background-position:-240px -20px}
240
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_fullscreen,
241
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_fullscreen {background-position:-240px 0}
242
-
243
- .no-font-face .wp_themeSkin span.mce_wp_fullscreen {background-position:-240px -20px}
244
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_wp_fullscreen,
245
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_wp_fullscreen {background-position:-240px 0}
246
-
247
- .no-font-face .wp_themeSkin span.mce_media {background-position:-400px -20px}
248
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_media,
249
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_media {background-position:-400px 0}
250
-
251
- .no-font-face .wp_themeSkin span.mce_pastetext {background-position:-340px -20px}
252
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_pastetext,
253
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_pastetext {background-position:-340px 0}
254
-
255
- .no-font-face .wp_themeSkin span.mce_pasteword {background-position:-360px -20px}
256
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_pasteword,
257
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_pasteword {background-position:-360px 0}
258
-
259
- .no-font-face .wp_themeSkin span.mce_spellchecker {background-position:-220px -20px}
260
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_spellchecker,
261
- .no-font-face .wp_themeSkin .mceSplitButtonEnabled:hover span.mce_spellchecker,
262
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_spellchecker,
263
- .no-font-face .wp_themeSkin .mceSplitButtonSelected span.mce_spellchecker {background-position:-220px 0}
264
-
265
- .no-font-face .wp_themeSkin span.mce_wp_help {background-position:-520px -20px}
266
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_wp_help,
267
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_wp_help {background-position:-520px 0}
268
-
269
- .no-font-face .wp_themeSkin span.mce_wp_adv {background-position:-260px -20px}
270
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_wp_adv,
271
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_wp_adv {background-position:-260px 0}
272
-
273
- .no-font-face .wp_themeSkin span.mce_wp_more {background-position:-200px -20px}
274
- .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_wp_more,
275
- .no-font-face .wp_themeSkin .mceButtonActive span.mce_wp_more {background-position:-200px 0}
276
-
277
- .no-font-face .mceIcon:before {
278
- display: none !important;
279
- }
280
- /* End no @font-face */
281
-
282
- /* Containers */
283
- .wp_themeSkin table {}
284
-
285
- .wp_themeSkin iframe {
286
- display: block;
287
- }
288
-
289
- .wp_themeSkin #mce_fullscreen_ifr {
290
- background-color: #fff;
291
- }
292
-
293
- .wp_themeSkin .mceToolbar {
294
- padding: 1px;
295
- }
296
-
297
- /* External */
298
- .wp_themeSkin .mceExternalToolbar {
299
- position: absolute;
300
- border-bottom: 0;
301
- display: none;
302
- }
303
-
304
- .wp_themeSkin .mceExternalToolbar td.mceToolbar {
305
- padding-right: 13px;
306
- }
307
-
308
- .wp_themeSkin .mceExternalClose {
309
- position: absolute;
310
- top: 3px;
311
- right: 3px;
312
- width: 7px;
313
- height: 7px;
314
- background: url("../js/tinymce/skins/wordpress/images/icons.gif") -820px 0;
315
- }
316
-
317
- /* Layout */
318
- .wp_themeSkin table.mceToolbar,
319
- .wp_themeSkin tr.mceFirst .mceToolbar tr td,
320
- .wp_themeSkin tr.mceLast .mceToolbar tr td {
321
- border: 0;
322
- margin: 0;
323
- padding: 0;
324
- }
325
-
326
- .wp_themeSkin table.mceLayout {
327
- border: 0;
328
- }
329
-
330
- .wp_themeSkin .mceStatusbar {
331
- background: #fff;
332
- border-top: 1px solid #eee;
333
- color: #000;
334
- display: block;
335
- font-family: sans-serif;
336
- font-size: 12px;
337
- height: 20px;
338
- line-height: 16px;
339
- padding: 0 0 0 8px;
340
- overflow: visible;
341
- }
342
-
343
- .wp_themeSkin .mceStatusbar * {
344
- color: #555;
345
- }
346
-
347
- .wp_themeSkin .mceStatusbar div {
348
- float: left;
349
- padding: 2px;
350
- }
351
-
352
- .wp_themeSkin .mceStatusbar a.mceResize {
353
- display: block;
354
- float: right;
355
- background: url("../js/tinymce/skins/wordpress/images/icons.gif") -800px 0;
356
- width: 20px;
357
- height: 20px;
358
- cursor: se-resize;
359
- }
360
-
361
- .wp_themeSkin .mceStatusbar a:hover {
362
- text-decoration: underline;
363
- }
364
-
365
- .wp_themeSkin table.mceToolbar {
366
- margin: 0 6px 2px;
367
- }
368
-
369
- .wp_themeSkin table.mceToolbar :active,
370
- .wp_themeSkin table.mceToolbar :focus,
371
- .wp_themeSkin table.mceToolbar:focus,
372
- .wp_themeSkin span.mceSeparator:focus {
373
- outline: none;
374
- }
375
-
376
- .wp_themeSkin #content_toolbar1 {
377
- margin-top: 2px;
378
- }
379
-
380
- .wp_themeSkin .mceToolbar .mceToolbarEndListBox span {
381
- display: none;
382
- }
383
-
384
- .wp_themeSkin span.mceIcon,
385
- .wp_themeSkin img.mceIcon {
386
- display: block;
387
- width: 20px;
388
- height: 20px;
389
- }
390
-
391
- a .mceIcon, .mceAction {
392
- text-align: center;
393
- font: normal 20px/1 'dashicons' !important;
394
- speak: none;
395
- -webkit-font-smoothing: antialiased;
396
- -moz-osx-font-smoothing: grayscale;
397
- }
398
-
399
- .mceAction {
400
- line-height:16px;
401
- }
402
-
403
- /* Button */
404
- .wp_themeSkin .mceButton {
405
- display: block;
406
- width: 20px;
407
- height: 20px;
408
- cursor: default;
409
- padding: 1px 2px;
410
- margin: 1px;
411
- -webkit-border-radius: 2px;
412
- border-radius: 2px;
413
- }
414
-
415
- .wp_themeSkin a.mceButtonEnabled:hover {
416
- background-image: inherit 0 -10px;
417
- }
418
-
419
- .wp_themeSkin .mceOldBoxModel a.mceButton span, .wp_themeSkin .mceOldBoxModel a.mceButton img {
420
- margin: 0 0 0 1px;
421
- }
422
-
423
- .wp_themeSkin .mceButtonDisabled .mceIcon {
424
- opacity: 0.2;
425
- filter: alpha(opacity=20);
426
- }
427
-
428
- /* Separator */
429
- .wp_themeSkin .mceSeparator {
430
- display: none;
431
- }
432
-
433
- /* ListBox */
434
- .wp_themeSkin .mceListBox,
435
- .wp_themeSkin .mceListBox a {
436
- display: block;
437
- }
438
-
439
- .wp_themeSkin .mceListBox .mceText {
440
- padding: 1px 4px 1px 5px;
441
- width: 70px;
442
- text-align: left;
443
- text-decoration: none;
444
- -webkit-border-bottom-left-radius: 2px;
445
- -webkit-border-top-left-radius: 2px;
446
- border-bottom-left-radius: 2px;
447
- border-top-left-radius: 2px;
448
- font-family: sans-serif;
449
- font-size: 12px;
450
- height: 20px;
451
- line-height: 20px;
452
- overflow: hidden;
453
- }
454
-
455
- .wp_themeSkin .mceListBox {
456
- margin: 1px;
457
- direction: ltr;
458
- background-color: #fff;
459
- border: 1px solid #ddd;
460
- -webkit-box-shadow: inset 0 1px 1px -1px rgba(0, 0, 0, .2);
461
- box-shadow: inset 0 1px 1px -1px rgba(0, 0, 0, .2);
462
- }
463
-
464
- .wp_themeSkin .mceListBox .mceOpen {
465
- width: 12px;
466
- height: 20px;
467
- border-collapse: separate;
468
- padding: 1px;
469
- -webkit-border-bottom-left-radius: 0;
470
- -webkit-border-top-left-radius: 0;
471
- border-bottom-left-radius: 0;
472
- border-top-left-radius: 0;
473
- }
474
-
475
- .wp_themeSkin .mceListBox .mceFirst a {
476
- border-style: solid;
477
- border-width: 1px;
478
- border-bottom-right-radius: 2px;
479
- border-top-right-radius: 2px;
480
- }
481
-
482
- .wp_themeSkin .mceListBoxMenu .mce_formatPreview {
483
- line-height: normal;
484
- }
485
-
486
- .wp_themeSkin .mceListBox .mceOpen,
487
- .wp_themeSkin .mceListBoxHover .mceOpen,
488
- .wp_themeSkin .mceListBoxSelected .mceOpen,
489
- .wp_themeSkin table.mceListBoxEnabled .mceOpen {
490
- background-image: url("../../../../../wp-includes/images/down_arrow.gif");
491
- background-position: 3px 1px;
492
- background-repeat: no-repeat;
493
- }
494
-
495
- .wp_themeSkin .mceListBoxDisabled .mceText {
496
- color: gray;
497
- }
498
-
499
- .wp_themeSkin .mceListBoxMenu {
500
- overflow: auto;
501
- overflow-x: hidden;
502
- }
503
-
504
- .wp_themeSkin .mceOldBoxModel .mceListBox .mceText {
505
- height: 22px;
506
- }
507
-
508
- .wp_themeSkin select.mceListBox {
509
- font-family: sans-serif;
510
- font-size: 12px;
511
- border-color: #b2b2b2;
512
- background-color: #fff;
513
- }
514
-
515
- /* SplitButton */
516
- .wp_themeSkin .mceSplitButton a,
517
- .wp_themeSkin .mceSplitButton span {
518
- display: block;
519
- height: 20px;
520
- }
521
-
522
- .wp_themeSkin .mceSplitButton {
523
- display: block;
524
- direction: ltr;
525
- }
526
-
527
- .wp_themeSkin table.mceSplitButton td {
528
- padding: 2px;
529
- -webkit-border-radius: 2px;
530
- border-radius: 2px;
531
- }
532
-
533
- .wp_themeSkin table.mceSplitButton:hover td {
534
- background-image: inherit 0 -10px;
535
- }
536
-
537
- .wp_themeSkin .mceSplitButton a.mceAction {
538
- height: 20px;
539
- width: 20px;
540
- padding: 1px 2px;
541
- border-right: 0 none;
542
- }
543
-
544
- .wp_themeSkin .mceSplitButton span.mceAction {
545
- background-image: url("../../../../../wp-includes/js/tinymce/skins/wordpress/images/icons.gif");
546
- background-repeat: no-repeat;
547
- background-color: transparent;
548
- width: 20px;
549
- }
550
-
551
- .wp_themeSkin .mceSplitButton span.mceAction.mce_bullist,
552
- .wp_themeSkin .mceSplitButton span.mceAction.mce_numlist {
553
- background-image: none;
554
- }
555
-
556
- .wp_themeSkin .mceSplitButton a.mceOpen {
557
- width: 11px;
558
- height: 20px;
559
- background-position: 0px 2px;
560
- background-repeat: no-repeat;
561
- padding: 1px 0;
562
- }
563
-
564
- .wp_themeSkin .mceSplitButton span.mceOpen {
565
- display: none;
566
- }
567
-
568
- .wp_themeSkin .mceSplitButtonDisabled .mceAction {
569
- opacity: 0.3;
570
- filter: alpha(opacity=30);
571
- }
572
-
573
- .wp_themeSkin .mceListBox a.mceText,
574
- .wp_themeSkin .mceSplitButton a.mceAction {
575
- -webkit-border-bottom-left-radius: 2px;
576
- -webkit-border-top-left-radius: 2px;
577
- border-bottom-left-radius: 2px;
578
- border-top-left-radius: 2px;
579
- }
580
-
581
- .wp_themeSkin .mceSplitButton a.mceOpen,
582
- .wp_themeSkin .mceListBox a.mceOpen {
583
- -webkit-border-bottom-right-radius: 2px;
584
- -webkit-border-top-right-radius: 2px;
585
- border-bottom-right-radius: 2px;
586
- border-top-right-radius: 2px;
587
- }
588
-
589
- /* ColorSplitButton */
590
- .wp_themeSkin div.mceColorSplitMenu table {
591
- background-color: #ebebeb;
592
- border-color: #bbb;
593
- }
594
-
595
- .wp_themeSkin .mceColorSplitMenu td {
596
- padding: 2px;
597
- }
598
-
599
- .wp_themeSkin .mceColorSplitMenu a {
600
- display: block;
601
- width: 9px;
602
- height: 9px;
603
- overflow: hidden;
604
- border-color: #B2B2B2;
605
- }
606
-
607
- .wp_themeSkin .mceColorSplitMenu td.mceMoreColors {
608
- padding: 1px 3px 1px 1px;
609
- }
610
-
611
- .wp_themeSkin .mceColorSplitMenu a.mceMoreColors {
612
- width: 100%;
613
- height: auto;
614
- text-align: center;
615
- font-family: "Open Sans", sans-serif;
616
- font-size: 11px;
617
- line-height: 20px;
618
- border-color: #fff;
619
- }
620
-
621
- .wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover {}
622
- .wp_themeSkin a.mceMoreColors:hover {}
623
- .wp_themeSkin .mceColorPreview {
624
- margin: -5px 0 0 2px;
625
- width: 16px;
626
- height: 4px;
627
- overflow: hidden;
628
- }
629
-
630
- /* Menu */
631
- .wp_themeSkin .mceMenu {
632
- position: absolute;
633
- left: 0;
634
- top: 0;
635
- z-index: 1000;
636
- border-color: #ddd;
637
- direction: ltr;
638
- }
639
-
640
- .wp_themeSkin .mceNoIcons span.mceIcon {
641
- width: 0;
642
- }
643
-
644
- .wp_themeSkin .mceNoIcons a .mceText {
645
- padding-left: 10px;
646
- }
647
-
648
- .wp_themeSkin .mceMenu table {
649
- background-color: #ebeaeb;
650
- }
651
-
652
- .wp_themeSkin .mceMenu a,
653
- .wp_themeSkin .mceMenu span,
654
- .wp_themeSkin .mceMenu {
655
- display: block;
656
- }
657
-
658
- .wp_themeSkin .mceMenu td {
659
- height: 20px;overflow: hidden;
660
- }
661
-
662
- .wp_themeSkin .mceMenu a {
663
- position: relative;
664
- padding: 3px 0 4px 0;
665
- text-decoration: none !important;
666
- }
667
-
668
- .wp_themeSkin .mceMenu .mceText {
669
- position: relative;
670
- display: block;
671
- font-family: "Open Sans", sans-serif;
672
- cursor: default;
673
- margin: 0;
674
- padding: 0 25px;
675
- color: #000;
676
- }
677
-
678
- .wp_themeSkin .mceMenu span.mceText, .wp_themeSkin .mceMenu .mcePreview {
679
- font-size: 12px;
680
- }
681
-
682
- .wp_themeSkin .mceMenu pre.mceText {
683
- font-family: Monospace;
684
- }
685
-
686
- .wp_themeSkin .mceMenu .mceIcon {
687
- position: absolute;
688
- top: 0;
689
- left: 0;
690
- width: 22px;
691
- }
692
-
693
- .wp_themeSkin .mceMenu .mceMenuItemEnabled a:hover,
694
- .wp_themeSkin .mceMenu .mceMenuItemActive {
695
- background-color: #f5f5f5;
696
- }
697
-
698
- .wp_themeSkin td.mceMenuItemSeparator {
699
- height: 1px;
700
- background-color: #aaa;
701
- }
702
-
703
- .wp_themeSkin .mceMenuItemTitle a {
704
- border-top: 0;
705
- border-right: 0;
706
- border-left: 0;
707
- border-bottom: 1px solid #aaa;
708
- text-decoration: none !important;
709
- background-color: #ccc;
710
- }
711
-
712
- .wp_themeSkin .mceMenuItemTitle span.mceText {
713
- font-weight: bold;
714
- padding-left: 4px;
715
- color: #000;
716
- }
717
-
718
- .wp_themeSkin .mceMenuItemSelected .mceIcon {
719
- background: url("/wp-includes/js/tinymce/skins/wordpress/images/menu_check.gif");
720
- color: #888;
721
- }
722
-
723
- .wp_themeSkin .mceNoIcons .mceMenuItemSelected a {
724
- background: url("/wp-includes/js/tinymce/skins/wordpress/images/menu_arrow.gif") no-repeat -6px center;
725
- }
726
-
727
- .wp_themeSkin .mceMenu span.mceMenuLine {
728
- display: none;
729
- }
730
-
731
- .wp_themeSkin .mceMenuItemSub a {
732
- background: url("/wp-includes/js/tinymce/skins/wordpress/images/menu_arrow.gif") no-repeat top right;
733
- }
734
-
735
- /* Progress,Resize */
736
- .wp_themeSkin .mceBlocker {
737
- position: absolute;
738
- left: 0;
739
- top: 0;
740
- z-index: 1000;
741
- opacity: 0.5;
742
- filter: alpha(opacity=50);
743
- background: #FFF;
744
- }
745
-
746
- .wp_themeSkin .mceProgress {
747
- position: absolute;
748
- left: 0;
749
- top: 0;
750
- z-index: 1001;
751
- background: url("/wp-includes/images/spinner.gif") no-repeat;
752
- width: 32px;
753
- height: 32px;
754
- margin: -16px 0 0 -16px;
755
- }
756
-
757
- .wp_themeSkin .mcePlaceHolder {
758
- border: 1px dotted gray;
759
- }
760
-
761
- /* Rtl */
762
- .mceRtl .mceListBox .mceText {
763
- text-align: right;
764
- padding: 0 4px 0 0;
765
- }
766
-
767
- .mceRtl .mceMenuItem .mceText {
768
- text-align: right;
769
- }
770
-
771
- /* Formats */
772
- .wp_themeSkin .mce_p span.mceText {}
773
- .wp_themeSkin .mce_address span.mceText {
774
- font-style: italic;
775
- }
776
-
777
- .wp_themeSkin .mce_pre span.mceText {
778
- font-family: monospace;
779
- }
780
-
781
- .wp_themeSkin .mce_h1 span.mceText {
782
- font-weight: bolder;
783
- font-size: 18px;
784
- }
785
-
786
- .wp_themeSkin .mce_h2 span.mceText {
787
- font-weight: bolder;
788
- font-size: 14px;
789
- }
790
-
791
- .wp_themeSkin .mce_h3 span.mceText {
792
- font-weight: bolder;
793
- font-size: 12px;
794
- }
795
-
796
- .wp_themeSkin .mce_h4 span.mceText {
797
- font-weight: bolder;
798
- font-size: 11px;
799
- }
800
-
801
- .wp_themeSkin .mce_h5 span.mceText {
802
- font-weight: bolder;
803
- font-size: 11px;
804
- }
805
-
806
- .wp_themeSkin .mce_h6 span.mceText {
807
- font-weight: bolder;
808
- font-size: 10px;
809
- }
810
-
811
- span.mce_bold:before {
812
- content: '\f200';
813
- }
814
-
815
- span.mce_italic:before {
816
- content: '\f201';
817
- }
818
-
819
- span.mce_bullist:before {
820
- content: '\f203';
821
- }
822
-
823
- span.mce_numlist:before {
824
- content: '\f204';
825
- }
826
-
827
- span.mce_blockquote:before {
828
- content: '\f205';
829
- }
830
-
831
- span.mce_justifyleft:before {
832
- content: '\f206';
833
- }
834
-
835
- span.mce_justifycenter:before {
836
- content: '\f207';
837
- }
838
-
839
- span.mce_justifyright:before {
840
- content: '\f208';
841
- }
842
-
843
- span.mce_link:before {
844
- content: '\f103';
845
- }
846
-
847
- span.mce_unlink:before {
848
- content: '\f225';
849
- }
850
-
851
- span.mce_wp_more:before {
852
- content: '\f209';
853
- }
854
-
855
- span.mce_strikethrough:before {
856
- content: '\f224';
857
- }
858
-
859
- span.mce_spellchecker {
860
- font-size: 20px;
861
- background: none !important;
862
- margin-top: 2px;
863
- }
864
-
865
- span.mce_spellchecker:before {
866
- content: '\f210';
867
- }
868
-
869
- span.mce_fullscreen:before,
870
- span.mce_wp_fullscreen:before {
871
- content: '\f211';
872
- }
873
-
874
- span.mce_wp_adv:before {
875
- content: '\f212';
876
- }
877
- span.mce_underline:before {
878
- content: '\f213';
879
- }
880
-
881
- span.mce_justifyfull:before {
882
- content: '\f214';
883
- }
884
-
885
- span.mce_forecolor {
886
- background: none !important;
887
- }
888
-
889
- span.mce_forecolor:before {
890
- content: '\f215';
891
- }
892
-
893
- span.mce_pastetext:before {
894
- content: '\f217';
895
- }
896
-
897
- span.mce_pasteword:before {
898
- content: '\f216';
899
- }
900
-
901
- span.mce_removeformat:before {
902
- content: '\f218';
903
- }
904
-
905
- span.mce_charmap:before {
906
- content: '\f220';
907
- }
908
-
909
- span.mce_outdent:before {
910
- content: '\f221';
911
- }
912
-
913
- span.mce_indent:before {
914
- content: '\f222';
915
- }
916
-
917
- span.mce_undo:before {
918
- content: '\f171';
919
- }
920
-
921
- span.mce_redo:before {
922
- content: '\f172';
923
- }
924
-
925
- span.mce_help:before,
926
- span.mce_wp_help:before {
927
- content: '\f223';
928
- }
929
-
930
- span.mce_image:before {
931
- content: '\f104';
932
- }
933
-
934
- span.mce_ltr:before {
935
- content: '\f320';
936
- }
937
-
938
- /* Default icons */
939
- .wp_themeSkin span.mce_cleanup {background-position:-380px -20px}
940
- .wp_themeSkin span.mce_anchor {background-position:-200px 0}
941
- .wp_themeSkin span.mce_sub {background-position:-600px 0}
942
- .wp_themeSkin span.mce_sup {background-position:-620px 0}
943
- .wp_themeSkin span.mce_newdocument {background-position:-520px 0}
944
- .wp_themeSkin span.mce_image {background-position:-380px 0}
945
- .wp_themeSkin span.mce_code {background-position:-260px 0}
946
- .wp_themeSkin span.mce_hr {background-position:-360px 0}
947
- .wp_themeSkin span.mce_visualaid {background-position:-660px 0}
948
- .wp_themeSkin span.mce_paste {background-position:-560px 0}
949
- .wp_themeSkin span.mce_copy {background-position:-700px 0}
950
- .wp_themeSkin span.mce_cut {background-position:-680px 0}
951
- .wp_themeSkin .mce_backcolor span.mceAction {background-position:-760px 0}
952
- .wp_themeSkin .mce_backcolorpicker {background-position:-760px 0}
953
-
954
- /* Plugins */
955
- .wp_themeSkin span.mce_advhr {background-position:-0px -20px}
956
- .wp_themeSkin span.mce_ltr {background-position:-20px -20px}
957
- .wp_themeSkin span.mce_rtl {background-position:-40px -20px}
958
- .wp_themeSkin span.mce_emotions {background-position:-60px -20px}
959
- .wp_themeSkin span.mce_fullpage {background-position:-80px -20px}
960
- .wp_themeSkin span.mce_iespell {background-position:-120px -20px}
961
- .wp_themeSkin span.mce_insertdate {background-position:-140px -20px}
962
- .wp_themeSkin span.mce_inserttime {background-position:-160px -20px}
963
- .wp_themeSkin span.mce_absolute {background-position:-180px -20px}
964
- .wp_themeSkin span.mce_backward {background-position:-200px -20px}
965
- .wp_themeSkin span.mce_forward {background-position:-220px -20px}
966
- .wp_themeSkin span.mce_insert_layer {background-position:-240px -20px}
967
- .wp_themeSkin span.mce_insertlayer {background-position:-260px -20px}
968
- .wp_themeSkin span.mce_movebackward {background-position:-280px -20px}
969
- .wp_themeSkin span.mce_moveforward {background-position:-300px -20px}
970
- .wp_themeSkin span.mce_media {background-position:-320px -20px}
971
- .wp_themeSkin span.mce_nonbreaking {background-position:-340px -20px}
972
- .wp_themeSkin span.mce_selectall {background-position:-400px -20px}
973
- .wp_themeSkin span.mce_preview {background-position:-420px -20px}
974
- .wp_themeSkin span.mce_print {background-position:-440px -20px}
975
- .wp_themeSkin span.mce_cancel {background-position:-460px -20px}
976
- .wp_themeSkin span.mce_save {background-position:-480px -20px}
977
- .wp_themeSkin span.mce_replace {background-position:-500px -20px}
978
- .wp_themeSkin span.mce_search {background-position:-520px -20px}
979
- .wp_themeSkin span.mce_styleprops {background-position:-560px -20px}
980
- .wp_themeSkin span.mce_table {background-position:-580px -20px}
981
- .wp_themeSkin span.mce_cell_props {background-position:-600px -20px}
982
- .wp_themeSkin span.mce_delete_table {background-position:-620px -20px}
983
- .wp_themeSkin span.mce_delete_col {background-position:-640px -20px}
984
- .wp_themeSkin span.mce_delete_row {background-position:-660px -20px}
985
- .wp_themeSkin span.mce_col_after {background-position:-680px -20px}
986
- .wp_themeSkin span.mce_col_before {background-position:-700px -20px}
987
- .wp_themeSkin span.mce_row_after {background-position:-720px -20px}
988
- .wp_themeSkin span.mce_row_before {background-position:-740px -20px}
989
- .wp_themeSkin span.mce_merge_cells {background-position:-760px -20px}
990
- .wp_themeSkin span.mce_table_props {background-position:-980px -20px}
991
- .wp_themeSkin span.mce_row_props {background-position:-780px -20px}
992
- .wp_themeSkin span.mce_split_cells {background-position:-800px -20px}
993
- .wp_themeSkin span.mce_template {background-position:-820px -20px}
994
- .wp_themeSkin span.mce_visualchars {background-position:-840px -20px}
995
- .wp_themeSkin span.mce_abbr {background-position:-860px -20px}
996
- .wp_themeSkin span.mce_acronym {background-position:-880px -20px}
997
- .wp_themeSkin span.mce_attribs {background-position:-900px -20px}
998
- .wp_themeSkin span.mce_cite {background-position:-920px -20px}
999
- .wp_themeSkin span.mce_del {background-position:-940px -20px}
1000
- .wp_themeSkin span.mce_ins {background-position:-960px -20px}
1001
- .wp_themeSkin span.mce_pagebreak {background-position:0 -40px}
1002
- .wp_themeSkin span.mce_restoredraft {background-position:-20px -40px}
1003
- .wp_themeSkin span.mce_visualblocks {background-position: -40px -40px}
1004
-
1005
- /* border */
1006
- .wp_themeSkin .mceExternalToolbar,
1007
- .wp_themeSkin .mceButton,
1008
- .wp_themeSkin a.mceButtonEnabled:hover,
1009
- .wp_themeSkin a.mceButtonActive,
1010
- .wp_themeSkin a.mceButtonSelected,
1011
- .wp_themeSkin .mceListBox .mceText,
1012
- .wp_themeSkin .mceListBox .mceOpen,
1013
- .wp_themeSkin select.mceListBox,
1014
- .wp_themeSkin .mceSplitButton a.mceAction,
1015
- .wp_themeSkin .mceSplitButton a.mceOpen,
1016
- .wp_themeSkin .mceSplitButton a.mceOpen:hover,
1017
- .wp_themeSkin .mceSplitButtonSelected a.mceOpen,
1018
- .wp_themeSkin table.mceSplitButtonEnabled:hover a.mceAction,
1019
- .wp_themeSkin .mceSplitButton a.mceAction:hover,
1020
- .wp_themeSkin div.mceColorSplitMenu table,
1021
- .wp_themeSkin .mceColorSplitMenu a,
1022
- .wp_themeSkin .mceColorSplitMenu a.mceMoreColors,
1023
- .wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover,
1024
- .wp_themeSkin a.mceMoreColors:hover,
1025
- .wp_themeSkin .mceMenu {
1026
- border-style: solid;
1027
- border-width: 1px;
1028
- }
1029
-
1030
- .wp_themeSkin .mceListBox .mceText {
1031
- border-right: 0 none;
1032
- }
1033
-
1034
- .wp_themeSkin iframe {
1035
- background: transparent;
1036
- }
1037
-
1038
- .wp_themeSkin .mceButton {
1039
- border-color: transparent;
1040
- }
1041
-
1042
- .wp_themeSkin .mceListBox .mceText,
1043
- .wp_themeSkin .mceListBox .mceOpen {
1044
- border-color: transparent;
1045
- }
1046
-
1047
- .wp_themeSkin a.mceButtonEnabled:hover,
1048
- .wp_themeSkin table.mceSplitButton:hover {
1049
- border-color: #bbb;
1050
- background: #eee;
1051
- background-image: -webkit-gradient(linear, left bottom, left top, from(#e5e5e5), to(#fff));
1052
- background-image: -webkit-linear-gradient(bottom, #e5e5e5, #fff);
1053
- background-image: -moz-linear-gradient(bottom, #e5e5e5, #fff);
1054
- background-image: -o-linear-gradient(bottom, #e5e5e5, #fff);
1055
- background-image: linear-gradient(to top, #e5e5e5, #fff);
1056
- }
1057
-
1058
- .wp_themeSkin a.mceButton:active,
1059
- .wp_themeSkin a.mceButtonEnabled:active,
1060
- .wp_themeSkin a.mceButtonSelected:active,
1061
- .wp_themeSkin a.mceButtonActive,
1062
- .wp_themeSkin a.mceButtonActive:active,
1063
- .wp_themeSkin a.mceButtonActive:hover,
1064
- .wp_themeSkin .mceSplitButtonSelected table,
1065
- .wp_themeSkin .mceSplitButtonSelected table:hover {
1066
- outline: none;
1067
- border-color: #999 #ccc #ccc #999;
1068
- background: #eee;
1069
- background-image: -webkit-gradient(linear, left bottom, left top, from(#f6f6f6), to(#e3e3e3));
1070
- background-image: -webkit-linear-gradient(bottom, #f6f6f6, #e3e3e3);
1071
- background-image: -moz-linear-gradient(bottom, #f6f6f6, #e3e3e3);
1072
- background-image: -o-linear-gradient(bottom, #f6f6f6, #e3e3e3);
1073
- background-image: linear-gradient(to top, #f6f6f6, #e3e3e3);
1074
- }
1075
-
1076
- .wp_themeSkin .mceSplitButtonSelected table a.mceOpen,
1077
- .wp_themeSkin .mceSplitButtonSelected table a.mceAction {
1078
- border-color: #999 #ccc #ccc #999;
1079
- }
1080
-
1081
- .wp_themeSkin .mceButtonDisabled {
1082
- border-color: transparent;
1083
- }
1084
-
1085
- .wp_themeSkin .mceListBox .mceOpen {
1086
- border-left: 0;
1087
- }
1088
-
1089
- .wp_themeSkin .mceListBoxEnabled:hover,
1090
- .wp_themeSkin .mceListBoxEnabled:active,
1091
- .wp_themeSkin .mceListBoxHover,
1092
- .wp_themeSkin .mceListBoxHover:active,
1093
- .wp_themeSkin .mceListBoxSelected {
1094
- -webkit-box-shadow: inset 0 1px 1px -1px rgba(0, 0, 0, .3);
1095
- box-shadow: inset 0 1px 1px -1px rgba(0, 0, 0, .3);
1096
- border-color: #bbb;
1097
- }
1098
-
1099
- /* SplitButton */
1100
- .wp_themeSkin .mceSplitButton .mceLast span.mceOpen .mceIconOnly {
1101
- display: block;
1102
- }
1103
-
1104
- .wp_themeSkin .mceSplitButton a.mceAction,
1105
- .wp_themeSkin .mceSplitButton a.mceOpen {
1106
- border-color: transparent;
1107
- }
1108
-
1109
- .wp_themeSkin .mceSplitButton:hover a {
1110
- border-color: #bbb;
1111
- }
1112
-
1113
- .wp_themeSkin .mceSplitButtonEnabled a.mceOpen,
1114
- .wp_themeSkin .mceSplitButtonSelected a.mceOpen,
1115
- .wp_themeSkin .mceSplitButtonActive a.mceOpen,
1116
- .wp_themeSkin .mceSplitButtonEnabled:hover a.mceOpen {
1117
- background-image: url("../../../../../wp-includes/images/down_arrow.gif");
1118
- background-position: 1px 2px;
1119
- background-repeat: no-repeat;
1120
- border-left: 0;
1121
- }
1122
-
1123
- .wp_themeSkin .mceSplitButtonActive td {
1124
- -webkit-border-radius: 3px;
1125
- border-radius: 3px;
1126
- }
1127
-
1128
- .wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover {
1129
- border-color: #0A246A;
1130
- background-color: #B6BDD2;
1131
- }
1132
-
1133
- .wp_themeSkin a.mceMoreColors:hover {
1134
- border-color: #0A246A;
1135
- }
1136
-
1137
- .wp_themeSkin .mceMenuItemDisabled .mceText {
1138
- color: #888;
1139
- }
1140
-
1141
- #mceModalBlocker {
1142
- background: #000;
1143
- opacity: 0.7;
1144
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
1145
- filter: alpha(opacity=70);
1146
- }
1147
-
1148
- /* WP specific */
1149
- .wp-editor-wrap {
1150
- position: relative;
1151
- }
1152
-
1153
- .wp-editor-tools {
1154
- position: relative;
1155
- z-index: 1;
1156
- }
1157
-
1158
- .wp-editor-container {
1159
- clear: both;
1160
- }
1161
-
1162
- .wp-editor-area {
1163
- font-family: Consolas, Monaco, monospace;
1164
- font-size: 13px;
1165
- padding: 10px;
1166
- margin: 1px 0 0;
1167
- line-height: 150%;
1168
- border: 0 none;
1169
- outline: none;
1170
- display: block;
1171
- resize: vertical;
1172
- -moz-box-sizing: border-box;
1173
- -webkit-box-sizing: border-box;
1174
- box-sizing: border-box;
1175
- }
1176
-
1177
- .wp-editor-tools {
1178
- padding: 0;
1179
- }
1180
-
1181
- .wp-editor-container textarea.wp-editor-area {
1182
- width: 100%;
1183
- margin: 0;
1184
- -webkit-box-shadow: none;
1185
- box-shadow: none;
1186
- }
1187
-
1188
- .quicktags-toolbar,
1189
- .wp_themeSkin tr.mceFirst td.mceToolbar {
1190
- border-bottom: 1px solid #dedede;
1191
- background: #f5f5f5;
1192
- }
1193
-
1194
- .wp-editor-tabs {
1195
- float: right;
1196
- }
1197
-
1198
- .wp-switch-editor {
1199
- background: #ebebeb;
1200
- border: 1px solid #dedede;
1201
- color: #777;
1202
- cursor: pointer;
1203
- float: right;
1204
- font: 13px/19px "Open Sans", sans-serif;
1205
- height: 19px;
1206
- margin: 5px 0 0 5px;
1207
- padding: 3px 8px 4px;
1208
- position: relative;
1209
- top: 1px;
1210
- }
1211
-
1212
- .wp-switch-editor:active {
1213
- background-color: #f1f1f1;
1214
- }
1215
-
1216
- .wp-switch-editor:hover {
1217
- text-decoration: none !important;
1218
- background: #fff;
1219
- }
1220
-
1221
- .js .tmce-active .wp-editor-area {
1222
- color: white;
1223
- }
1224
-
1225
- .tmce-active .quicktags-toolbar {
1226
- display: none;
1227
- }
1228
-
1229
- .tmce-active .switch-tmce,
1230
- .html-active .switch-html {
1231
- background: #f5f5f5;
1232
- color: #555;
1233
- height: 20px;
1234
- border-bottom: none;
1235
- }
1236
-
1237
- .wp-media-buttons {
1238
- float: left;
1239
- }
1240
-
1241
- .wp-media-buttons .button {
1242
- margin-right: 5px;
1243
- margin-bottom: 4px;
1244
- padding-left: 7px;
1245
- padding-right: 7px;
1246
- }
1247
-
1248
- .wp-media-buttons .button:active {
1249
- position: relative;
1250
- top: 1px;
1251
- margin-top: -1px;
1252
- margin-bottom: 1px;
1253
- }
1254
-
1255
- .wp-media-buttons .insert-media {
1256
- padding-left: 5px;
1257
- }
1258
-
1259
- .wp-media-buttons a {
1260
- text-decoration: none;
1261
- color: #464646;
1262
- font-size: 12px;
1263
- }
1264
-
1265
- .wp-media-buttons img {
1266
- padding: 0 4px;
1267
- vertical-align: middle;
1268
- }
1269
-
1270
- .wp-media-buttons span.wp-media-buttons-icon {
1271
- display: inline-block;
1272
- width: 18px;
1273
- height: 18px;
1274
- vertical-align: text-top;
1275
- margin: 0 2px;
1276
- }
1277
-
1278
- .wp-media-buttons .add_media span.wp-media-buttons-icon {
1279
- background: none;
1280
- }
1281
-
1282
- .wp-media-buttons .add_media span.wp-media-buttons-icon:before {
1283
- font: normal 18px/1 'dashicons';
1284
- speak: none;
1285
- -webkit-font-smoothing: antialiased;
1286
- -moz-osx-font-smoothing: grayscale;
1287
- }
1288
-
1289
- .wp-media-buttons .add_media span.wp-media-buttons-icon:before {
1290
- content: '\f104';
1291
- }
1292
-
1293
- .quicktags-toolbar {
1294
- border-bottom-style: solid;
1295
- border-bottom-width: 1px;
1296
- -webkit-border-top-right-radius: 3px;
1297
- -webkit-border-top-left-radius: 3px;
1298
- border-top-right-radius: 3px;
1299
- border-top-left-radius: 3px;
1300
- padding: 2px 8px 0;
1301
- min-height: 29px;
1302
- }
1303
-
1304
- .quicktags-toolbar > div {
1305
- padding: 2px 4px 0;
1306
- }
1307
-
1308
- .quicktags-toolbar input {
1309
- margin: 2px 1px 4px;
1310
- line-height: 18px;
1311
- display: inline-block;
1312
- min-width: 26px;
1313
- padding: 2px 4px;
1314
- font: 12px/18px "Open Sans", sans-serif;
1315
- color: #464646;
1316
- border: 1px solid #c3c3c3;
1317
- -webkit-border-radius: 3px;
1318
- border-radius: 3px;
1319
- background: #eee;
1320
- background-image: -webkit-gradient(linear, left bottom, left top, from(#e3e3e3), to(#fff));
1321
- background-image: -webkit-linear-gradient(bottom, #e3e3e3, #fff);
1322
- background-image: -moz-linear-gradient(bottom, #e3e3e3, #fff);
1323
- background-image: -o-linear-gradient(bottom, #e3e3e3, #fff);
1324
- background-image: linear-gradient(to top, #e3e3e3, #fff);
1325
- }
1326
-
1327
- .quicktags-toolbar input:hover {
1328
- border-color: #aaa;
1329
- background: #ddd;
1330
- }
1331
-
1332
- .quicktags-toolbar input[value="link"] {
1333
- text-decoration: underline;
1334
- }
1335
-
1336
- .quicktags-toolbar input[value="del"] {
1337
- text-decoration: line-through;
1338
- }
1339
-
1340
- .quicktags-toolbar input[value="i"] {
1341
- font-style: italic;
1342
- }
1343
-
1344
- .quicktags-toolbar input[value="b"] {
1345
- font-weight: bold;
1346
- }
1347
-
1348
- #wp_editbtns,
1349
- #wp_gallerybtns {
1350
- padding: 2px;
1351
- position: absolute;
1352
- display: none;
1353
- z-index: 155000;
1354
- }
1355
-
1356
- #wp_editimgbtn,
1357
- #wp_delimgbtn,
1358
- #wp_editgallery,
1359
- #wp_delgallery {
1360
- border-color: #999;
1361
- background-color: #eee;
1362
- margin: 2px;
1363
- padding: 2px;
1364
- border-width: 1px;
1365
- border-style: solid;
1366
- -webkit-border-radius: 3px;
1367
- border-radius: 3px;
1368
- }
1369
-
1370
- #wp_editimgbtn:hover,
1371
- #wp_delimgbtn:hover,
1372
- #wp_editgallery:hover,
1373
- #wp_delgallery:hover {
1374
- border-color: #555;
1375
- background-color: #ccc;
1376
- }
1377
-
1378
- /*------------------------------------------------------------------------------
1379
- wp-link
1380
- ------------------------------------------------------------------------------*/
1381
-
1382
- #wp-link {
1383
- background-color: #F5F5F5;
1384
- line-height: 1.4em;
1385
- font-size: 12px;
1386
- }
1387
-
1388
- #wp-link ol,
1389
- #wp-link ul {
1390
- list-style: none;
1391
- margin: 0;
1392
- padding: 0;
1393
- }
1394
-
1395
- #wp-link input[type="text"] {
1396
- -webkit-box-sizing: border-box;
1397
- }
1398
-
1399
- #wp-link input[type="text"],
1400
- #wp-link textarea {
1401
- border-width: 1px;
1402
- border-style: solid;
1403
- -webkit-border-radius: 4px;
1404
- border-radius: 4px;
1405
- font-size: 12px;
1406
- margin: 1px;
1407
- padding: 3px;
1408
- }
1409
-
1410
- #wp-link #link-options {
1411
- padding: 10px 0 14px;
1412
- border-bottom: 1px solid #dfdfdf;
1413
- margin: 0 6px 14px;
1414
- }
1415
-
1416
- #wp-link p.howto {
1417
- margin: 3px;
1418
- }
1419
-
1420
- #wp-link #internal-toggle {
1421
- display: inline-block;
1422
- cursor: pointer;
1423
- padding-left: 18px;
1424
- }
1425
-
1426
- #wp-link .toggle-arrow {
1427
- background: transparent url("../../../../../wp-includes/images/toggle-arrow.png") top left no-repeat;
1428
- height: 23px;
1429
- line-height: 23px;
1430
- }
1431
-
1432
- #wp-link .toggle-arrow-active {
1433
- background-position: center left;
1434
- }
1435
-
1436
- #wp-link label input[type="text"] {
1437
- width: 360px;
1438
- margin-top: 5px;
1439
- }
1440
-
1441
- #wp-link #link-options label span,
1442
- #wp-link #search-panel label span.search-label {
1443
- display: inline-block;
1444
- width: 80px;
1445
- text-align: right;
1446
- padding-right: 5px;
1447
- }
1448
-
1449
- #wp-link .link-search-field {
1450
- float: left;
1451
- width: 220px;
1452
- }
1453
-
1454
- #wp-link .link-search-wrapper {
1455
- margin: 5px 6px 9px;
1456
- display: block;
1457
- overflow: hidden;
1458
- }
1459
-
1460
- #wp-link .link-search-wrapper span {
1461
- float: left;
1462
- margin-top: 4px;
1463
- }
1464
-
1465
- #wp-link .link-search-wrapper .spinner {
1466
- display: none;
1467
- vertical-align: text-bottom;
1468
- }
1469
-
1470
- #wp-link .link-target {
1471
- width: auto;
1472
- padding: 3px 0 0;
1473
- margin: 0 0 0 87px;
1474
- font-size: 11px;
1475
- }
1476
-
1477
- #wp-link .query-results {
1478
- border: 1px #dfdfdf solid;
1479
- margin: 0 5px 5px;
1480
- background: #fff;
1481
- height: 185px;
1482
- overflow: auto;
1483
- position: relative;
1484
- }
1485
-
1486
- #wp-link li,
1487
- #wp-link .query-notice {
1488
- clear: both;
1489
- margin-bottom: 0;
1490
- border-bottom: 1px solid #f1f1f1;
1491
- color: #333;
1492
- padding: 4px 6px;
1493
- cursor: pointer;
1494
- position: relative;
1495
- }
1496
-
1497
- #wp-link li:hover {
1498
- background: #eaf2fa;
1499
- color: #151515;
1500
- }
1501
-
1502
- #wp-link li.unselectable {
1503
- border-bottom: 1px solid #dfdfdf;
1504
- }
1505
-
1506
- #wp-link li.unselectable:hover {
1507
- background: #fff;
1508
- cursor: auto;
1509
- color: #333;
1510
- }
1511
-
1512
- #wp-link li.selected {
1513
- background: #ddd;
1514
- color: #333;
1515
- }
1516
-
1517
- #wp-link li.selected .item-title {
1518
- font-weight: bold;
1519
- }
1520
-
1521
- #wp-link .item-title {
1522
- display: inline-block;
1523
- width: 80%;
1524
- }
1525
-
1526
- #wp-link .item-info {
1527
- text-transform: uppercase;
1528
- color: #666;
1529
- font-size: 11px;
1530
- position: absolute;
1531
- right: 5px;
1532
- top: 4px;
1533
- bottom: 0;
1534
- }
1535
-
1536
- #wp-link #search-results {
1537
- display: none;
1538
- }
1539
-
1540
- #wp-link #search-panel {
1541
- float: left;
1542
- width: 100%;
1543
- }
1544
-
1545
- #wp-link .river-waiting {
1546
- display: none;
1547
- padding: 10px 0;
1548
- }
1549
-
1550
- #wp-link .river-waiting .spinner {
1551
- margin: 0 auto;
1552
- display: block;
1553
- }
1554
-
1555
- #wp-link .submitbox {
1556
- padding: 5px 10px;
1557
- font-size: 11px;
1558
- overflow: auto;
1559
- height: 29px;
1560
- }
1561
-
1562
- #wp-link-cancel {
1563
- line-height: 25px;
1564
- float: left;
1565
- }
1566
-
1567
- #wp-link-update {
1568
- line-height: 23px;
1569
- float: right;
1570
- }
1571
-
1572
- /*!
1573
- * jQuery UI CSS Framework 1.10.1
1574
- * http://jqueryui.com
1575
- *
1576
- * Copyright 2013 jQuery Foundation and other contributors
1577
- * Released under the MIT license.
1578
- * http://jquery.org/license
1579
- *
1580
- * http://docs.jquery.com/UI/Theming/API
1581
- */
1582
-
1583
- /* Layout helpers
1584
- ----------------------------------*/
1585
- .ui-helper-hidden {
1586
- display: none;
1587
- }
1588
- .ui-helper-hidden-accessible {
1589
- border: 0;
1590
- clip: rect(0 0 0 0);
1591
- height: 1px;
1592
- margin: -1px;
1593
- overflow: hidden;
1594
- padding: 0;
1595
- position: absolute;
1596
- width: 1px;
1597
- }
1598
- .ui-helper-reset {
1599
- margin: 0;
1600
- padding: 0;
1601
- border: 0;
1602
- outline: 0;
1603
- line-height: 1.3;
1604
- text-decoration: none;
1605
- font-size: 100%;
1606
- list-style: none;
1607
- }
1608
- .ui-helper-clearfix:before,
1609
- .ui-helper-clearfix:after {
1610
- content: "";
1611
- display: table;
1612
- border-collapse: collapse;
1613
- }
1614
- .ui-helper-clearfix:after {
1615
- clear: both;
1616
- }
1617
- .ui-helper-clearfix {
1618
- min-height: 0; /* support: IE7 */
1619
- }
1620
- .ui-helper-zfix {
1621
- width: 100%;
1622
- height: 100%;
1623
- top: 0;
1624
- left: 0;
1625
- position: absolute;
1626
- opacity: 0;
1627
- filter:Alpha(Opacity=0);
1628
- }
1629
-
1630
- .ui-front {
1631
- z-index: 100;
1632
- }
1633
-
1634
-
1635
- /* Interaction Cues
1636
- ----------------------------------*/
1637
- .ui-state-disabled {
1638
- cursor: default !important;
1639
- }
1640
-
1641
-
1642
- /* Icons
1643
- ----------------------------------*/
1644
-
1645
- /* states and images */
1646
- .ui-icon {
1647
- display: block;
1648
- text-indent: -99999px;
1649
- overflow: hidden;
1650
- background-repeat: no-repeat;
1651
- }
1652
-
1653
-
1654
- /* Misc visuals
1655
- ----------------------------------*/
1656
-
1657
- /* Overlays */
1658
- .ui-widget-overlay {
1659
- position: fixed;
1660
- top: 0;
1661
- left: 0;
1662
- width: 100%;
1663
- height: 100%;
1664
- }
1665
-
1666
-
1667
- /*!
1668
- * jQuery UI Resizable 1.10.1
1669
- * http://jqueryui.com
1670
- *
1671
- * Copyright 2013 jQuery Foundation and other contributors
1672
- * Released under the MIT license.
1673
- * http://jquery.org/license
1674
- *
1675
- * http://docs.jquery.com/UI/Resizable#theming
1676
- */
1677
- .ui-resizable {
1678
- position: relative;
1679
- }
1680
- .ui-resizable-handle {
1681
- position: absolute;
1682
- font-size: 0.1px;
1683
- display: block;
1684
- }
1685
- .ui-resizable-disabled .ui-resizable-handle,
1686
- .ui-resizable-autohide .ui-resizable-handle {
1687
- display: none;
1688
- }
1689
- .ui-resizable-n {
1690
- cursor: n-resize;
1691
- height: 7px;
1692
- width: 100%;
1693
- top: -5px;
1694
- left: 0;
1695
- }
1696
- .ui-resizable-s {
1697
- cursor: s-resize;
1698
- height: 7px;
1699
- width: 100%;
1700
- bottom: -5px;
1701
- left: 0;
1702
- }
1703
- .ui-resizable-e {
1704
- cursor: e-resize;
1705
- width: 7px;
1706
- right: -5px;
1707
- top: 0;
1708
- height: 100%;
1709
- }
1710
- .ui-resizable-w {
1711
- cursor: w-resize;
1712
- width: 7px;
1713
- left: -5px;
1714
- top: 0;
1715
- height: 100%;
1716
- }
1717
- .ui-resizable-se {
1718
- cursor: se-resize;
1719
- width: 12px;
1720
- height: 12px;
1721
- right: 1px;
1722
- bottom: 1px;
1723
- }
1724
- .ui-resizable-sw {
1725
- cursor: sw-resize;
1726
- width: 9px;
1727
- height: 9px;
1728
- left: -5px;
1729
- bottom: -5px;
1730
- }
1731
- .ui-resizable-nw {
1732
- cursor: nw-resize;
1733
- width: 9px;
1734
- height: 9px;
1735
- left: -5px;
1736
- top: -5px;
1737
- }
1738
- .ui-resizable-ne {
1739
- cursor: ne-resize;
1740
- width: 9px;
1741
- height: 9px;
1742
- right: -5px;
1743
- top: -5px;
1744
- }
1745
-
1746
- /*!
1747
- * jQuery UI Dialog 1.10.1
1748
- * http://jqueryui.com
1749
- *
1750
- * Copyright 2013 jQuery Foundation and other contributors
1751
- * Released under the MIT license.
1752
- * http://jquery.org/license
1753
- *
1754
- * http://docs.jquery.com/UI/Dialog#theming
1755
- */
1756
- .ui-dialog {
1757
- position: absolute;
1758
- top: 0;
1759
- /* @noflip */
1760
- left: 0;
1761
- padding: .2em;
1762
- outline: 0;
1763
- }
1764
- .ui-dialog .ui-dialog-titlebar {
1765
- padding: .4em 1em;
1766
- position: relative;
1767
- }
1768
- .ui-dialog .ui-dialog-title {
1769
- float: left;
1770
- margin: .1em 0;
1771
- white-space: nowrap;
1772
- width: 90%;
1773
- overflow: hidden;
1774
- text-overflow: ellipsis;
1775
- }
1776
- .ui-dialog .ui-dialog-titlebar-close {
1777
- position: absolute;
1778
- right: .3em;
1779
- top: 50%;
1780
- width: 21px;
1781
- margin: -10px 0 0 0;
1782
- padding: 1px;
1783
- height: 20px;
1784
- }
1785
- .ui-dialog .ui-dialog-content {
1786
- position: relative;
1787
- border: 0;
1788
- padding: .5em 1em;
1789
- background: none;
1790
- overflow: auto;
1791
- }
1792
- .ui-dialog .ui-dialog-buttonpane {
1793
- text-align: left;
1794
- border-width: 1px 0 0 0;
1795
- background-image: none;
1796
- margin-top: .5em;
1797
- padding: .3em 1em .5em .4em;
1798
- }
1799
- .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
1800
- float: right;
1801
- }
1802
- .ui-dialog .ui-dialog-buttonpane button {
1803
- margin: .5em .4em .5em 0;
1804
- cursor: pointer;
1805
- }
1806
- .ui-dialog .ui-resizable-se {
1807
- width: 12px;
1808
- height: 12px;
1809
- right: -5px;
1810
- bottom: -5px;
1811
- background-position: 16px 16px;
1812
- }
1813
- .ui-draggable .ui-dialog-titlebar {
1814
- cursor: move;
1815
- }
1816
-
1817
- /* WP jQuery Dialog Theme */
1818
- .wp-dialog {
1819
- padding: 0;
1820
- z-index: 300002;
1821
- border: 0;
1822
- -webkit-box-shadow: 0 5px 15px rgba(0,0,0,0.7);
1823
- box-shadow: 0 5px 15px rgba(0,0,0,0.7);
1824
- background-color: #f5f5f5;
1825
- }
1826
-
1827
- .wp-dialog .ui-dialog-title {
1828
- display: block;
1829
- text-align: center;
1830
- padding: 0;
1831
- }
1832
-
1833
- .wp-dialog .ui-dialog-titlebar {
1834
- padding: 0 1em;
1835
- background-color: #444;
1836
- font-size: 13px;
1837
- line-height: 24px;
1838
- color: #fff;
1839
- }
1840
-
1841
- .wp-dialog .ui-dialog-content {
1842
- padding: 0;
1843
- }
1844
-
1845
- .wp-dialog .ui-dialog-titlebar-close {
1846
- cursor: pointer;
1847
- -webkit-appearance: none;
1848
- border: 0;
1849
- width: 30px;
1850
- height: 20px;
1851
- top: 13px;
1852
- right: 6px;
1853
- background: none;
1854
- }
1855
-
1856
- .wp-dialog .ui-dialog-titlebar-close:before {
1857
- content: '\f158';
1858
- font: normal 20px/1 'dashicons';
1859
- speak: none;
1860
- -webkit-font-smoothing: antialiased;
1861
- -moz-osx-font-smoothing: grayscale;
1862
- color: #999;
1863
- padding-left: 12px;
1864
- }
1865
-
1866
- .wp-dialog .ui-dialog-titlebar-close:hover:before {
1867
- color: #2ea2cc;
1868
- }
1869
-
1870
- .wp-dialog .ui-dialog-titlebar-close .ui-button-text {
1871
- display: none;
1872
- }
1873
-
1874
- .wp-dialog .ui-dialog-titlebar-close:hover,
1875
- .wp-dialog .ui-dialog-titlebar-close:focus {
1876
- background-position: -87px -32px;
1877
- }
1878
-
1879
- .ui-widget-overlay {
1880
- z-index: 300001;
1881
- background-color: #000;
1882
- opacity: 0.6;
1883
- filter: alpha(opacity=60);
1884
- }
1885
-
1886
- /* TinyMCE modal */
1887
- .clearlooks2 .mceTop {
1888
- border-bottom: 1px solid #ccc;
1889
- }
1890
-
1891
- .clearlooks2 .mceTop span {
1892
- font: 13px/24px "Open Sans", sans-serif;
1893
- color: #e5e5e5;
1894
- }
1895
-
1896
- .clearlooks2 .mceTop .mceLeft {
1897
- background: #444444;
1898
- border-color: transparent;
1899
- }
1900
-
1901
- .clearlooks2 .mceTop .mceRight {
1902
- background: #444444;
1903
- border-color: transparent;
1904
- }
1905
-
1906
- .clearlooks2 .mceMiddle {
1907
- clip: rect(24px auto auto auto);
1908
- }
1909
-
1910
- .clearlooks2 .mceMiddle .mceLeft {
1911
- background: #f1f1f1;
1912
- border-color: transparent;
1913
- }
1914
-
1915
- .clearlooks2 .mceMiddle .mceRight {
1916
- background: #f1f1f1;
1917
- border-color: transparent;
1918
- }
1919
-
1920
- .clearlooks2 .mceBottom {
1921
- background: #f1f1f1;
1922
- border-color: transparent;
1923
- }
1924
-
1925
- .clearlooks2 .mceBottom .mceLeft {
1926
- background: #f1f1f1;
1927
- border-color: transparent;
1928
- }
1929
-
1930
- .clearlooks2 .mceBottom .mceCenter {
1931
- background: #f1f1f1;
1932
- border-color: transparent;
1933
- }
1934
-
1935
- .clearlooks2 .mceBottom .mceRight {
1936
- background: #f1f1f1;
1937
- border-color: transparent;
1938
- }
1939
-
1940
- .clearlooks2 .mceClose,
1941
- .clearlooks2 .mceFocus .mceClose,
1942
- .clearlooks2 .mceFocus .mceClose:hover {
1943
- background-image: none;
1944
- }
1945
- .clearlooks2 .mceClose:before {
1946
- speak: none;
1947
- -webkit-font-smoothing: antialiased;
1948
- -moz-osx-font-smoothing: grayscale;
1949
- color: #999;
1950
- padding-left: 12px;
1951
- }
1952
-
1953
- /* Distraction Free Writing mode
1954
- * =Overlay Styles
1955
- -------------------------------------------------------------- */
1956
- .fullscreen-overlay {
1957
- z-index: 149999;
1958
- display: none;
1959
- position: fixed;
1960
- top: 0;
1961
- bottom: 0;
1962
- left: 0;
1963
- right: 0;
1964
- filter: inherit;
1965
- }
1966
-
1967
- .fullscreen-active .fullscreen-overlay,
1968
- .fullscreen-active #wp-fullscreen-body {
1969
- display: block;
1970
- }
1971
-
1972
- .fullscreen-fader {
1973
- z-index: 200000;
1974
- }
1975
-
1976
- .fullscreen-active .fullscreen-fader {
1977
- display: none;
1978
- }
1979
-
1980
- /* =Overlay Body
1981
- -------------------------------------------------------------- */
1982
- #wp-fullscreen-body {
1983
- width: 100%;
1984
- z-index: 150005;
1985
- display: none;
1986
- position: absolute;
1987
- top: 0;
1988
- left: 0;
1989
- font-size: 12px;
1990
- }
1991
-
1992
- #wp-fullscreen-wrap {
1993
- margin: 0 auto 50px;
1994
- position: relative;
1995
- padding-top: 60px;
1996
- }
1997
-
1998
- #wp-fullscreen-title {
1999
- font-size: 1.7em;
2000
- line-height: 100%;
2001
- outline: medium none;
2002
- padding: 6px 7px;
2003
- width: 100%;
2004
- margin-bottom: 30px;
2005
- -webkit-box-shadow: none;
2006
- box-shadow: none;
2007
- }
2008
-
2009
- #wp-fullscreen-container {
2010
- padding: 4px 10px 50px;
2011
- }
2012
-
2013
- #wp-fullscreen-title,
2014
- #wp-fullscreen-container {
2015
- -webkit-border-radius: 0;
2016
- border-radius: 0;
2017
- border: 1px dashed transparent;
2018
- background: transparent;
2019
- -moz-transition-property: border-color;
2020
- -moz-transition-duration: 0.6s;
2021
- -webkit-transition-property: border-color;
2022
- -webkit-transition-duration: 0.6s;
2023
- -o-transition-property: border-color;
2024
- -o-transition-duration: 0.6s;
2025
- transition-property: border-color;
2026
- transition-duration: 0.6s;
2027
- }
2028
-
2029
- #wp_mce_fullscreen {
2030
- width: 100%;
2031
- min-height: 300px;
2032
- border: 0;
2033
- background: transparent;
2034
- font-family: Consolas, Monaco, monospace;
2035
- line-height: 1.6em;
2036
- padding: 0;
2037
- overflow-y: hidden;
2038
- outline: none;
2039
- resize: none;
2040
- -webkit-box-shadow: none;
2041
- box-shadow: none;
2042
- }
2043
-
2044
- #wp-fullscreen-tagline {
2045
- color: #BBBBBB;
2046
- font-size: 18px;
2047
- float: right;
2048
- padding-top: 5px;
2049
- }
2050
-
2051
- /* =Top bar
2052
- -------------------------------------------------------------- */
2053
- #fullscreen-topbar {
2054
- background: #f5f5f5;
2055
- border-bottom: 1px solid #fff;
2056
- height: 40px;
2057
- left: 0;
2058
- min-width: 800px;
2059
- position: fixed;
2060
- top: 0;
2061
- width: 100%;
2062
- z-index: 150050;
2063
- }
2064
-
2065
- #wp-fullscreen-toolbar {
2066
- padding: 6px 10px 0;
2067
- clear: both;
2068
- max-width: 1100px;
2069
- min-width: 820px;
2070
- margin: 0 auto;
2071
- }
2072
-
2073
- #wp-fullscreen-mode-bar,
2074
- #wp-fullscreen-button-bar,
2075
- #wp-fullscreen-close,
2076
- #wp-fullscreen-count {
2077
- float: left;
2078
- }
2079
-
2080
- #wp-fullscreen-save {
2081
- float: right;
2082
- padding: 2px 2px 0 5px;
2083
- }
2084
-
2085
- #wp-fullscreen-count,
2086
- #wp-fullscreen-close {
2087
- padding-top: 5px;
2088
- }
2089
-
2090
- #wp-fullscreen-central-toolbar {
2091
- margin: auto;
2092
- padding: 0;
2093
- }
2094
-
2095
- #wp-fullscreen-buttons > div {
2096
- float: left;
2097
- }
2098
-
2099
- #wp-fullscreen-mode-bar {
2100
- padding: 1px 14px 0 0;
2101
- }
2102
-
2103
- #wp-fullscreen-modes a {
2104
- display: block;
2105
- font-size: 11px;
2106
- text-decoration: none;
2107
- float: left;
2108
- margin: 1px 0 0 0;
2109
- padding: 2px 6px 2px;
2110
- border-width: 1px 1px 1px 0;
2111
- border-style: solid;
2112
- border-color: #bbb;
2113
- color: #777;
2114
- text-shadow: 0 1px 0 #fff;
2115
- background-color: #f4f4f4;
2116
- background: #f4f4f4;
2117
- background-image: -webkit-gradient(linear, left bottom, left top, from(#e4e4e4), to(#f9f9f9));
2118
- background-image: -webkit-linear-gradient(bottom, #e4e4e4, #f9f9f9);
2119
- background-image: -moz-linear-gradient(bottom, #e4e4e4, #f9f9f9);
2120
- background-image: -o-linear-gradient(bottom, #e4e4e4, #f9f9f9);
2121
- background-image: linear-gradient(to top, #e4e4e4, #f9f9f9);
2122
- }
2123
-
2124
- #wp-fullscreen-modes a:hover,
2125
- .wp-html-mode #wp-fullscreen-modes a:last-child,
2126
- .wp-tmce-mode #wp-fullscreen-modes a:first-child {
2127
- color: #333;
2128
- border-color: #999;
2129
- background: #eee;
2130
- background-image: -webkit-gradient(linear, left top, left bottom, from(#e4e4e4), to(#f9f9f9));
2131
- background-image: -webkit-linear-gradient(top, #e4e4e4, #f9f9f9);
2132
- background-image: -moz-linear-gradient(top, #e4e4e4, #f9f9f9);
2133
- background-image: -o-linear-gradient(top, #e4e4e4, #f9f9f9);
2134
- background-image: linear-gradient(to bottom, #e4e4e4, #f9f9f9);
2135
- }
2136
-
2137
- #wp-fullscreen-modes a:first-child {
2138
- border-width: 1px;
2139
- -webkit-border-top-left-radius: 3px;
2140
- -webkit-border-bottom-left-radius: 3px;
2141
- border-top-left-radius: 3px;
2142
- border-bottom-left-radius: 3px;
2143
- }
2144
-
2145
- #wp-fullscreen-modes a:last-child {
2146
- -webkit-border-top-right-radius: 3px;
2147
- -webkit-border-bottom-right-radius: 3px;
2148
- border-top-right-radius: 3px;
2149
- border-bottom-right-radius: 3px;
2150
- }
2151
-
2152
- #wp-fullscreen-buttons .active a {
2153
- background: inherit;
2154
- }
2155
-
2156
- #wp-fullscreen-buttons .hidden {
2157
- display: none;
2158
- }
2159
-
2160
- #wp-fullscreen-buttons .disabled {
2161
- opacity: 0.5;
2162
- }
2163
-
2164
- .wp-html-mode #wp-fullscreen-buttons div {
2165
- display: none;
2166
- }
2167
-
2168
- .wp-html-mode #wp-fullscreen-buttons div.wp-fullscreen-both {
2169
- display: block;
2170
- }
2171
-
2172
- #fullscreen-topbar.fullscreen-make-sticky {
2173
- display: block !important;
2174
- }
2175
-
2176
- #wp-fullscreen-save img {
2177
- vertical-align: middle;
2178
- }
2179
-
2180
- #wp-fullscreen-save img,
2181
- #wp-fullscreen-save span {
2182
- padding-right: 4px;
2183
- display: none;
2184
- }
2185
-
2186
- /* =Thickbox Adjustments
2187
- -------------------------------------------------------------- */
2188
- .fullscreen-active #TB_overlay {
2189
- z-index: 150100;
2190
- }
2191
-
2192
- .fullscreen-active #TB_window {
2193
- z-index: 150102;
2194
- }
2195
-
2196
- /* =TinyMCE Adjustments
2197
- -------------------------------------------------------------- */
2198
- #wp_mce_fullscreen_ifr {
2199
- background: transparent;
2200
- }
2201
-
2202
- #wp_mce_fullscreen_parent #wp_mce_fullscreen_tbl tr.mceFirst {
2203
- display : none;
2204
- }
2205
-
2206
- #wp-fullscreen-container .wp_themeSkin table td {
2207
- vertical-align: top;
2208
- }
2209
-
2210
- /* Colors */
2211
- .fullscreen-overlay {
2212
- background: #fff;
2213
- }
2214
-
2215
- .wp-fullscreen-focus #wp-fullscreen-title,
2216
- .wp-fullscreen-focus #wp-fullscreen-container {
2217
- border-color: #ccc;
2218
- }
2219
-
2220
- /* =CSS 3 transitions
2221
- -------------------------------------------------------------- */
2222
-
2223
- .fade-1000,
2224
- .fade-600,
2225
- .fade-400,
2226
- .fade-300 {
2227
- opacity: 0;
2228
- -moz-transition-property: opacity;
2229
- -webkit-transition-property: opacity;
2230
- -o-transition-property: opacity;
2231
- transition-property: opacity;
2232
- }
2233
-
2234
- .fade-1000 {
2235
- -moz-transition-duration: 1s;
2236
- -webkit-transition-duration: 1s;
2237
- -o-transition-duration: 1s;
2238
- transition-duration: 1s;
2239
- }
2240
-
2241
- .fade-600 {
2242
- -moz-transition-duration: 0.6s;
2243
- -webkit-transition-duration: 0.6s;
2244
- -o-transition-duration: 0.6s;
2245
- transition-duration: 0.6s;
2246
- }
2247
-
2248
- .fade-400 {
2249
- -moz-transition-duration: 0.4s;
2250
- -webkit-transition-duration: 0.4s;
2251
- -o-transition-duration: 0.4s;
2252
- transition-duration: 0.4s;
2253
- }
2254
-
2255
- .fade-300 {
2256
- -moz-transition-duration: 0.3s;
2257
- -webkit-transition-duration: 0.3s;
2258
- -o-transition-duration: 0.3s;
2259
- transition-duration: 0.3s;
2260
- }
2261
-
2262
- .fade-trigger {
2263
- opacity: 1;
2264
- }
2265
-
2266
- /* =Localization
2267
- -------------------------------------------------------------- */
2268
- .rtl .wp_themeSkin .mceColorSplitMenu a.mceMoreColors,
2269
- .rtl .wp_themeSkin .mceMenu .mceText,
2270
- .rtl .wp-switch-editor,
2271
- .rtl .quicktags-toolbar input,
2272
- .rtl .clearlooks2 .mceTop span,
2273
- .rtl .wp_themeSkin .mceColorSplitMenu a.mceMoreColors {
2274
- font-family: Tahoma, sans-serif;
2275
- }
2276
-
2277
- html:lang(he-il) .rtl .wp_themeSkin .mceColorSplitMenu a.mceMoreColors,
2278
- html:lang(he-il) .rtl .wp_themeSkin .mceMenu .mceText,
2279
- html:lang(he-il) .rtl .wp-switch-editor,
2280
- html:lang(he-il) .rtl .quicktags-toolbar input,
2281
- html:lang(he-il) .rtl .clearlooks2 .mceTop span,
2282
- html:lang(he-il) .rtl .wp_themeSkin .mceColorSplitMenu a.mceMoreColors {
2283
- font-family: Arial, sans-serif;
2284
- }
2285
-
2286
-
2287
- /* HiDPI */
2288
- @media print,
2289
- (-o-min-device-pixel-ratio: 5/4),
2290
- (-webkit-min-device-pixel-ratio: 1.25),
2291
- (min-resolution: 120dpi) {
2292
- .wp-media-buttons .add_media span.wp-media-buttons-icon,
2293
- #wp-fullscreen-buttons #wp_fs_image span.mce_image {
2294
- background: none;
2295
- }
2296
-
2297
- .wp_themeSkin .mceListBox .mceOpen,
2298
- .wp_themeSkin .mceListBoxHover .mceOpen,
2299
- .wp_themeSkin .mceListBoxSelected .mceOpen,
2300
- .wp_themeSkin table.mceListBoxEnabled .mceOpen {
2301
- background-image: url('../../../../../wp-includes/images/down_arrow-2x.gif');
2302
- background-size: 10px 20px;
2303
- }
2304
-
2305
- .wp_themeSkin .mceSplitButtonEnabled a.mceOpen,
2306
- .wp_themeSkin .mceSplitButtonSelected a.mceOpen,
2307
- .wp_themeSkin .mceSplitButtonActive a.mceOpen,
2308
- .wp_themeSkin .mceSplitButtonEnabled:hover a.mceOpen {
2309
- background-image: url('../../../../../wp-includes/images/down_arrow-2x.gif');
2310
- background-size: 10px 20px;
2311
- }
2312
-
2313
- #wp-link .toggle-arrow {
2314
- background: transparent url('../../../../../wp-includes/images/toggle-arrow-2x.png') top left no-repeat;
2315
- background-size: 19px 69px;
2316
- }
2317
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
css/vendor/bootstrap.tooltip.css DELETED
@@ -1,101 +0,0 @@
1
- .tooltip {
2
- position: absolute;
3
- z-index: 1030;
4
- display: block;
5
- visibility: visible;
6
- font-size: 12px;
7
- line-height: 1.4;
8
- opacity: 0;
9
- filter: alpha(opacity=0);
10
- }
11
- .tooltip.in {
12
- opacity: 0.9;
13
- filter: alpha(opacity=90);
14
- }
15
- .tooltip.top {
16
- margin-top: -3px;
17
- padding: 5px 0;
18
- }
19
- .tooltip.right {
20
- margin-left: 3px;
21
- padding: 0 5px;
22
- }
23
- .tooltip.bottom {
24
- margin-top: 3px;
25
- padding: 5px 0;
26
- }
27
- .tooltip.left {
28
- margin-left: -3px;
29
- padding: 0 5px;
30
- }
31
- .tooltip-inner {
32
- max-width: 200px;
33
- padding: 3px 8px;
34
- color: #ffffff;
35
- text-align: center;
36
- text-decoration: none;
37
- background-color: #000000;
38
- border-radius: 4px;
39
- }
40
- .tooltip-inner a {
41
- color: #fff;
42
- }
43
- .tooltip-arrow {
44
- position: absolute;
45
- width: 0;
46
- height: 0;
47
- border-color: transparent;
48
- border-style: solid;
49
- }
50
- .tooltip.top .tooltip-arrow {
51
- bottom: 0;
52
- left: 50%;
53
- margin-left: -5px;
54
- border-width: 5px 5px 0;
55
- border-top-color: #000000;
56
- }
57
- .tooltip.top-left .tooltip-arrow {
58
- bottom: 0;
59
- left: 5px;
60
- border-width: 5px 5px 0;
61
- border-top-color: #000000;
62
- }
63
- .tooltip.top-right .tooltip-arrow {
64
- bottom: 0;
65
- right: 5px;
66
- border-width: 5px 5px 0;
67
- border-top-color: #000000;
68
- }
69
- .tooltip.right .tooltip-arrow {
70
- top: 50%;
71
- left: 0;
72
- margin-top: -5px;
73
- border-width: 5px 5px 5px 0;
74
- border-right-color: #000000;
75
- }
76
- .tooltip.left .tooltip-arrow {
77
- top: 50%;
78
- right: 0;
79
- margin-top: -5px;
80
- border-width: 5px 0 5px 5px;
81
- border-left-color: #000000;
82
- }
83
- .tooltip.bottom .tooltip-arrow {
84
- top: 0;
85
- left: 50%;
86
- margin-left: -5px;
87
- border-width: 0 5px 5px;
88
- border-bottom-color: #000000;
89
- }
90
- .tooltip.bottom-left .tooltip-arrow {
91
- top: 0;
92
- left: 5px;
93
- border-width: 0 5px 5px;
94
- border-bottom-color: #000000;
95
- }
96
- .tooltip.bottom-right .tooltip-arrow {
97
- top: 0;
98
- right: 5px;
99
- border-width: 0 5px 5px;
100
- border-bottom-color: #000000;
101
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
css/wysija-editor.css CHANGED
@@ -1 +1 @@
1
- .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}.hidden{display:none}strong{font-weight:bold}img{vertical-align:middle}:focus{outline:0 !important}.inline{display:-moz-inline-box;display:inline-block;*display:inline;*float:left}.wysija_tools li,.wysija_tools dd{margin:0 !important}.wysija_controls li{margin:0 0 0 3px !important}#wysija_items{position:fixed;width:275px;right:20px;top:20px;z-index:999}#wysija_items li{line-height:100px;height:100px;outline:1px solid #ccc;text-align:center}.wysija_items li.disabled{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";filter:alpha(opacity=20);-moz-opacity:0.2;opacity:0.2}.wysija_items li.active a{height:100px;cursor:pointer;display:block}.wysija_header,.wysija_footer{position:relative;display:inline-table;display:block;height:1%;margin:0;padding:0;z-index:98}.wysija_header:after,.wysija_footer:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_block{position:relative;margin:0 10px;padding:10px 18px 10px 18px;display:inline-table;display:block;height:1%;margin:0;z-index:98}.wysija_block.dragging,.wysija_header.dragging,.wysija_footer.dragging{z-index:99000}.wysija_block:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_block.hover{border:1px dashed #bbb;margin:0 0 0 0;padding:9px 17px 9px 17px}.wysija_block.static{padding:0;margin:0}.wysija_block .wysija_controls{background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;border:1px solid #ccc;position:absolute;margin:0;padding:0;width:598px;height:20px;left:-1px;right:0;top:-22px;width:100%}.wysija_block .wysija_controls .handle{width:600px}.wysija_block .wysija_controls li{float:left;width:20px;height:20px}.wysija_block .wysija_controls a{cursor:pointer;float:left;font-size:120%;font-weight:bold;height:20px;line-height:20px;text-align:center;width:20px;color:#000}.wysija_block .handle_container,.wysija_block .handle_container a{float:none;width:40px}.wysija_block .handle_container{left:280px;top:0;position:absolute}.wysija_gallery .wysija_tools,.wysija_image .wysija_tools{position:absolute;height:34px;line-height:34px;margin:0;width:152px;top:-36px;z-index:1010;background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;border:1px solid #ccc;padding:0 0 0 5px}.wysija_gallery .wysija_tools{width:102px}.left .wysija_image .wysija_tools,.center .wysija_image .wysija_tools,.left.wysija_gallery .wysija_tools,.center.wysija_gallery .wysija_tools{left:0;text-align:left}.right .wysija_image .wysija_tools,.right.wysija_gallery .wysija_tools{right:0;text-align:right}.wysija_text .wysija_tools{position:absolute;height:20px;line-height:20px;top:0;right:0;margin:0;z-index:1000;width:20px}.wysija_text.alone .wysija_tools{display:none}.wysija_gallery .wysija_tools li,.wysija_image .wysija_tools li{float:left;width:25px;height:34px}.wysija_text .wysija_tools li{float:left;width:20px;height:20px}.wysija_gallery .wysija_tools a,.wysija_image .wysija_tools a,.wysija_text .wysija_tools a{background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));float:left;width:20px;height:20px;margin:5px 3px 0 0;-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.15),inset 0 0 2px 1px #fff;-moz-box-shadow:0 1px 0 rgba(0,0,0,0.15),inset 0 0 2px 1px #fff;box-shadow:0 1px 0 rgba(0,0,0,0.15),inset 0 0 2px 1px #fff;border:1px solid #ccc;z-index:1010;position:relative}.wysija_text .wysija_tools a{margin:0}.wysija_gallery .wysija_tools a:hover,.wysija_image .wysija_tools a:hover,.wysija_text .wysija_tools a:hover{background-color:#ddd;border-color:#909090}.wysija_gallery .wysija_tools a.active,.wysija_image .wysija_tools a.active,.wysija_text .wysija_tools a.active{background-color:#ddd;background-image:-moz-linear-gradient(center bottom, #eee, #bbb);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#eee), to(#bbb));border-color:#909090}.wysija_controls a span,.wysija_gallery .wysija_tools a span,.wysija_image .wysija_tools a span,.wysija_text .wysija_tools a span,.wj_content a span{display:block;height:20px;width:20px}.wysija_controls span input{margin:2px 0 0 0;padding:0;color:transparent}.alignment-left span{background:url(../img/controls/icons.png) no-repeat 0 0}.alignment-left.active span,.alignment-left:hover span{background:url(../img/controls/icons.png) no-repeat 0 -20px}.alignment-center span{background:url(../img/controls/icons.png) no-repeat -20px 0}.alignment-center.active span,.alignment-center:hover span{background:url(../img/controls/icons.png) no-repeat -20px -20px}.alignment-right span{background:url(../img/controls/icons.png) no-repeat -40px 0}.alignment-right.active span,.alignment-right:hover span{background:url(../img/controls/icons.png) no-repeat -40px -20px}.add-link span{background:url(../img/controls/icons.png) no-repeat -60px 0}.add-link.active span,.add-link:hover span{background:url(../img/controls/icons.png) no-repeat -60px -20px}.remove-link span{background:url(../img/controls/icons.png) no-repeat -80px 0}.remove-link.active span,.remove-link:hover span{background:url(../img/controls/icons.png) no-repeat -80px -20px}.remove span{background:url(../img/controls/icons.png) no-repeat -100px 0}.remove.active span,.remove:hover span{background:url(../img/controls/icons.png) no-repeat -100px -20px}.handle span{background:url(../img/controls/grip-handle.png) no-repeat;cursor:move;width:40px !important}.duplicate span{background:url(../img/controls/icons.png) no-repeat -140px 0}.duplicate.active span,.duplicate:hover span{background:url(../img/controls/icons.png) no-repeat -140px -20px}.settings span{background:url(../img/controls/icons.png) no-repeat -160px 0}.settings.active span,.settings:hover span{background:url(../img/controls/icons.png) no-repeat -160px -20px}.icon-plus span{background:url(../img/controls/icons.png) no-repeat -200px 0}.icon-plus.active span,.icon-plus:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.icon-minus span{background:url(../img/controls/icons.png) no-repeat -220px 0}.icon-minus.active span,.icon-minus:hover span{background:url(../img/controls/icons.png) no-repeat -220px -20px}.banner{color:#000;z-index:999;text-align:center;width:600px;position:absolute;top:0;right:0;left:0;bottom:0;white-space:nowrap;font-size:16px !important;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.banner .banner-message{margin:20px auto 0 auto}.banner .banner-icon{background:url(../img/controls/image-placeholder.png) no-repeat;padding:2px 0 0 28px}.banner .banner-notice{margin:10px auto 0 auto;font-size:12px;font-style:italic}#wysija_wrapper{padding:20px;width:600px;border:1px solid #ccc;position:relative;background-color:#fff;-webkit-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);-moz-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);box-shadow:0 0 5px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1)}#wysija_wrapper:before,#wysija_wrapper:after{position:absolute;width:40%;height:10px;content:' ';left:12px;bottom:12px;background:transparent;-webkit-transform:skew(-5deg) rotate(-5deg);-moz-transform:skew(-5deg) rotate(-5deg);-ms-transform:skew(-5deg) rotate(-5deg);-o-transform:skew(-5deg) rotate(-5deg);transform:skew(-5deg) rotate(-5deg);-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.3);-moz-box-shadow:0 6px 12px rgba(0,0,0,0.3);box-shadow:0 6px 12px rgba(0,0,0,0.3);z-index:-1}#wysija_wrapper:after{left:auto;right:12px;-webkit-transform:skew(5deg) rotate(5deg);-moz-transform:skew(5deg) rotate(5deg);-ms-transform:skew(5deg) rotate(5deg);-o-transform:skew(5deg) rotate(5deg);transform:skew(5deg) rotate(5deg)}body.rtl #wysija_wrapper{right:603px !important}#wysija_container{margin:30px 0 0 0;width:600px;border-collapse:collapse;width:600px;margin:0;padding:0}#wysija_header{padding:0}#wysija_body{vertical-align:top;padding:0}#wysija_footer{padding:0}#wysija_block_placeholder{height:0;padding:0;margin:0}.block_placeholder,.text_placeholder{font-weight:bold;height:0;overflow:hidden;line-height:30px;text-align:center;border:0 none;width:598px;z-index:9500;margin:0 auto;text-indent:-9999px}.wysija_block .block_placeholder,.wysija_block .text_placeholder,.wysija_block .image_placeholder{margin:0}.image_placeholder{margin:1px 0 0 1px}.hover .image_placeholder{margin:0}.wysija_content .empty.editable{font-size:13px;line-height:30px}.wysija_image.empty{height:0;width:0;margin:0 !important;z-index:-1;overflow:hidden}.wysija_image.empty.active{height:auto}.wysija_image.active{background:url(../img/controls/image-placeholder.png) no-repeat center center #f5f5f5;border:1px dashed #dfdfdf}#wysija_header .wysija_image.empty,#wysija_footer .wysija_image.empty{background-image:none;height:auto}#wysija_header .wysija_image.active,#wysija_footer .wysija_image.active{border:0 none}.block_placeholder.active,.text_placeholder.active{text-indent:0;border:1px dashed #dfdfdf;background-color:#f5f5f5;display:block;overflow:auto;height:30px}.image_placeholder.empty.active{display:block}.block_placeholder.hover,.text_placeholder.hover,.image_hover .wysija_image{background-color:#0074a2;border-color:#0074a2;color:#fff !important}.image_placeholder.active{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=25)";filter:alpha(opacity=25);-moz-opacity:0.25;opacity:0.25;z-index:9501}.wysija_image.empty.active,.wysija_text.empty.active{display:block;margin:0}#wysija_header .wysija_image.active,#wysija_footer .wysija_image.active{left:0;top:0;right:0}.wysija_header .image_placeholder,.wysija_footer .image_placeholder{border:0 none !important;margin:0 !important}.wysija_header .image_placeholder.active,.wysija_footer .image_placeholder.active{border:0 none !important}.wysija_options{display:none}.wysija_content .wysija_image{margin:0 auto 15px auto;cursor:move}.wysija_header .wysija_content.left .wysija_image,.wysija_header .wysija_content.right .wysija_image,.wysija_footer .wysija_content.left .wysija_image,.wysija_footer .wysija_content.right .wysija_image{margin:0 0 0 0 !important}.wysija_content.center .image_placeholder.active{margin:0 0 -2px 0}.wysija_header .wysija_content.center .wysija_image,.wysija_footer .wysija_content.center .wysija_image{margin:0 auto !important}.wysija_header .wysija_content.center .image_placeholder.active,.wysija_footer .wysija_content.center .image_placeholder.active{margin:0}.wysija_block .wysija_content.center .wysija_image.empty.active{margin-bottom:5px !important}.wysija_content.left{float:none}.wysija_gallery.left{float:left}.wysija_content.left .wysija_image{float:left;margin:0 15px 5px 0}.wysija_content.left .wysija_image.active{margin:0 13px 3px 0}.wysija_content.left .wysija_image.empty.active{margin:0 15px 5px 0 !important}.wysija_gallery.right{float:right}.wysija_content.right .wysija_image{float:right;margin:0 0 5px 15px}.wysija_content.right .wysija_image.active{margin:0 0 3px 13px}.wysija_content.right .wysija_image.empty.active{margin:0 0 5px 15px !important}.wysija_content .wysija_image.alone{margin:0 !important}.wysija_content.center .wysija_image.alone{margin:0 auto !important}.wysija_image{position:relative;z-index:999}.wysija_image .url-info{position:absolute;bottom:0;left:0;font-size:0.7em;padding:2px;color:#000;background-color:#fff;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";filter:alpha(opacity=80);-moz-opacity:0.8;opacity:0.8}.wysija_content.left .wysija_image .url-info{right:0;left:auto}.wysija_text{position:relative;z-index:998}.wysija_text.editing{border:1px solid #dfdfdf}.wysija_content.left .wysija_text.editing{float:left}.wysija_text .editable:hover{cursor:pointer}#wysija_toolbar{left:657px;position:absolute;top:-1000px;width:295px}#wysija_toolbar .wysija_toolbar_tabs{border-bottom:1px solid #dfdfdf;line-height:0}#wysija_toolbar .wysija_toolbar_tabs li,#wysija_toolbar .wysija_toolbar_tabs a{margin:0;height:30px;line-height:30px;padding:0;display:-moz-inline-box;display:inline-block;*display:inline;*float:left;outline:0 none}#wysija_toolbar .wysija_toolbar_tabs a{outline:0 none;text-decoration:none;color:#a6a6a6}#wysija_toolbar .wysija_toolbar_tabs li{margin:0 0 1px 0}#wysija_toolbar .wysija_toolbar_tabs a{font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #f5f5f5);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#F5F5F5', endColorstr='#F9F9F9');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#f5f5f5));border:1px solid #DFDFDF;-moz-border-radius:3px 3px 0 0;-webkit-border-radius:3px 3px 0 0;-khtml-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;box-shadow:0 1px 0 #FFFFFF inset;padding:0 7px}#wysija_toolbar .wysija_toolbar_tabs a:hover{background-color:#eee}#wysija_toolbar .wysija_toolbar_tabs a.selected{color:#000;border-bottom:0 none;background:#fcfcfc;filter:none;padding-bottom:1px}#wysija_toolbar .wysija_toolbar_tabs,#wysija_toolbar .wj_content,#wysija_toolbar .wj_images,#wysija_toolbar .wj_styles,#wysija_toolbar .wj_themes{position:relative;z-index:9998;margin:0}#wysija_toolbar #wysija_notices span{font-size:12px !important;font-weight:normal !important}.wj_content{background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:0 0 10px 0}.wj_content li{padding:10px 10px 0 10px;position:relative}.wj_content li.notice{font-style:italic;font-size:11px;margin:0 !important;border:0 none !important;background:none !important}.wj_images{z-index:999;background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:9px}.wj_images ul{height:360px;overflow:auto;margin:0;padding:0}.wj_images li{float:left;width:80px;margin:2px;height:80px;overflow:hidden;position:relative;border:1px solid #dfdfdf}.wj_images li img{max-height:150px;width:80px}.wj_images li a{float:left;display:block;height:80px;width:80px}.wj_button{text-align:center;width:265px;margin:20px 0;height:30px;line-height:30px}.wj_images img{cursor:move;max-width:275px}#wysija-upload-browse,#wysija-themes-browse{float:none}.wj_images #wj_images_preview{border:3px solid #dfdfdf;position:absolute;right:295px;top:0;background-color:#fff}.wj_styles{z-index:999;background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:9px}.wj_styles p{margin:10px 0}.wj_styles .preview{width:20px;float:none !important;height:20px;vertical-align:middle;display:-moz-inline-box;display:inline-block;*display:inline;*float:left;border:1px solid #333}.wj_styles input,.wj_styles select{height:20px;border:0 none;border:1px solid #CCC;margin:0 3px 0 0 !important;padding:0 !important;vertical-align:middle;line-height:20px;font-size:12px}.wj_styles #aUnderlineInput{margin:0 0 0 10px !important}.wj_styles select{width:75px}.wj_styles input.checkbox,.wj_styles input[type=checkbox]{border:0 none !important}.wj_styles input.color{width:55px;padding:0 0 0 2px !important}.wj_styles input.color.disabled{background-color:#eee !important;color:#eee !important}.wj_styles select.small-size{width:50px}.wj_styles select.type{width:68px}.wj_styles select.size{width:58px}.wj_styles form label{cursor:normal;margin:0 0 0 3px}.wj_themes{z-index:999;background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:9px}.wj_themes ul{height:360px;overflow:auto;margin:0;padding:0}.wj_themes li{float:left;width:80px;margin:2px;height:80px;overflow:hidden;border:1px solid #dfdfdf;position:relative}.wj_themes li img{max-height:150px;width:80px}.wj_themes li a{display:block}.wj_themes #wj_themes_preview{border:3px solid #dfdfdf;position:absolute;right:295px;top:0;background-color:#fff}.wysija_widget{width:275px;height:25px;line-height:25px;z-index:9999 !important}.wj_content a.wysija_item,.wysija_widget{height:25px;line-height:25px;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;display:block;font-size:12px;font-weight:bold;padding:0 0 0 7px;cursor:move;color:#222;text-shadow:0 1px 0 #FFFFFF}.wj_content a.wysija_item.disabled{cursor:help;color:#cccccc}.wysija_item_settings{position:absolute;right:15px;top:13px}.wysija_widget.image{z-index:9999 !important;height:auto !important;width:150px !important;background:none !important;border:0 none !important;box-shadow:none !important;border-radius:0 !important;padding:0 !important}#wysija_notices{z-index:20000;position:relative;left:0;top:0;padding:5px;border:1px solid #dfdfdf;border-top:0 none}#wysija_notices.notice{background-color:#FFFFE0;border-color:#E6DB55;z-index:9999}#wysija_notices.error{background-color:#FFEBE8;border-color:#CC0000}#wysija_notice_msg{font-size:14px;font-weight:bold}.align-center{text-align:center}.align-left{text-align:left}.align-right{text-align:right}.align-justify{text-align:justify}.wysija_gallery{position:relative}.wysija_gallery.center{margin:0 auto}.wysija_gallery.right{text-align:right}.wysija_gallery.left{text-align:left}.wysija_row{width:100%}.wysija_cell{float:left;text-align:center}.resize-controls{position:absolute;left:0;right:0;top:0;bottom:0;z-index:99000;border:1px dashed #ccc}.resize-handle{position:absolute;bottom:0;right:0;width:20px;height:20px;border:0 none;z-index:1001;cursor:se-resize;background:transparent url(../img/controls/resize-se.png) no-repeat scroll right bottom}.resize-info{position:absolute;bottom:0;left:4px;font-size:0.8em;padding:0;margin:0;text-shadow:0 1px 0 #F7F5F2;white-space:nowrap}.right .resize-handle{position:absolute;bottom:0;left:0;width:20px;height:20px;border:0 none;z-index:1001;cursor:sw-resize;background:transparent url(../img/controls/resize-sw.png) no-repeat scroll left bottom}.right .resize-info{left:auto !important;right:4px}#adminmenu li .wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{z-index:1001 !important}.wysija_divider{margin:0 auto;width:564px}.wysija_block.auto-post.hover .wysija_content *,.wysija_block.auto-post.hover .wysija_divider{z-index:1000;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";filter:alpha(opacity=30);-moz-opacity:0.3;opacity:0.3}.wysija_auto-post .wysija_divider{text-align:center;margin:0 !important;width:100% !important}.wysija_auto-post .nopost{height:100px}.wysija_auto-post .nopost p{margin:25px 0 0 0}.wysija_settings{left:10px;position:absolute;top:0;z-index:1000}.wysija_settings a{background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;font-size:12px;font-weight:normal;cursor:pointer;color:#222;text-shadow:0 1px 0 #FFFFFF;text-decoration:none;display:block;padding:5px 5px 3px 27px}.wysija_settings a span{width:20px;height:20px;position:absolute;top:3px;left:5px}#wysija_toggle_images{position:absolute;top:5px;right:5px;z-index:1000;width:73px;height:33px;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;background-color:#fff}#wysija_toggle_images.on{background:url(../img/controls/images-toggle-on.png) no-repeat}#wysija_toggle_images.off{background:url(../img/controls/images-toggle-off.png) no-repeat}#wysija_toggle_images:hover{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);-moz-opacity:1.0;opacity:1.0}.wysija_block.auto-post{padding:0 !important}.wysija_auto-post .wysija_content{padding:10px 17px !important}.wysija_auto-post .wysija_content:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_auto-post .wysija_content{display:inline-table}* html .wysija_auto-post .wysija_content{height:1%}.wysija_auto-post .wysija_content{display:block}.wysija_auto-post .wysija_divider{padding:9px 0 !important}.wysija_block.auto-post.hover .wysija_content{padding:10px 17px !important}.wysija_auto-post .wysija_text{pointer-events:none;cursor:default}.wysija_auto-post .wysija_image{pointer-events:none;cursor:default}.auto-post.hover .wysija_content:last-child{padding:9px 17px 9px 17px !important}.wysija_auto-post .loading{padding:10px 17px;font-size:10px}#wysija_popup_overlay{background-color:#000;height:100%;left:0;position:fixed;top:0;width:100%;z-index:999989;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=75)";filter:alpha(opacity=75);-moz-opacity:0.75;opacity:0.75}#wysija_popup_overlay.loading{background:url(../img/popup/loading.gif) no-repeat 50% 50% #000}#wysija_popup{position:absolute;top:0;left:0;width:600px;height:400px;background-color:#fff;z-index:999999;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;-moz-box-shadow:#000 0 4px 30px;-webkit-box-shadow:#000 0 4px 30px;-khtml-box-shadow:#000 0 4px 30px;box-shadow:#000 0 4px 30px;border:1px solid #555}#wysija_popup_content{padding:0;overflow:hidden;position:relative}#wysija_popup_title{background-color:#222;border:1px solid #333;height:27px;margin:0;padding:0}#wysija_popup_title h3{color:#cfcfcf;font-size:12px;font-weight:normal;margin:6px 0 0 10px;padding:0;float:left;font:12px "Lucida Grande", Verdana, Arial, sans-serif}#wysija_popup_iframe{border:0 none;outline:0 none}#wysija_popup_close{background:url(../img/popup/close.png) no-repeat;height:15px;width:15px;background-color:#333;display:block;float:right;margin:6px 10px 0 0}.mpoet-ui .wysija_item_settings{text-decoration:none}.mpoet-ui .settings span{background:none;color:#999}.mpoet-ui .wysija_item_settings:hover .dashicons-admin-generic:before,.mpoet-ui .settings:hover .dashicons-admin-generic:before{color:#2ea2cc}.wp_themeSkin .mceToolbar{margin:0 !important;padding:0 !important}
1
+ .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}.hidden{display:none}strong{font-weight:bold}img{vertical-align:middle}:focus{outline:0 !important}.inline{display:-moz-inline-box;display:inline-block;*display:inline;*float:left}.wysija_tools li,.wysija_tools dd{margin:0 !important}.wysija_controls li{margin:0 0 0 3px !important}#wysija_items{position:fixed;width:275px;right:20px;top:20px;z-index:999}#wysija_items li{line-height:100px;height:100px;outline:1px solid #ccc;text-align:center}.wysija_items li.disabled{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";filter:alpha(opacity=20);-moz-opacity:0.2;opacity:0.2}.wysija_items li.active a{height:100px;cursor:pointer;display:block}.wysija_header,.wysija_footer{position:relative;display:inline-table;display:block;height:1%;margin:0;padding:0;z-index:98}.wysija_header:after,.wysija_footer:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_block{position:relative;margin:0 10px;padding:10px 18px 10px 18px;display:inline-table;display:block;height:1%;margin:0;z-index:98}.wysija_block.dragging,.wysija_header.dragging,.wysija_footer.dragging{z-index:99000}.wysija_block:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_block.hover{border:1px dashed #bbb;margin:0 0 0 0;padding:9px 17px 9px 17px}.wysija_block.static{padding:0;margin:0}.wysija_block .wysija_controls{background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;border:1px solid #ccc;position:absolute;margin:0;padding:0;width:598px;height:20px;left:-1px;right:0;top:-22px;width:100%}.wysija_block .wysija_controls .handle{width:600px}.wysija_block .wysija_controls li{float:left;width:20px;height:20px}.wysija_block .wysija_controls a{cursor:pointer;float:left;font-size:120%;font-weight:bold;height:20px;line-height:20px;text-align:center;width:20px;color:#000}.wysija_block .handle_container,.wysija_block .handle_container a{float:none;width:40px}.wysija_block .handle_container{left:280px;top:0;position:absolute}.wysija_gallery .wysija_tools,.wysija_image .wysija_tools{position:absolute;height:34px;line-height:34px;margin:0;width:152px;top:-36px;z-index:1010;background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;border:1px solid #ccc;padding:0 0 0 5px}.wysija_gallery .wysija_tools{width:102px}.left .wysija_image .wysija_tools,.center .wysija_image .wysija_tools,.left.wysija_gallery .wysija_tools,.center.wysija_gallery .wysija_tools{left:0;text-align:left}.right .wysija_image .wysija_tools,.right.wysija_gallery .wysija_tools{right:0;text-align:right}.wysija_text .wysija_tools{position:absolute;height:20px;line-height:20px;top:0;right:0;margin:0;z-index:1000;width:20px}.wysija_text.alone .wysija_tools{display:none}.wysija_gallery .wysija_tools li,.wysija_image .wysija_tools li{float:left;width:25px;height:34px}.wysija_text .wysija_tools li{float:left;width:20px;height:20px}.wysija_gallery .wysija_tools a,.wysija_image .wysija_tools a,.wysija_text .wysija_tools a{background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));float:left;width:20px;height:20px;margin:5px 3px 0 0;-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.15),inset 0 0 2px 1px #fff;-moz-box-shadow:0 1px 0 rgba(0,0,0,0.15),inset 0 0 2px 1px #fff;box-shadow:0 1px 0 rgba(0,0,0,0.15),inset 0 0 2px 1px #fff;border:1px solid #ccc;z-index:1010;position:relative}.wysija_text .wysija_tools a{margin:0}.wysija_gallery .wysija_tools a:hover,.wysija_image .wysija_tools a:hover,.wysija_text .wysija_tools a:hover{background-color:#ddd;border-color:#909090}.wysija_gallery .wysija_tools a.active,.wysija_image .wysija_tools a.active,.wysija_text .wysija_tools a.active{background-color:#ddd;background-image:-moz-linear-gradient(center bottom, #eee, #bbb);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#eee), to(#bbb));border-color:#909090}.wysija_controls a span,.wysija_gallery .wysija_tools a span,.wysija_image .wysija_tools a span,.wysija_text .wysija_tools a span,.wj_content a span{display:block;height:20px;width:20px}.wysija_controls span input{margin:2px 0 0 0;padding:0;color:transparent}.alignment-left span{background:url(../img/controls/icons.png) no-repeat 0 0}.alignment-left.active span,.alignment-left:hover span{background:url(../img/controls/icons.png) no-repeat 0 -20px}.alignment-center span{background:url(../img/controls/icons.png) no-repeat -20px 0}.alignment-center.active span,.alignment-center:hover span{background:url(../img/controls/icons.png) no-repeat -20px -20px}.alignment-right span{background:url(../img/controls/icons.png) no-repeat -40px 0}.alignment-right.active span,.alignment-right:hover span{background:url(../img/controls/icons.png) no-repeat -40px -20px}.add-link span{background:url(../img/controls/icons.png) no-repeat -60px 0}.add-link.active span,.add-link:hover span{background:url(../img/controls/icons.png) no-repeat -60px -20px}.remove-link span{background:url(../img/controls/icons.png) no-repeat -80px 0}.remove-link.active span,.remove-link:hover span{background:url(../img/controls/icons.png) no-repeat -80px -20px}.remove span{background:url(../img/controls/icons.png) no-repeat -100px 0}.remove.active span,.remove:hover span{background:url(../img/controls/icons.png) no-repeat -100px -20px}.handle span{background:url(../img/controls/grip-handle.png) no-repeat;cursor:move;width:40px !important}.duplicate span{background:url(../img/controls/icons.png) no-repeat -140px 0}.duplicate.active span,.duplicate:hover span{background:url(../img/controls/icons.png) no-repeat -140px -20px}.settings span{background:url(../img/controls/icons.png) no-repeat -160px 0}.settings.active span,.settings:hover span{background:url(../img/controls/icons.png) no-repeat -160px -20px}.icon-plus span{background:url(../img/controls/icons.png) no-repeat -200px 0}.icon-plus.active span,.icon-plus:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.icon-minus span{background:url(../img/controls/icons.png) no-repeat -220px 0}.icon-minus.active span,.icon-minus:hover span{background:url(../img/controls/icons.png) no-repeat -220px -20px}.banner{color:#000;background-color:#fff;z-index:999;text-align:center;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";filter:alpha(opacity=70);-moz-opacity:0.7;opacity:0.7;width:600px;position:absolute;top:0;right:0;left:0;bottom:0;white-space:nowrap;font-size:16px !important}.banner .banner-message{margin:20px auto 0 auto}.banner .banner-notice{margin:10px auto 0 auto;font-size:12px;font-style:italic}#wysija_wrapper{padding:20px;width:600px;border:1px solid #ccc;position:relative;background-color:#fff;-webkit-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);-moz-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);box-shadow:0 0 5px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1)}#wysija_wrapper:before,#wysija_wrapper:after{position:absolute;width:40%;height:10px;content:' ';left:12px;bottom:12px;background:transparent;-webkit-transform:skew(-5deg) rotate(-5deg);-moz-transform:skew(-5deg) rotate(-5deg);-ms-transform:skew(-5deg) rotate(-5deg);-o-transform:skew(-5deg) rotate(-5deg);transform:skew(-5deg) rotate(-5deg);-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.3);-moz-box-shadow:0 6px 12px rgba(0,0,0,0.3);box-shadow:0 6px 12px rgba(0,0,0,0.3);z-index:-1}#wysija_wrapper:after{left:auto;right:12px;-webkit-transform:skew(5deg) rotate(5deg);-moz-transform:skew(5deg) rotate(5deg);-ms-transform:skew(5deg) rotate(5deg);-o-transform:skew(5deg) rotate(5deg);transform:skew(5deg) rotate(5deg)}body.rtl #wysija_wrapper{right:603px !important}#wysija_container{margin:30px 0 0 0;width:600px;border-collapse:collapse;width:600px;margin:0;padding:0}#wysija_header{padding:0}#wysija_body{vertical-align:top;padding:0}#wysija_footer{padding:0}.empty{display:none}.empty.active.wysija_image,.empty.active.wysija_text{display:block}#wysija_block_placeholder{height:0;padding:0;margin:0}#block_placeholder{margin:0;height:0}#block_placeholder.active{margin:18px 18px 0px 18px;display:block;height:30px}.block_placeholder{border:0 none;z-index:9500;margin:0;position:relative;left:0;top:-10px;width:562px}.wysija_block .block_placeholder,.wysija_block .text_placeholder,.wysija_block .image_placeholder{margin:0}.image_placeholder{margin:1px 0 0 1px}.wysija_block .block_placeholder.active,.wysija_block .text_placeholder.active{height:30px}.block_placeholder,.text_placeholder,.image_placeholder.empty{transition:opacity .25s, height .25s linear;-moz-transition:opacity .25s, height .25s linear;-webkit-transition:opacity .25s, height .25s linear;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);-moz-opacity:0;opacity:0;height:0;margin:0}.image_placeholder.active{border:1px dashed #bbb;background-color:#f5f5f5;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;transition:opacity .25s;-moz-transition:opacity .25s;-webkit-transition:opacity .25s}.block_placeholder.active,.text_placeholder.active,.image_placeholder.empty.active{border:1px dashed #bbb;background-color:#f5f5f5;display:block;transition:opacity .25s, height .25s linear;-moz-transition:opacity .25s, height .25s linear;-webkit-transition:opacity .25s, height .25s linear;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5}.wysija_content .empty.editable{margin:0 !important}.block_placeholder.active,.wysija_content.center .text_placeholder.active{height:30px}.image_placeholder.empty.active{height:80px;width:80px}.wysija_image.empty.active{width:80px}.wysija_content.right .wysija_image.empty.active{margin-right:3px}.auto-post .block_placeholder.active{margin:0 0 0 18px}.block_placeholder.hover,.text_placeholder.hover,.image_placeholder.hover,.image_placeholder.empty.hover{background-color:#e5e5e5;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);-moz-opacity:1.0;opacity:1.0}.text_placeholder.hover{display:block}#wysija_header .wysija_image.active,#wysija_footer .wysija_image.active{left:0;top:0;right:0}.wysija_header .image_placeholder,.wysija_footer .image_placeholder{border:0 none !important;margin:0 !important}.wysija_header .image_placeholder.active,.wysija_footer .image_placeholder.active{border:0 none !important}.wysija_options{display:none}.wysija_content .wysija_image,.wysija_content.center .wysija_image{margin:0 auto 15px auto;cursor:move}.wysija_content.center .image_placeholder.active{margin:0 0 -2px 0}.wysija_header .wysija_content.center .wysija_image,.wysija_footer .wysija_content.center .wysija_image{margin:0 auto}.wysija_header .wysija_content.left .wysija_image,.wysija_header .wysija_content.right .wysija_image,.wysija_footer .wysija_content.left .wysija_image,.wysija_footer .wysija_content.right .wysija_image{margin:0 0 0 0}.wysija_header .wysija_content.center .image_placeholder.active,.wysija_footer .wysija_content.center .image_placeholder.active{margin:0}.wysija_content.left{float:none}.wysija_gallery.left{float:left}.wysija_content.left .wysija_image{float:left;margin:0 15px 5px 0}.wysija_gallery.right{float:right}.wysija_content.right .wysija_image{float:right;margin:0 0 5px 15px}.wysija_content .wysija_image.alone{margin:0 !important}.wysija_content.center .wysija_image.alone{margin:0 auto !important}.wysija_content.left .wysija_image.active{margin:0 13px 3px 0;left:-1px;top:-1px}.wysija_content.center .wysija_image.active{left:-1px;top:-1px}.wysija_content.right .wysija_image.active{margin:0 0 3px 13px;top:-1px;right:-1px}.wysija_image{position:relative;z-index:999}.wysija_image .url-info{position:absolute;bottom:0;left:0;font-size:0.7em;padding:2px;color:#000;background-color:#fff;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";filter:alpha(opacity=80);-moz-opacity:0.8;opacity:0.8}.wysija_content.left .wysija_image .url-info{right:0;left:auto}.wysija_text{position:relative;z-index:998}.wysija_text.editing{border:1px solid #dfdfdf}.wysija_content.left .wysija_text.editing{float:left}.wysija_text .editable:hover{cursor:pointer}#wysija_toolbar{left:657px;position:absolute;top:-1000px;width:295px}#wysija_toolbar .wysija_toolbar_tabs{border-bottom:1px solid #dfdfdf;line-height:0}#wysija_toolbar .wysija_toolbar_tabs li,#wysija_toolbar .wysija_toolbar_tabs a{margin:0;height:30px;line-height:30px;padding:0;display:-moz-inline-box;display:inline-block;*display:inline;*float:left;outline:0 none}#wysija_toolbar .wysija_toolbar_tabs a{outline:0 none;text-decoration:none;color:#a6a6a6}#wysija_toolbar .wysija_toolbar_tabs li{margin:0 0 1px 0}#wysija_toolbar .wysija_toolbar_tabs a{font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #f5f5f5);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#F5F5F5', endColorstr='#F9F9F9');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#f5f5f5));border:1px solid #DFDFDF;-moz-border-radius:3px 3px 0 0;-webkit-border-radius:3px 3px 0 0;-khtml-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;box-shadow:0 1px 0 #FFFFFF inset;padding:0 7px}#wysija_toolbar .wysija_toolbar_tabs a:hover{background-color:#eee}#wysija_toolbar .wysija_toolbar_tabs a.selected{color:#000;border-bottom:0 none;background:#fcfcfc;filter:none;padding-bottom:1px}#wysija_toolbar .wysija_toolbar_tabs,#wysija_toolbar .wj_content,#wysija_toolbar .wj_images,#wysija_toolbar .wj_styles,#wysija_toolbar .wj_themes{position:relative;z-index:9998;margin:0}#wysija_toolbar #wysija_notices span{font-size:12px !important;font-weight:normal !important}.wj_content{background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:0 0 10px 0}.wj_content li{padding:10px 10px 0 10px;position:relative}.wj_content li.notice{font-style:italic;font-size:11px;margin:0 !important;border:0 none !important;background:none !important}.wj_images{z-index:999;background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:9px}.wj_images ul{height:360px;overflow:auto;margin:0;padding:0}.wj_images li{float:left;width:80px;margin:2px;height:80px;overflow:hidden;position:relative;border:1px solid #dfdfdf}.wj_images li img{max-height:150px;width:80px}.wj_images li a{float:left;display:block;height:80px;width:80px}.wj_button{text-align:center;width:265px;margin:20px 0;height:30px;line-height:30px}.wj_images img{cursor:move;max-width:275px}#wysija-upload-browse,#wysija-themes-browse{float:none}.wj_images #wj_images_preview{border:3px solid #dfdfdf;position:absolute;right:295px;top:0;background-color:#fff}.wj_styles{z-index:999;background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:9px}.wj_styles p{margin:10px 0}.wj_styles .preview{width:20px;float:none !important;height:20px;vertical-align:middle;display:-moz-inline-box;display:inline-block;*display:inline;*float:left;border:1px solid #333}.wj_styles input,.wj_styles select{height:20px;border:0 none;border:1px solid #CCC;margin:0 3px 0 0 !important;padding:0 !important;vertical-align:middle;line-height:20px;font-size:12px}.wj_styles #aUnderlineInput{margin:0 0 0 10px !important}.wj_styles select{width:75px}.wj_styles input.checkbox,.wj_styles input[type=checkbox]{border:0 none !important}.wj_styles input.color{width:55px;padding:0 0 0 2px !important}.wj_styles input.color.disabled{background-color:#eee !important;color:#eee !important}.wj_styles select.small-size{width:50px}.wj_styles select.type{width:68px}.wj_styles select.size{width:58px}.wj_styles form label{cursor:normal;margin:0 0 0 3px}.wj_themes{z-index:999;background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:9px}.wj_themes ul{height:360px;overflow:auto;margin:0;padding:0}.wj_themes li{float:left;width:80px;margin:2px;height:80px;overflow:hidden;border:1px solid #dfdfdf;position:relative}.wj_themes li img{max-height:150px;width:80px}.wj_themes li a{display:block}.wj_themes #wj_themes_preview{border:3px solid #dfdfdf;position:absolute;right:295px;top:0;background-color:#fff}.wysija_widget{width:275px;height:25px;line-height:25px;z-index:9999 !important}.wj_content a.wysija_item,.wysija_widget{height:25px;line-height:25px;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;display:block;font-size:12px;font-weight:bold;padding:0 0 0 7px;cursor:move;color:#222;text-shadow:0 1px 0 #FFFFFF}.wj_content a.wysija_item.disabled{cursor:help;color:#cccccc}.wysija_item_settings{position:absolute;right:15px;top:13px}.wysija_widget.image{z-index:9999 !important;height:auto !important;width:150px !important;background:none !important;border:0 none !important;box-shadow:none !important;border-radius:0 !important;padding:0 !important}#wysija_notices{z-index:20000;position:relative;left:0;top:0;padding:5px;border:1px solid #dfdfdf;border-top:0 none}#wysija_notices.notice{background-color:#FFFFE0;border-color:#E6DB55;z-index:9999}#wysija_notices.error{background-color:#FFEBE8;border-color:#CC0000}#wysija_notice_msg{font-size:14px;font-weight:bold}.align-center{text-align:center}.align-left{text-align:left}.align-right{text-align:right}.align-justify{text-align:justify}.wysija_gallery{position:relative}.wysija_gallery.center{margin:0 auto}.wysija_gallery.right{text-align:right}.wysija_gallery.left{text-align:left}.wysija_row{width:100%}.wysija_cell{float:left;text-align:center}.resize-controls{position:absolute;left:-1px;right:-1px;top:-1px;height:100%;z-index:99000;border:1px dashed #ccc}.resize-handle{position:absolute;bottom:0;right:0;width:20px;height:20px;border:0 none;z-index:1001;cursor:se-resize;background:transparent url(../img/controls/resize-se.png) no-repeat scroll right bottom}.resize-info{position:absolute;bottom:0;left:0;font-size:0.8em;padding:2px;text-shadow:0 1px 0 #F7F5F2}.right .resize-handle{position:absolute;bottom:0;left:0;width:20px;height:20px;border:0 none;z-index:1001;cursor:sw-resize;background:transparent url(../img/controls/resize-sw.png) no-repeat scroll left bottom}.right .resize-info{position:absolute;bottom:0;right:0;text-align:right}#adminmenu li .wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{z-index:1001 !important}.wysija_divider{margin:0 auto;width:564px}.wysija_block.auto-post.hover .wysija_content *,.wysija_block.auto-post.hover .wysija_divider{z-index:1000;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";filter:alpha(opacity=30);-moz-opacity:0.3;opacity:0.3}.wysija_auto-post .wysija_divider{text-align:center;margin:0 !important;width:100% !important}.wysija_auto-post .nopost{height:100px}.wysija_auto-post .nopost p{margin:25px 0 0 0}.wysija_settings{left:10px;position:absolute;top:0;z-index:1000}.wysija_settings a{background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;font-size:12px;font-weight:normal;cursor:pointer;color:#222;text-shadow:0 1px 0 #FFFFFF;text-decoration:none;display:block;padding:5px 5px 3px 27px}.wysija_settings a span{width:20px;height:20px;position:absolute;top:3px;left:5px}#wysija_toggle_images{position:absolute;top:5px;right:5px;z-index:1000;width:73px;height:33px;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;background-color:#fff}#wysija_toggle_images.on{background:url(../img/controls/images-toggle-on.png) no-repeat}#wysija_toggle_images.off{background:url(../img/controls/images-toggle-off.png) no-repeat}#wysija_toggle_images:hover{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);-moz-opacity:1.0;opacity:1.0}.wysija_block.auto-post{padding:0 !important}.wysija_auto-post .wysija_content{padding:10px 17px !important}.wysija_auto-post .wysija_content:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_auto-post .wysija_content{display:inline-table}* html .wysija_auto-post .wysija_content{height:1%}.wysija_auto-post .wysija_content{display:block}.wysija_auto-post .wysija_divider{padding:9px 0 !important}.wysija_block.auto-post.hover .wysija_content{padding:10px 17px !important}.wysija_auto-post .wysija_text{pointer-events:none;cursor:default}.wysija_auto-post .wysija_image{pointer-events:none;cursor:default}.auto-post.hover .wysija_content:last-child{padding:9px 17px 9px 17px !important}.wysija_auto-post .loading{padding:10px 17px;font-size:10px}#wysija_popup_overlay{background-color:#000;height:100%;left:0;position:fixed;top:0;width:100%;z-index:999989;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=75)";filter:alpha(opacity=75);-moz-opacity:0.75;opacity:0.75}#wysija_popup_overlay.loading{background:url(../img/popup/loading.gif) no-repeat 50% 50% #000}#wysija_popup{position:absolute;top:0;left:0;width:600px;height:400px;background-color:#fff;z-index:999999;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;-moz-box-shadow:#000 0 4px 30px;-webkit-box-shadow:#000 0 4px 30px;-khtml-box-shadow:#000 0 4px 30px;box-shadow:#000 0 4px 30px;border:1px solid #555}#wysija_popup_content{padding:0;overflow:hidden;position:relative}#wysija_popup_title{background-color:#222;border:1px solid #333;height:27px;margin:0;padding:0}#wysija_popup_title h3{color:#cfcfcf;font-size:12px;font-weight:normal;margin:6px 0 0 10px;padding:0;float:left;font:12px "Lucida Grande", Verdana, Arial, sans-serif}#wysija_popup_iframe{border:0 none;outline:0 none}#wysija_popup_close{background:url(../img/popup/close.png) no-repeat;height:15px;width:15px;background-color:#333;display:block;float:right;margin:6px 10px 0 0}.debug-line{position:absolute;left:0;top:0;display:block;height:1px;width:100%}.debug-line.red{background-color:#f00}.debug-line.green{background-color:#0f0}.debug-line.blue{background-color:#00f}.mpoet-ui .wysija_item_settings{text-decoration:none}.mpoet-ui .settings span{background:none;color:#999}.mpoet-ui .wysija_item_settings:hover .dashicons-admin-generic:before,.mpoet-ui .settings:hover .dashicons-admin-generic:before{color:#2ea2cc}
css/wysija-form-editor.css CHANGED
@@ -1 +1 @@
1
- .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}.hidden{display:none}strong{font-weight:bold}img{vertical-align:middle}:focus{outline:0 !important}.inline{display:-moz-inline-box;display:inline-block;*display:inline;*float:left}#form-error{padding:10px;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;color:#000;font-weight:normal;background-color:#ffebe8;border:1px solid #c00}#form-notice{padding:10px;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;color:#555555;font-weight:normal;background-color:#FFFBCC;border:1px solid #E6DB55}#wysija_form_editor{padding:20px;width:600px;border:1px solid #ccc;position:relative;background-color:#fff;-webkit-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);-moz-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);box-shadow:0 0 5px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1)}#wysija_form_editor:before,#wysija_form_editor:after{position:absolute;width:40%;height:10px;content:' ';left:12px;bottom:12px;background:transparent;-webkit-transform:skew(-5deg) rotate(-5deg);-moz-transform:skew(-5deg) rotate(-5deg);-ms-transform:skew(-5deg) rotate(-5deg);-o-transform:skew(-5deg) rotate(-5deg);transform:skew(-5deg) rotate(-5deg);-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.3);-moz-box-shadow:0 6px 12px rgba(0,0,0,0.3);box-shadow:0 6px 12px rgba(0,0,0,0.3);z-index:-1}#wysija_form_editor:after{left:auto;right:12px;-webkit-transform:skew(5deg) rotate(5deg);-moz-transform:skew(5deg) rotate(5deg);-ms-transform:skew(5deg) rotate(5deg);-o-transform:skew(5deg) rotate(5deg);transform:skew(5deg) rotate(5deg)}.wysija_form_block .wysija_warning{font-weight:bold;color:#900}.block_placeholder{margin:0;border:0 none}.block_placeholder.active{border:1px dashed #b4b4b4;margin:10px;display:block}.block_placeholder.hover{margin:10px;border:1px dashed #b4b4b4;background-color:#f5f5f5}.wysija_form_block{background-color:#fff;height:20px;border:0 none}.wysija_form_block.highlighted{border:1px solid #5897FB;padding:9px 17px}.wysija_form_block img{max-width:100%}.wysija_form_block p{margin:5px 0;word-wrap:break-word}.wysija_form_block p input.radio,.wysija_form_block p input.checkbox{margin:0 5px 0 0}#wysija_form_container{width:640px;margin:0}#wysija-add-field{float:none}#wysija_form_toolbar{position:absolute;width:295px}#wysija_form_toolbar .wysija_form_toolbar_tabs{border-bottom:1px solid #dfdfdf;line-height:0}#wysija_form_toolbar .add_custom_field{text-align:center;padding:15px 0 5px 0}#wysija_form_toolbar .wysija_form_toolbar_tabs li,#wysija_form_toolbar .wysija_form_toolbar_tabs a{margin:0;height:30px;line-height:30px;padding:0;display:-moz-inline-box;display:inline-block;*display:inline;*float:left;outline:0 none}#wysija_form_toolbar .wysija_form_toolbar_tabs a{outline:0 none;text-decoration:none;color:#a6a6a6}#wysija_form_toolbar .wysija_form_toolbar_tabs li{margin:0 0 1px 0}#wysija_form_toolbar .wysija_form_toolbar_tabs a{font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #f5f5f5);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#F5F5F5', endColorstr='#F9F9F9');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#f5f5f5));border:1px solid #DFDFDF;-moz-border-radius:3px 3px 0 0;-webkit-border-radius:3px 3px 0 0;-khtml-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;box-shadow:0 1px 0 #FFFFFF inset;padding:0 7px}#wysija_form_toolbar .wysija_form_toolbar_tabs a:hover{background-color:#eee}#wysija_form_toolbar .wysija_form_toolbar_tabs a.selected{color:#000;border-bottom:0 none;background:#fcfcfc;filter:none;padding-bottom:1px}#wysija_form_toolbar .wysija_form_toolbar_tabs,#wysija_form_toolbar .wj_content,#wysija_form_toolbar .wj_images,#wysija_form_toolbar .wj_styles,#wysija_form_toolbar .wj_themes{position:relative;z-index:9998;margin:0}.wysija_form_widget{width:275px;height:25px;line-height:25px;z-index:9999 !important}#wysija_form_toolbar a.wysija_form_item,.wysija_form_widget{height:25px;line-height:25px;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;display:block;font-size:12px;font-weight:bold;padding:0 0 0 7px;cursor:move;color:#222;text-shadow:0 1px 0 #FFFFFF}#wysija_form_toolbar a.wysija_form_item.disabled{cursor:pointer;color:#cccccc;pointer-events:none}.wysija_form_item_settings{position:absolute;right:35px;top:13px}.wysija_form_item_delete{position:absolute;right:15px;top:13px}.wj_content{background-color:#fcfcfc;border:1px solid #dfdfdf;padding:0 0 10px 0}.wj_content li{padding:10px 10px 0 10px;position:relative}.wj_content li.notice{font-style:italic;font-size:11px;margin:0 !important;border:0 none !important;background:none !important}.wysija_form_block{position:relative;margin:0;padding:10px 18px 10px 18px;display:inline-table;display:block;height:1%;margin:0;z-index:98}.wysija_form_block.dragging{z-index:99000;pointer-events:none}.wysija_form_block:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_form_block.hover{border:1px dashed #bbb;margin:0 0 0 0;padding:9px 17px 9px 17px}.wysija_form_block.static{background-color:#999}.wysija_form_block .wysija_controls{background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;border:1px solid #ccc;position:absolute;margin:0;padding:0;width:598px;height:20px;left:-1px;right:0;top:-22px}.wysija_form_block .wysija_controls li{float:left;width:20px;height:20px}.wysija_form_block .wysija_controls a{cursor:pointer;float:left;font-size:120%;font-weight:bold;height:20px;line-height:20px;text-align:center;width:20px;color:#000}.wysija_form_block .wysija_controls a.remove{margin:0 0 0 1px}.wysija_form_block .handle_container,.wysija_form_block .handle_container a{float:none;width:40px !important}.wysija_form_block .handle_container{left:280px;top:0;position:absolute}.wysija_controls a span,.wysija_gallery .wysija_tools a span,.wysija_image .wysija_tools a span,.wysija_text .wysija_tools a span,.wj_content a span{display:block;height:20px;width:20px}.wysija_controls span input{margin:2px 0 0 0;padding:0;color:transparent}.alignment-left span{background:url(../img/controls/icons.png) no-repeat 0 0}.alignment-left.active span,.alignment-left:hover span{background:url(../img/controls/icons.png) no-repeat 0 -20px}.alignment-center span{background:url(../img/controls/icons.png) no-repeat -20px 0}.alignment-center.active span,.alignment-center:hover span{background:url(../img/controls/icons.png) no-repeat -20px -20px}.alignment-right span{background:url(../img/controls/icons.png) no-repeat -40px 0}.alignment-right.active span,.alignment-right:hover span{background:url(../img/controls/icons.png) no-repeat -40px -20px}.add-link span{background:url(../img/controls/icons.png) no-repeat -60px 0}.add-link.active span,.add-link:hover span{background:url(../img/controls/icons.png) no-repeat -60px -20px}.remove-link span{background:url(../img/controls/icons.png) no-repeat -80px 0}.remove-link.active span,.remove-link:hover span{background:url(../img/controls/icons.png) no-repeat -80px -20px}.remove span,.delete span{background:url(../img/controls/icons.png) no-repeat -100px 0}.remove.active span,.remove:hover span,.delete.active span,.delete:hover span{background:url(../img/controls/icons.png) no-repeat -100px -20px}.handle span{background:url(../img/controls/grip-handle.png) no-repeat;cursor:move;width:40px !important}.duplicate span{background:url(../img/controls/icons.png) no-repeat -140px 0}.duplicate.active span,.duplicate:hover span{background:url(../img/controls/icons.png) no-repeat -140px -20px}.settings span{background:url(../img/controls/icons.png) no-repeat -160px 0}.settings.active span,.settings:hover span{background:url(../img/controls/icons.png) no-repeat -160px -20px}.icon-plus span{background:url(../img/controls/icons.png) no-repeat -200px 0}.icon-plus.active span,.icon-plus:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.icon-minus span{background:url(../img/controls/icons.png) no-repeat -220px 0}.icon-minus.active span,.icon-minus:hover span{background:url(../img/controls/icons.png) no-repeat -220px -20px}.wysija_options{display:none}.wysija_settings{left:10px;position:absolute;top:0;z-index:1000}.wysija_settings a{background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;font-size:12px;font-weight:normal;cursor:pointer;color:#222;text-shadow:0 1px 0 #FFFFFF;text-decoration:none;display:block;padding:5px 5px 3px 27px}.wysija_settings a span{width:20px;height:20px;position:absolute;top:3px;left:5px}.wysija_form_block label{margin:0 5px 0 0;display:block}#wysija_widget_templates{display:none}#wysija_popup_overlay{background-color:#000;height:100%;left:0;position:fixed;top:0;width:100%;z-index:999998;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=75)";filter:alpha(opacity=75);-moz-opacity:0.75;opacity:0.75}#wysija_popup_overlay.loading{background:url(../img/popup/loading.gif) no-repeat 50% 50% #000}#wysija_popup{position:absolute;top:0;left:0;width:600px;height:400px;background-color:#fff;z-index:999999;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;-moz-box-shadow:#000 0 4px 30px;-webkit-box-shadow:#000 0 4px 30px;-khtml-box-shadow:#000 0 4px 30px;box-shadow:#000 0 4px 30px;border:1px solid #555}#wysija_popup_content{padding:0;overflow:hidden;clear:both}#wysija_popup_title{background-color:#222;border:1px solid #333;height:27px;margin:0;padding:0}#wysija_popup_title h3{color:#cfcfcf;font-size:12px;font-weight:normal;margin:6px 0 0 10px;padding:0;float:left;font:12px "Lucida Grande", Verdana, Arial, sans-serif}#wysija_popup_title.empty{background-color:transparent;height:0;border:0 none}#wysija_popup_iframe{border:0 none;outline:0 none}#wysija_popup_close{background:url(../img/popup/close.png) no-repeat;height:15px;width:15px;background-color:#333;display:block;float:right;margin:6px 10px 0 0}h2.title{height:40px;line-height:40px;margin:0 0 15px 0}h2.title span,h2.title form{float:left;margin:0 5px 0 0;vertical-align:middle}h2.title span#form-name{padding:0 3px;margin:0 10px 0 0;font-style:italic}h2.title span#form-name-default{display:none}h2.title #edit-form-name{float:left;margin:10px 5px 0 0}h2.title input{margin:0 10px 0 0}#list-selection{margin:30px 0 0 0}#list-selection label{display:block}#after-submit{margin:30px 0 0 0}#after-submit textarea{width:300px;height:50px}#form-export-links{margin:20px 0 0 0}#form-export textarea{width:100%;height:100px}#wysija_notices{z-index:20000;position:relative;left:0;top:0;padding:5px;border:1px solid #dfdfdf;border-top:0 none}#wysija_notices.notice{background-color:#FFFFE0;border-color:#E6DB55;z-index:9999}#wysija_notices.error{background-color:#FFEBE8;border-color:#CC0000}#wysija_notice_msg{font-size:14px;font-weight:bold}.expand-code{cursor:pointer}.wysija_form_block textarea{resize:none}.mpoet-ui .wysija_form_item_settings,.mpoet-ui .wysija_form_item_delete{text-decoration:none}.mpoet-ui .wysija_form_item_settings:hover .dashicons-admin-generic:before,.mpoet-ui .wysija_form_item_delete:hover .dashicons-dismiss:before,.mpoet-ui .settings:hover .dashicons-admin-generic:before{color:#2ea2cc}.mpoet-ui .settings span,.mpoet-ui .delete span{background:none;color:#999}.mpoet-ui .delete span:before{font-size:21px}
1
+ .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}.hidden{display:none}strong{font-weight:bold}img{vertical-align:middle}:focus{outline:0 !important}.inline{display:-moz-inline-box;display:inline-block;*display:inline;*float:left}#form-error{padding:10px;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;color:#000;font-weight:normal;background-color:#ffebe8;border:1px solid #c00}#form-notice{padding:10px;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;color:#555555;font-weight:normal;background-color:#FFFBCC;border:1px solid #E6DB55}#wysija_form_editor{padding:20px;width:600px;border:1px solid #ccc;position:relative;background-color:#fff;-webkit-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);-moz-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);box-shadow:0 0 5px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1)}#wysija_form_editor:before,#wysija_form_editor:after{position:absolute;width:40%;height:10px;content:' ';left:12px;bottom:12px;background:transparent;-webkit-transform:skew(-5deg) rotate(-5deg);-moz-transform:skew(-5deg) rotate(-5deg);-ms-transform:skew(-5deg) rotate(-5deg);-o-transform:skew(-5deg) rotate(-5deg);transform:skew(-5deg) rotate(-5deg);-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.3);-moz-box-shadow:0 6px 12px rgba(0,0,0,0.3);box-shadow:0 6px 12px rgba(0,0,0,0.3);z-index:-1}#wysija_form_editor:after{left:auto;right:12px;-webkit-transform:skew(5deg) rotate(5deg);-moz-transform:skew(5deg) rotate(5deg);-ms-transform:skew(5deg) rotate(5deg);-o-transform:skew(5deg) rotate(5deg);transform:skew(5deg) rotate(5deg)}.wysija_form_block .wysija_warning{font-weight:bold;color:#900}.block_placeholder{margin:0;border:0 none}.block_placeholder.active{border:1px dashed #b4b4b4;margin:10px;display:block}.block_placeholder.hover{margin:10px;border:1px dashed #b4b4b4;background-color:#f5f5f5}.wysija_form_block{background-color:#fff;height:20px;border:0 none}.wysija_form_block.highlighted{border:1px solid #5897FB;padding:9px 17px}.wysija_form_block img{max-width:100%}.wysija_form_block p{margin:5px 0}.wysija_form_block p input.radio,.wysija_form_block p input.checkbox{margin:0 5px 0 0}#wysija_form_container{width:640px;margin:0}#wysija-add-field{float:none}#wysija_form_toolbar{position:absolute;width:295px}#wysija_form_toolbar .wysija_form_toolbar_tabs{border-bottom:1px solid #dfdfdf;line-height:0}#wysija_form_toolbar .add_custom_field{text-align:center;padding:15px 0 5px 0}#wysija_form_toolbar .wysija_form_toolbar_tabs li,#wysija_form_toolbar .wysija_form_toolbar_tabs a{margin:0;height:30px;line-height:30px;padding:0;display:-moz-inline-box;display:inline-block;*display:inline;*float:left;outline:0 none}#wysija_form_toolbar .wysija_form_toolbar_tabs a{outline:0 none;text-decoration:none;color:#a6a6a6}#wysija_form_toolbar .wysija_form_toolbar_tabs li{margin:0 0 1px 0}#wysija_form_toolbar .wysija_form_toolbar_tabs a{font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #f5f5f5);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#F5F5F5', endColorstr='#F9F9F9');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#f5f5f5));border:1px solid #DFDFDF;-moz-border-radius:3px 3px 0 0;-webkit-border-radius:3px 3px 0 0;-khtml-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;box-shadow:0 1px 0 #FFFFFF inset;padding:0 7px}#wysija_form_toolbar .wysija_form_toolbar_tabs a:hover{background-color:#eee}#wysija_form_toolbar .wysija_form_toolbar_tabs a.selected{color:#000;border-bottom:0 none;background:#fcfcfc;filter:none;padding-bottom:1px}#wysija_form_toolbar .wysija_form_toolbar_tabs,#wysija_form_toolbar .wj_content,#wysija_form_toolbar .wj_images,#wysija_form_toolbar .wj_styles,#wysija_form_toolbar .wj_themes{position:relative;z-index:9998;margin:0}.wysija_form_widget{width:275px;height:25px;line-height:25px;z-index:9999 !important}#wysija_form_toolbar a.wysija_form_item,.wysija_form_widget{height:25px;line-height:25px;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;display:block;font-size:12px;font-weight:bold;padding:0 0 0 7px;cursor:move;color:#222;text-shadow:0 1px 0 #FFFFFF}#wysija_form_toolbar a.wysija_form_item.disabled{cursor:pointer;color:#cccccc;pointer-events:none}.wysija_form_item_settings{position:absolute;right:35px;top:13px}.wysija_form_item_delete{position:absolute;right:15px;top:13px}.wj_content{background-color:#fcfcfc;border:1px solid #dfdfdf;padding:0 0 10px 0}.wj_content li{padding:10px 10px 0 10px;position:relative}.wj_content li.notice{font-style:italic;font-size:11px;margin:0 !important;border:0 none !important;background:none !important}.wysija_form_block{position:relative;margin:0;padding:10px 18px 10px 18px;display:inline-table;display:block;height:1%;margin:0;z-index:98}.wysija_form_block.dragging{z-index:99000;pointer-events:none}.wysija_form_block:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_form_block.hover{border:1px dashed #bbb;margin:0 0 0 0;padding:9px 17px 9px 17px}.wysija_form_block.static{background-color:#999}.wysija_form_block .wysija_controls{background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;border:1px solid #ccc;position:absolute;margin:0;padding:0;width:598px;height:20px;left:-1px;right:0;top:-22px}.wysija_form_block .wysija_controls li{float:left;width:20px;height:20px}.wysija_form_block .wysija_controls a{cursor:pointer;float:left;font-size:120%;font-weight:bold;height:20px;line-height:20px;text-align:center;width:20px;color:#000}.wysija_form_block .wysija_controls a.remove{margin:0 0 0 1px}.wysija_form_block .handle_container,.wysija_form_block .handle_container a{float:none;width:40px !important}.wysija_form_block .handle_container{left:280px;top:0;position:absolute}.wysija_controls a span,.wysija_gallery .wysija_tools a span,.wysija_image .wysija_tools a span,.wysija_text .wysija_tools a span,.wj_content a span{display:block;height:20px;width:20px}.wysija_controls span input{margin:2px 0 0 0;padding:0;color:transparent}.alignment-left span{background:url(../img/controls/icons.png) no-repeat 0 0}.alignment-left.active span,.alignment-left:hover span{background:url(../img/controls/icons.png) no-repeat 0 -20px}.alignment-center span{background:url(../img/controls/icons.png) no-repeat -20px 0}.alignment-center.active span,.alignment-center:hover span{background:url(../img/controls/icons.png) no-repeat -20px -20px}.alignment-right span{background:url(../img/controls/icons.png) no-repeat -40px 0}.alignment-right.active span,.alignment-right:hover span{background:url(../img/controls/icons.png) no-repeat -40px -20px}.add-link span{background:url(../img/controls/icons.png) no-repeat -60px 0}.add-link.active span,.add-link:hover span{background:url(../img/controls/icons.png) no-repeat -60px -20px}.remove-link span{background:url(../img/controls/icons.png) no-repeat -80px 0}.remove-link.active span,.remove-link:hover span{background:url(../img/controls/icons.png) no-repeat -80px -20px}.remove span,.delete span{background:url(../img/controls/icons.png) no-repeat -100px 0}.remove.active span,.remove:hover span,.delete.active span,.delete:hover span{background:url(../img/controls/icons.png) no-repeat -100px -20px}.handle span{background:url(../img/controls/grip-handle.png) no-repeat;cursor:move;width:40px !important}.duplicate span{background:url(../img/controls/icons.png) no-repeat -140px 0}.duplicate.active span,.duplicate:hover span{background:url(../img/controls/icons.png) no-repeat -140px -20px}.settings span{background:url(../img/controls/icons.png) no-repeat -160px 0}.settings.active span,.settings:hover span{background:url(../img/controls/icons.png) no-repeat -160px -20px}.icon-plus span{background:url(../img/controls/icons.png) no-repeat -200px 0}.icon-plus.active span,.icon-plus:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.icon-minus span{background:url(../img/controls/icons.png) no-repeat -220px 0}.icon-minus.active span,.icon-minus:hover span{background:url(../img/controls/icons.png) no-repeat -220px -20px}.wysija_options{display:none}.wysija_settings{left:10px;position:absolute;top:0;z-index:1000}.wysija_settings a{background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;font-size:12px;font-weight:normal;cursor:pointer;color:#222;text-shadow:0 1px 0 #FFFFFF;text-decoration:none;display:block;padding:5px 5px 3px 27px}.wysija_settings a span{width:20px;height:20px;position:absolute;top:3px;left:5px}.wysija_form_block label{margin:0 5px 0 0;display:block}#wysija_widget_templates{display:none}#wysija_popup_overlay{background-color:#000;height:100%;left:0;position:fixed;top:0;width:100%;z-index:999998;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=75)";filter:alpha(opacity=75);-moz-opacity:0.75;opacity:0.75}#wysija_popup_overlay.loading{background:url(../img/popup/loading.gif) no-repeat 50% 50% #000}#wysija_popup{position:absolute;top:0;left:0;width:600px;height:400px;background-color:#fff;z-index:999999;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;-moz-box-shadow:#000 0 4px 30px;-webkit-box-shadow:#000 0 4px 30px;-khtml-box-shadow:#000 0 4px 30px;box-shadow:#000 0 4px 30px;border:1px solid #555}#wysija_popup_content{padding:0;overflow:hidden;clear:both}#wysija_popup_title{background-color:#222;border:1px solid #333;height:27px;margin:0;padding:0}#wysija_popup_title h3{color:#cfcfcf;font-size:12px;font-weight:normal;margin:6px 0 0 10px;padding:0;float:left;font:12px "Lucida Grande", Verdana, Arial, sans-serif}#wysija_popup_title.empty{background-color:transparent;height:0;border:0 none}#wysija_popup_iframe{border:0 none;outline:0 none}#wysija_popup_close{background:url(../img/popup/close.png) no-repeat;height:15px;width:15px;background-color:#333;display:block;float:right;margin:6px 10px 0 0}h2.title{height:40px;line-height:40px;margin:0 0 15px 0}h2.title span,h2.title form{float:left;margin:0 5px 0 0;vertical-align:middle}h2.title span#form-name{padding:0 3px;margin:0 10px 0 0;font-style:italic}h2.title span#form-name-default{display:none}h2.title #edit-form-name{float:left;margin:10px 5px 0 0}h2.title input{margin:0 10px 0 0}#list-selection{margin:30px 0 0 0}#list-selection label{display:block}#after-submit{margin:30px 0 0 0}#after-submit textarea{width:300px;height:50px}#form-export-links{margin:20px 0 0 0}#form-export textarea{width:100%;height:100px}#wysija_notices{z-index:20000;position:relative;left:0;top:0;padding:5px;border:1px solid #dfdfdf;border-top:0 none}#wysija_notices.notice{background-color:#FFFFE0;border-color:#E6DB55;z-index:9999}#wysija_notices.error{background-color:#FFEBE8;border-color:#CC0000}#wysija_notice_msg{font-size:14px;font-weight:bold}.expand-code{cursor:pointer}.wysija_form_block textarea{resize:none}select.chosen_select{width:642px}.search-field input{width:auto !important}.mpoet-ui .wysija_form_item_settings,.mpoet-ui .wysija_form_item_delete{text-decoration:none}.mpoet-ui .wysija_form_item_settings:hover .dashicons-admin-generic:before,.mpoet-ui .wysija_form_item_delete:hover .dashicons-dismiss:before,.mpoet-ui .settings:hover .dashicons-admin-generic:before{color:#2ea2cc}.mpoet-ui .settings span,.mpoet-ui .delete span{background:none;color:#999}.mpoet-ui .delete span:before{font-size:21px}
docs/german-disclaimer.md DELETED
@@ -1,4 +0,0 @@
1
- ### WICHTIG - HAFTUNGSAUSSCHLUSS
2
-
3
- Dieses Plugin trägt wesentlich dazu bei, Ihren Newsletter rechtssicher betreiben zu können.
4
- Es ist durch einen Rechtsanwalt geprüft worden, der ebenfalls die rechtlichen Hinweise & Muster erstellt hat. Sie entsprechen den rechtlichen Anforderungen eines typischen Newsletters. Jedoch kann die rechtliche Sicherheit eines Newsletters nur im Einzelfall geprüft und bestätigt werden, so dass insoweit keine Haftung übernommen werden kann. Daher sind auch die rechtliche Text- & Hinweismuster nur als Vorlagen zu verstehen, deren abschließende rechtliche Prüfung und ggf. Anpassung Ihnen obliegt. Falls Sie eine Prüfung Ihres Newsletters wünschen, können Sie sich an Rechtsanwalt Thomas Schwenke, LL.M. [http://rechtsanwalt-schwenke.de/kontakt](http://rechtsanwalt-schwenke.de/kontakt) wenden.
 
 
 
 
helpers/articles.php CHANGED
@@ -6,19 +6,6 @@ class WYSIJA_help_articles extends WYSIJA_object {
6
 
7
  }
8
 
9
- function stripShortcodes($content) {
10
- if(strlen(trim($content)) === 0) {
11
- return '';
12
- }
13
- // remove captions
14
- $content = preg_replace("/\[caption.*?\](.*<\/a>)(.*?)\[\/caption\]/", '$1', $content);
15
-
16
- // remove other shortcodes
17
- $content = preg_replace('/\[[^\[\]]*\]/', '', $content);
18
-
19
- return $content;
20
- }
21
-
22
  function convertPostToBlock($post, $params = array()) {
23
 
24
  // defaults
@@ -48,8 +35,8 @@ class WYSIJA_help_articles extends WYSIJA_object {
48
  if(!empty($post['post_excerpt'])) {
49
  $content = $post['post_excerpt'];
50
  } else {
51
- // strip shortcodes before getting the excerpt
52
- $post['post_content'] = $this->stripShortcodes($post['post_content']);
53
 
54
  // if excerpt is empty then try to find the "more" tag
55
  $excerpts = explode('<!--more-->', $post['post_content']);
@@ -71,8 +58,8 @@ class WYSIJA_help_articles extends WYSIJA_object {
71
  // remove images
72
  $content = preg_replace('/<img[^>]+./','', $content);
73
 
74
- // strip shortcodes
75
- $content = $this->stripShortcodes($content);
76
 
77
  // remove wysija nl shortcode
78
  $content= preg_replace('/\<div class="wysija-register">(.*?)\<\/div>/','',$content);
@@ -244,9 +231,7 @@ class WYSIJA_help_articles extends WYSIJA_object {
244
  $content = '';
245
 
246
  // get categories
247
- //$categories = get_the_category($post['ID']);
248
- $helper_wp_tools = WYSIJA::get('wp_tools', 'helper');
249
- $categories = $helper_wp_tools->get_post_categories($post);
250
 
251
  if(empty($categories) === false) {
252
  // check if the user specified a label to be displayed before the author's name
@@ -254,7 +239,13 @@ class WYSIJA_help_articles extends WYSIJA_object {
254
  $content = stripslashes($params['category_label']).' ';
255
  }
256
 
257
- $content .= join(', ', $categories);
 
 
 
 
 
 
258
  }
259
 
260
  return $content;
6
 
7
  }
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  function convertPostToBlock($post, $params = array()) {
10
 
11
  // defaults
35
  if(!empty($post['post_excerpt'])) {
36
  $content = $post['post_excerpt'];
37
  } else {
38
+ // remove shortcodes before getting the excerpt
39
+ $post['post_content'] = preg_replace('/\[[^\[\]]*\]/', '', $post['post_content']);
40
 
41
  // if excerpt is empty then try to find the "more" tag
42
  $excerpts = explode('<!--more-->', $post['post_content']);
58
  // remove images
59
  $content = preg_replace('/<img[^>]+./','', $content);
60
 
61
+ // remove shortcodes
62
+ $content = preg_replace('/\[[^\[\]]*\]/', '', $content);
63
 
64
  // remove wysija nl shortcode
65
  $content= preg_replace('/\<div class="wysija-register">(.*?)\<\/div>/','',$content);
231
  $content = '';
232
 
233
  // get categories
234
+ $categories = get_the_category($post['ID']);
 
 
235
 
236
  if(empty($categories) === false) {
237
  // check if the user specified a label to be displayed before the author's name
239
  $content = stripslashes($params['category_label']).' ';
240
  }
241
 
242
+ $category_names = array();
243
+
244
+ foreach($categories as $category) {
245
+ $category_names[] = $category->name;
246
+ }
247
+
248
+ $content .= join(', ', $category_names);
249
  }
250
 
251
  return $content;
helpers/back.php CHANGED
@@ -78,6 +78,43 @@ class WYSIJA_help_back extends WYSIJA_help{
78
  }
79
  }
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
  /**
83
  * On any of the administration pages related to MailPoet, if the user
@@ -172,43 +209,6 @@ class WYSIJA_help_back extends WYSIJA_help{
172
  }
173
  }
174
 
175
- /**
176
- * this function will check the role of the user executing the action, if it's called from another
177
- * WordPress admin page than page.php for instance admin-post.php
178
- * @return boolean
179
- */
180
- function verify_capability(){
181
- if( isset( $_GET['page'] ) && substr( $_GET['page'] ,0 ,7 ) == 'wysija_' ){
182
-
183
- switch( $_GET['page'] ){
184
- case 'wysija_campaigns':
185
- $role_needed = 'wysija_newsletters';
186
- break;
187
- case 'wysija_subscribers':
188
- $role_needed = 'wysija_subscribers';
189
- break;
190
- case 'wysija_config':
191
- $role_needed = 'wysija_config';
192
- break;
193
- case 'wysija_statistics':
194
- $role_needed = 'wysija_stats_dashboard';
195
- break;
196
- default:
197
- $role_needed = 'switch_themes';
198
- }
199
-
200
- if( current_user_can( $role_needed ) ){
201
- return true;
202
- } else{
203
- die( 'You are not allowed here.' );
204
- }
205
-
206
- }else{
207
- // this is not a wysija interface/action we can let it pass
208
- return true;
209
- }
210
- }
211
-
212
  /**
213
  * translatable strings need to be not loaded to early, this is why we put them ina separate function
214
  * @global type $wysija_installing
@@ -388,7 +388,7 @@ class WYSIJA_help_back extends WYSIJA_help{
388
  wp_enqueue_script('wysija-admin-js-global', WYSIJA_URL.'js/admin-wysija-global.js',array(),WYSIJA::get_version());
389
  $pagename=str_replace('wysija_','',$_REQUEST['page']);
390
  $backloader=WYSIJA::get('backloader','helper');
391
- $backloader->init( $this->controller );
392
 
393
  //$this->controller->jsTrans["ignoremsg"]=__('Are you sure you want to ignore this message?.',WYSIJA);
394
  $jstrans=$this->controller->jsTrans;
@@ -397,13 +397,13 @@ class WYSIJA_help_back extends WYSIJA_help{
397
  $jstrans['gopremium']=__('Go Premium!',WYSIJA);
398
 
399
  //enqueue all the scripts that have been declared in the controller
400
- $backloader->parse_js( $this->controller, $pagename, WYSIJA_URL );
401
 
402
  //this will load automatically existing scripts and stylesheets based on the page and action parameters
403
- $backloader->load_assets($pagename,WYSIJA_DIR,WYSIJA_URL,$this->controller);
404
 
405
  //add some translation
406
- $backloader->localize( $pagename, WYSIJA_DIR, WYSIJA_URL, $this->controller );
407
 
408
  // add rtl support
409
  if ( is_rtl() ) {
@@ -425,7 +425,7 @@ class WYSIJA_help_back extends WYSIJA_help{
425
  function addCodeToPagePost(){
426
 
427
  //code to add external buttons to the tmce only if the user has the rights to add the forms
428
- if(get_user_option('rich_editing') == 'true') {
429
  add_filter("mce_external_plugins", array($this,"addRichPlugin"));
430
  add_filter('mce_buttons', array($this,'addRichButton1'),999);
431
  $myStyleUrl = "../../plugins/wysija-newsletters/css/tmce/style.css";
@@ -438,16 +438,8 @@ class WYSIJA_help_back extends WYSIJA_help{
438
  }
439
 
440
  function addRichPlugin($plugin_array) {
441
- global $wp_version;
442
-
443
- if ( version_compare( $wp_version, '3.9', '<' ) ){
444
- $suffix = '';
445
- } else {
446
- $suffix = '_39';
447
- }
448
-
449
- $plugin_array['wysija_register'] = WYSIJA_URL.'mce/wysija_register/editor_plugin'.$suffix.'.js';
450
- //$plugin_array['wysija_subscribers'] = WYSIJA_URL.'mce/wysija_subscribers/editor_plugin.js';
451
 
452
  return $plugin_array;
453
  }
78
  }
79
  }
80
 
81
+ /**
82
+ * this function will check the role of the user executing the action, if it's called from another
83
+ * WordPress admin page than page.php for instance admin-post.php
84
+ * @return boolean
85
+ */
86
+ function verify_capability(){
87
+ if( isset( $_GET['page'] ) && substr( $_GET['page'] ,0 ,7 ) == 'wysija_' ){
88
+
89
+ switch( $_GET['page'] ){
90
+ case 'wysija_campaigns':
91
+ $role_needed = 'wysija_newsletters';
92
+ break;
93
+ case 'wysija_subscribers':
94
+ $role_needed = 'wysija_subscribers';
95
+ break;
96
+ case 'wysija_config':
97
+ $role_needed = 'wysija_config';
98
+ break;
99
+ case 'wysija_statistics':
100
+ $role_needed = 'wysija_stats_dashboard';
101
+ break;
102
+ default:
103
+ $role_needed = 'switch_themes';
104
+ }
105
+
106
+ if( current_user_can( $role_needed ) ){
107
+ return true;
108
+ } else{
109
+ die( 'You are not allowed here.' );
110
+ }
111
+
112
+ }else{
113
+ // this is not a wysija interface/action we can let it pass
114
+ return true;
115
+ }
116
+ }
117
+
118
 
119
  /**
120
  * On any of the administration pages related to MailPoet, if the user
209
  }
210
  }
211
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
  /**
213
  * translatable strings need to be not loaded to early, this is why we put them ina separate function
214
  * @global type $wysija_installing
388
  wp_enqueue_script('wysija-admin-js-global', WYSIJA_URL.'js/admin-wysija-global.js',array(),WYSIJA::get_version());
389
  $pagename=str_replace('wysija_','',$_REQUEST['page']);
390
  $backloader=WYSIJA::get('backloader','helper');
391
+ $backloader->initLoad($this->controller);
392
 
393
  //$this->controller->jsTrans["ignoremsg"]=__('Are you sure you want to ignore this message?.',WYSIJA);
394
  $jstrans=$this->controller->jsTrans;
397
  $jstrans['gopremium']=__('Go Premium!',WYSIJA);
398
 
399
  //enqueue all the scripts that have been declared in the controller
400
+ $backloader->jsParse($this->controller,$pagename,WYSIJA_URL);
401
 
402
  //this will load automatically existing scripts and stylesheets based on the page and action parameters
403
+ $backloader->loadScriptsStyles($pagename,WYSIJA_DIR,WYSIJA_URL,$this->controller);
404
 
405
  //add some translation
406
+ $backloader->localize($pagename,WYSIJA_DIR,WYSIJA_URL,$this->controller);
407
 
408
  // add rtl support
409
  if ( is_rtl() ) {
425
  function addCodeToPagePost(){
426
 
427
  //code to add external buttons to the tmce only if the user has the rights to add the forms
428
+ if(current_user_can('wysija_subscriwidget') && get_user_option('rich_editing') == 'true') {
429
  add_filter("mce_external_plugins", array($this,"addRichPlugin"));
430
  add_filter('mce_buttons', array($this,'addRichButton1'),999);
431
  $myStyleUrl = "../../plugins/wysija-newsletters/css/tmce/style.css";
438
  }
439
 
440
  function addRichPlugin($plugin_array) {
441
+ $plugin_array['wysija_register'] = WYSIJA_URL.'mce/wysija_register/editor_plugin.js';
442
+ $plugin_array['wysija_subscribers'] = WYSIJA_URL.'mce/wysija_subscribers/editor_plugin.js';
 
 
 
 
 
 
 
 
443
 
444
  return $plugin_array;
445
  }
helpers/backloader.php CHANGED
@@ -1,406 +1,290 @@
1
  <?php
2
- defined( 'WYSIJA' ) or die( 'Restricted access' );
 
3
 
4
  /**
5
  * class managing the admin vital part to integrate wordpress
6
  */
7
  class WYSIJA_help_backloader extends WYSIJA_help{
8
 
9
- var $jsVariables = '';
10
-
11
- function WYSIJA_help_backloader(){
12
-
13
- parent::WYSIJA_help();
14
-
15
- }
16
- /**
17
- *
18
- * @param type $controller
19
- */
20
- function init( &$controller ) {
21
- wp_enqueue_style( 'wysija-admin-css', WYSIJA_URL . 'css/admin.css', array(), WYSIJA::get_version() );
22
- wp_enqueue_script( 'wysija-admin', WYSIJA_URL . 'js/admin.js', array( 'jquery' ), true, WYSIJA::get_version() );
23
-
24
- /* default script on all wysija interfaces in admin */
25
- wp_enqueue_script( 'wysija-admin-if ', WYSIJA_URL . 'js/admin-wysija.js', array( 'jquery' ), WYSIJA::get_version() );
26
-
27
- // TO IMPROVE: This has NOTHING TO DO HERE. It has to be moved to the subscribers controller
28
- if ( ! $controller->jsTrans ) {
29
- $controller->jsTrans['selecmiss'] = __( 'Please make a selection first!', WYSIJA );
30
- $controller->jsTrans['suredelete'] = __( 'Deleting a list will not delete any subscribers.', WYSIJA );
31
- }
32
-
33
- $controller->jsTrans['sure_to_switch_package'] = __( 'Do you want to install that version?', WYSIJA );
34
- $controller->js[] = 'wysija-admin-ajax';
35
- $controller->js[] = 'thickbox';
36
- wp_enqueue_style( 'thickbox' );
37
- }
38
-
39
- /**
40
- * help to automatically loads scripts and stylesheets based on the request
41
- * @param type $pagename
42
- * @param type $dirname
43
- * @param type $urlname
44
- * @param type $controller
45
- * @param type $extension
46
- * @return type
47
- */
48
- function load_assets( $pagename, $dirname, $urlname, &$controller, $extension = 'newsletter' ) {
49
-
50
- if ( isset( $_REQUEST['action'] ) ) {
51
- $action = $_REQUEST['action'];
52
-
53
- //add form validators script for add and edit
54
- if ( ( $action == 'edit' || $action == 'add' ) && is_object( $controller ) ) {
55
- $controller->js[] = 'wysija-validator';
56
- }
57
- } else {
58
- $action = 'default';
59
-
60
- //load the listing script
61
- if ( $pagename != 'config' ) {
62
- wp_enqueue_script( 'wysija-admin-list' );
63
- }
64
- }
65
- //check for files based on this combinations of parameters pagename or pagename and action
66
- $possibleParameters = array( array( $pagename ), array( $pagename, $action ) );
67
- $enqueueFileTypes = array( 'wp_enqueue_script' => array( 'js' => 'js', 'php' => 'js' ), 'wp_enqueue_style' => array( 'css' => 'css' ) );
68
-
69
- // Files that we have, don't use file_exists if we know which files we have
70
- $files = (object) array(
71
- 'css' => array(
72
- 'add-ons',
73
- 'admin-campaigns-articles',
74
- 'admin-campaigns-autopost',
75
- 'admin-campaigns-bookmarks',
76
- 'admin-campaigns-dividers',
77
- 'admin-campaigns-editDetails',
78
- 'admin-campaigns-editTemplate',
79
- 'admin-campaigns-medias',
80
- 'admin-campaigns-themes',
81
- 'admin-campaigns-viewstats',
82
- 'admin-campaigns-welcome_new',
83
- 'admin-campaigns',
84
- 'admin-global',
85
- 'admin-premium',
86
- 'admin-statistics',
87
- 'admin-subscribers-addlist',
88
- 'admin-subscribers-edit',
89
- 'admin-subscribers-export',
90
- 'admin-subscribers-exportlist',
91
- 'admin-subscribers-import',
92
- 'admin-subscribers-importmatch',
93
- 'admin-subscribers-lists',
94
- 'admin-widget',
95
- 'admin-config',
96
- 'admin-config-form_widget_settings',
97
- ),
98
- 'js' => array(
99
- 'admin-ajax-proto',
100
- 'admin-ajax',
101
- 'admin-campaigns-articles',
102
- 'admin-campaigns-autopost',
103
- 'admin-campaigns-bookmarks',
104
- 'admin-campaigns-default',
105
- 'admin-campaigns-dividers',
106
- 'admin-campaigns-edit',
107
- 'admin-campaigns-editAutonl',
108
- 'admin-campaigns-editDetails',
109
- 'admin-campaigns-editTemplate',
110
- 'admin-campaigns-image_data',
111
- 'admin-campaigns-medias',
112
- 'admin-campaigns-themes',
113
- 'admin-campaigns-viewstats',
114
- 'admin-campaigns-welcome_new',
115
- 'admin-config-form_widget_settings',
116
- 'admin-config-settings',
117
- 'admin-global',
118
- 'admin-listing',
119
- 'admin-statistics-filter',
120
- 'admin-statistics',
121
- 'admin-subscribers-edit-manual',
122
- 'admin-subscribers-export',
123
- 'admin-subscribers-import',
124
- 'admin-subscribers-importmatch',
125
- 'admin-subscribers',
126
- 'admin-tmce',
127
- 'admin-wysija-global',
128
- 'admin-wysija',
129
- )
130
- );
131
-
132
- foreach ( $possibleParameters as $params ) {
133
- foreach ( $enqueueFileTypes as $method => $types ) {
134
- foreach ( $types as $file_type => $file_ext ){
135
- $file_slug = 'admin-' . implode( '-', $params );
136
- if ( in_array( $file_slug, $files->{ $file_ext } ) ) {
137
- $file_id = "wysija-autoinc-{$extension}-{$file_slug}-{$file_ext}";
138
- $file_url = "{$urlname}{$file_ext}/{$file_slug}.{$file_ext}";
139
- call_user_func_array( $method, array( $file_id, $file_url, array(), WYSIJA::get_version() ) );
140
- }
141
- }
142
- }
143
- }
144
-
145
- return true;
146
- }
147
-
148
- /**
149
- * enqueue and load dif ferent scripts and style based on one script being requested in the controller
150
- * @param type $controller
151
- * @param type $pagename
152
- * @param string $urlbase
153
- */
154
- function parse_js( &$controller, $pagename, $urlbase = WYSIJA_URL ){
155
-
156
- // find out the name of the plugin based on the urlbase parameter
157
- $plugin = substr( strrchr( substr( $urlbase, 0, strlen( $urlbase ) - 1 ), '/' ), 1 );
158
-
159
- /* enqueue all the scripts that have been declared in the controller */
160
- if ( $controller->js ) {
161
- foreach ( $controller->js as $kjs => $js ) {
162
- switch ( $js ) {
163
- case 'jquery-ui-tabs':
164
- wp_enqueue_script( $js );
165
- wp_enqueue_style( 'wysija-tabs-css', WYSIJA_URL . 'css/smoothness/jquery-ui-1.8.20.custom.css', array(), WYSIJA::get_version() );
166
- break;
167
-
168
- case 'wysija-validator':
169
- wp_enqueue_script( 'wysija-validator-lang' );
170
- wp_enqueue_script( $js );
171
- wp_enqueue_script( 'wysija-form' );
172
- wp_enqueue_style( 'validate-engine-css' );
173
- break;
174
-
175
- case 'wysija-admin-ajax':
176
- if ( $plugin != 'wysija-newsletters' ){
177
- $ajaxvarname = $plugin;
178
- } else {
179
- $ajaxvarname = 'wysija';
180
- }
181
-
182
- $dataajaxxx = array(
183
- 'action' => 'wysija_ajax',
184
- 'controller' => $pagename,
185
- 'wysijaplugin' => $plugin,
186
- 'dataType' => 'json',
187
- 'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ),
188
- // 'ajaxurl' => plugins_url( 'wysija-newsletters' ).'/core/ajax.php',
189
- 'pluginurl' => plugins_url( 'wysija-newsletters' ),
190
- 'loadingTrans' => __( 'Loading...', WYSIJA )
191
- );
192
-
193
- if ( is_user_logged_in() ){
194
- $dataajaxxx['adminurl'] = admin_url( 'admin.php' );
195
- }
196
-
197
- wp_localize_script( 'wysija-admin-ajax', $ajaxvarname.'AJAX',$dataajaxxx );
198
- wp_enqueue_script( 'jquery-ui-dialog' );
199
- wp_enqueue_script( $js );
200
- wp_enqueue_style( 'wysija-tabs-css', WYSIJA_URL . 'css/smoothness/jquery-ui-1.8.20.custom.css', array(), WYSIJA::get_version() );
201
- break;
202
-
203
- case 'wysija-admin-ajax-proto':
204
- wp_enqueue_script( $js );
205
- break;
206
-
207
- case 'wysija-edit-autonl':
208
- wp_enqueue_script( 'wysija-edit-autonl', WYSIJA_URL . 'js/admin-campaigns-editAutonl.js', array( 'jquery' ), WYSIJA::get_version() );
209
- break;
210
-
211
- case 'wysija-scriptaculous':
212
- // include prototypeJS + scriptaculous & addons
213
- wp_enqueue_script( 'wysija-prototype', WYSIJA_URL . 'js/prototype/prototype.js', array(), WYSIJA::get_version() );
214
- wp_enqueue_script( 'wysija-proto-scriptaculous', WYSIJA_URL . 'js/prototype/scriptaculous.js', array( 'wysija-prototype' ), WYSIJA::get_version() );
215
- wp_enqueue_script( 'wysija-proto-dragdrop', WYSIJA_URL . 'js/prototype/dragdrop.js', array( 'wysija-proto-scriptaculous' ), WYSIJA::get_version() );
216
- wp_enqueue_script( 'wysija-proto-controls', WYSIJA_URL . 'js/prototype/controls.js', array( 'wysija-proto-scriptaculous' ), WYSIJA::get_version() );
217
- wp_enqueue_script( 'wysija-proto-slider', WYSIJA_URL . 'js/prototype/slider.js', array( 'wysija-proto-scriptaculous' ), WYSIJA::get_version() );
218
- break;
219
-
220
- case 'mailpoet-select2':
221
-
222
- wp_enqueue_script( 'mailpoet-select2', WYSIJA_URL . 'js/select2/select2.min.js', array( 'jquery' ), WYSIJA::get_version() );
223
- wp_enqueue_script( 'mailpoet-select2-l10n', WYSIJA_URL . 'js/select2/select2-l10n.js', array( 'mailpoet-select2', 'underscore' ), WYSIJA::get_version() );
224
-
225
- wp_enqueue_style( 'mailpoet-select2', WYSIJA_URL . 'css/select2/select2.css', array(), WYSIJA::get_version() );
226
-
227
- wp_localize_script(
228
- 'mailpoet-select2-l10n',
229
- 'mailpoet_l10n_select2',
230
- array(
231
- 'noMatches' => __( 'No Results were found', WYSIJA ),
232
- 'inputTooShort' => __( 'Please enter <%= chars %> more character<%= plural %>', WYSIJA ),
233
- 'inputTooLong' => __( 'Please delete <%= chars %> character<%= plural %>', WYSIJA ),
234
- 'selectionTooBig' => __( 'You can only select <%= chars %> item<%= plural %>', WYSIJA ),
235
- 'loadMore' => __( 'Loading more Results...', WYSIJA ),
236
- 'searching' => __( 'Searching...', WYSIJA ),
237
- )
238
- );
239
-
240
- break;
241
-
242
- case 'wysija-form-editor':
243
- wp_enqueue_script( 'wysija-prototype', WYSIJA_URL . 'js/prototype/prototype.js', array(), WYSIJA::get_version() );
244
- wp_enqueue_script( 'wysija-proto-scriptaculous', WYSIJA_URL . 'js/prototype/scriptaculous.js', array( 'wysija-prototype' ), WYSIJA::get_version() );
245
- wp_enqueue_script( 'wysija-proto-dragdrop', WYSIJA_URL . 'js/prototype/dragdrop.js', array( 'wysija-proto-scriptaculous' ), WYSIJA::get_version() );
246
- wp_enqueue_script( 'wysija-proto-controls', WYSIJA_URL . 'js/prototype/controls.js', array( 'wysija-proto-scriptaculous' ), WYSIJA::get_version() );
247
- wp_enqueue_script( 'wysija-proto-slider', WYSIJA_URL . 'js/prototype/slider.js', array( 'wysija-proto-scriptaculous' ), WYSIJA::get_version() );
248
-
249
- // include form editor
250
- wp_enqueue_script( $js, WYSIJA_URL . 'js/' . $js . '.js', array(), WYSIJA::get_version() );
251
-
252
- /* MailPoet form editor i18n */
253
- wp_localize_script( 'wysija-form-editor', 'Wysija_i18n', $controller->jsTrans );
254
-
255
- // form editor css
256
- wp_enqueue_style( 'wysija-form-editor-css', WYSIJA_URL . 'css/wysija-form-editor.css', array(), WYSIJA::get_version() );
257
- break;
258
-
259
- case 'wysija-amcharts':
260
- // MailPoet chart
261
- wp_enqueue_script( 'amcharts', WYSIJA_URL . 'js/amcharts/amcharts.js', array(), WYSIJA::get_version() );
262
- wp_enqueue_script( 'wysija-amcharts', WYSIJA_URL . 'js/wysija-charts.js', array(), WYSIJA::get_version() );
263
- break;
264
-
265
- case 'wysija-editor':
266
-
267
- wp_enqueue_script( 'wysija-prototype', WYSIJA_URL . 'js/prototype/prototype.js', array(), WYSIJA::get_version() );
268
- wp_deregister_script( 'thickbox' );
269
-
270
- wp_register_script( 'thickbox', WYSIJA_URL . 'js/thickbox/thickbox.js', array( 'jquery' ), WYSIJA::get_version() );
271
-
272
- wp_localize_script(
273
- 'thickbox',
274
- 'thickboxL10n',
275
- array(
276
- 'next' => __( 'Next &gt;' ),
277
- 'prev' => __( '&lt; Prev' ),
278
- 'image' => __( 'Image' ),
279
- 'of' => __( 'of' ),
280
- 'close' => __( 'Close' ),
281
- 'noif rames' => __( 'This feature requires inline frames. You have iframes disabled or your browser does not support them.' ),
282
- 'l10n_print_after' => 'try{convertEntities( thickboxL10n );}catch( e ){};',
283
- )
284
- );
285
-
286
- wp_enqueue_script( 'wysija-proto-scriptaculous', WYSIJA_URL . 'js/prototype/scriptaculous.js' , array( 'wysija-prototype' ), WYSIJA::get_version() );
287
- wp_enqueue_script( 'wysija-proto-dragdrop', WYSIJA_URL . 'js/prototype/dragdrop.js', array( 'wysija-proto-scriptaculous' ), WYSIJA::get_version() );
288
- wp_enqueue_script( 'wysija-proto-controls', WYSIJA_URL . 'js/prototype/controls.js', array( 'wysija-proto-scriptaculous' ), WYSIJA::get_version() );
289
- wp_enqueue_script( 'wysija-timer', WYSIJA_URL . 'js/timer.js', array(), WYSIJA::get_version() );
290
- wp_enqueue_script( $js, WYSIJA_URL . 'js/' . $js . '.js', array(), WYSIJA::get_version() );
291
- wp_enqueue_script( 'wysija-konami', WYSIJA_URL . 'js/konami.js', array(), WYSIJA::get_version() );
292
- wp_enqueue_script( 'wysija-tinymce', WYSIJA_URL . 'js/tinymce/tiny_mce.js', array(), WYSIJA::get_version() );
293
-
294
- wp_enqueue_script( 'wysija-tinymce-init', WYSIJA_URL . 'js/tinymce_init.js', array(), WYSIJA::get_version() );
295
- wp_enqueue_style( 'wysija-editor-css', WYSIJA_URL . 'css/wysija-editor.css', array(), WYSIJA::get_version() );
296
- wp_enqueue_script( 'wysija-colorpicker', WYSIJA_URL . 'js/excolor/jquery.modcoder.excolor.js', array(), WYSIJA::get_version() );
297
-
298
- if ( version_compare( $GLOBALS['wp_version'], '3.9', '>=' ) ){
299
- wp_enqueue_style( 'mailpoet-tinymce', WYSIJA_URL . 'css/tmce/editor.css', array(), WYSIJA::get_version() );
300
- }
301
-
302
- /* MailPoet editor i18n */
303
- wp_localize_script( 'wysija-editor', 'Wysija_i18n', $controller->jsTrans );
304
- break;
305
-
306
- case 'wysija-colorpicker':
307
- wp_enqueue_script( 'wysija-colorpicker', WYSIJA_URL . 'js/excolor/jquery.modcoder.excolor.js', array(), WYSIJA::get_version() );
308
- break;
309
-
310
- case 'wysija-tooltip':
311
- wp_enqueue_script( 'mailpoet.tooltip', WYSIJA_URL . 'js/vendor/bootstrap.tooltip.js', array( 'jquery' ), WYSIJA::get_version(), true );
312
- wp_enqueue_style( 'mailpoet.tooltip', WYSIJA_URL . 'css/vendor/bootstrap.tooltip.css', array(), WYSIJA::get_version(), 'screen' );
313
- break;
314
-
315
- default:
316
- if ( is_string( $kjs ) ) {
317
- // check if there's a trailing slash in the urlbase
318
- if ( substr( $urlbase, -1 ) !== '/' ){
319
- $urlbase .= '/';
320
- }
321
- // check if there's already an extension specif ied for the file
322
- if ( substr( $urlbase, -3 ) !== '.js' ){
323
- $js .= '.js';
324
- }
325
- // enqueue script
326
-
327
- wp_enqueue_script( $kjs, $urlbase . 'js/' . $js, array(), WYSIJA::get_version() );
328
- } else {
329
- wp_enqueue_script( $js );
330
- }
331
- }
332
- }
333
- }
334
- }
335
-
336
- /**
337
- * add some js defined variable per script
338
- * @param type $pagename
339
- * @param type $dirname
340
- * @param type $urlname
341
- * @param type $controller
342
- * @param type $extension
343
- */
344
- function localize( $pagename, $dirname, $urlname, &$controller, $extension = 'newsletter' ){
345
- if ( $controller->jsLoc ){
346
- foreach ( $controller->jsLoc as $key => $value ){
347
- foreach ( $value as $kf => $local ){
348
-
349
- //this function accepts multidimensional array some version like wp3.2.1 couldn't do that
350
- $this->localizeme( $key, $kf, $local );
351
- }
352
- }
353
- }
354
- }
355
-
356
- /**
357
- * multidimensional array are possible here
358
- * @param type $handle
359
- * @param type $object_name
360
- * @param type $l10n
361
- */
362
- function localizeme( $handle, $object_name, $l10n ) {
363
-
364
- foreach ( ( array ) $l10n as $key => $value ) {
365
- if ( ! is_scalar( $value ) ){
366
- continue;
367
- }
368
- $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
369
- }
370
-
371
- $this->jsVariables .= "var $object_name = " . json_encode( $l10n ) . ';';
372
- add_action( 'admin_head', array( $this, 'localize_print' ) );
373
- }
374
-
375
- /**
376
- * load the variables in the html
377
- */
378
- function localize_print(){
379
- echo "<script type='text/javascript' id='mailpoet-localized'>\n"; // CDATA and type='text/javascript' is not needed for HTML 5
380
- echo "/* <![CDATA[ */\n";
381
- echo esc_attr( '' ) . $this->jsVariables . "\n"; // To comply with PHP Code Sniffer WordPress Standards before we "hack" the echo
382
- echo "/* ]]> */\n";
383
- echo "</script>\n";
384
- }
385
-
386
-
387
-
388
- /**
389
- * this is for backward compatibility and avoid blank screen on older version of the premium plugin
390
- */
391
- function loadScriptsStyles( $pagename, $dirname, $urlname, &$controller, $extension = 'newsletter' ) {
392
- return $this->load_assets( $pagename, $dirname, $urlname, $controller, $extension );
393
- }
394
-
395
- /**
396
- * this is for backward compatibility and avoid blank screen on older version of the premium plugin
397
- */
398
- function initLoad( &$controller ){
399
- return $this->init( $controller );
400
- }
401
-
402
- function jsParse( &$controller, $pagename, $urlbase = WYSIJA_URL ){
403
- $this->parse_js( $controller, $pagename, $urlbase );
404
- }
405
 
406
  }
 
 
 
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
+
4
 
5
  /**
6
  * class managing the admin vital part to integrate wordpress
7
  */
8
  class WYSIJA_help_backloader extends WYSIJA_help{
9
 
10
+ var $jsVariables='';
11
+ function WYSIJA_help_backloader(){
12
+
13
+ parent::WYSIJA_help();
14
+
15
+ }
16
+ /**
17
+ *
18
+ * @param type $controller
19
+ */
20
+ function initLoad(&$controller){
21
+ wp_enqueue_style('wysija-admin-css', WYSIJA_URL.'css/admin.css',array(),WYSIJA::get_version());
22
+ wp_enqueue_script('wysija-admin', WYSIJA_URL.'js/admin.js', array( 'jquery' ), true, WYSIJA::get_version());
23
+ /* default script on all wysija interfaces in admin */
24
+ wp_enqueue_script('wysija-admin-if', WYSIJA_URL.'js/admin-wysija.js', array( 'jquery' ),WYSIJA::get_version());
25
+
26
+
27
+ // TO IMPROVE: This has NOTHING TO DO HERE. It has to be moved to the subscribers controller
28
+ if(!$controller->jsTrans){
29
+ $controller->jsTrans['selecmiss']=__('Please make a selection first!',WYSIJA);
30
+ $controller->jsTrans['suredelete']=__('Deleting a list will not delete any subscribers.',WYSIJA);
31
+
32
+
33
+ }
34
+ $controller->jsTrans['sure_to_switch_package']=__('Do you want to install that version?',WYSIJA);
35
+ $controller->js[]='wysija-admin-ajax';
36
+ $controller->js[]='thickbox';
37
+ wp_enqueue_style( 'thickbox' );
38
+ }
39
+
40
+ /**
41
+ * help to automatically loads scripts and stylesheets based on the request
42
+ * @param type $pagename
43
+ * @param type $dirname
44
+ * @param type $urlname
45
+ * @param type $controller
46
+ * @param type $extension
47
+ * @return type
48
+ */
49
+ function loadScriptsStyles($pagename,$dirname,$urlname,&$controller,$extension='newsletter') {
50
+
51
+ if(isset($_REQUEST['action'])){
52
+ $action=$_REQUEST['action'];
53
+
54
+ //add form validators script for add and edit
55
+ if(($action=='edit' || $action=='add') && is_object($controller)){
56
+ $controller->js[]='wysija-validator';
57
+ }
58
+
59
+ }else{
60
+ $action='default';
61
+ //load the listing script
62
+ if($pagename!='config') wp_enqueue_script('wysija-admin-list');
63
+ }
64
+ //check for files based on this combinations of parameters pagename or pagename and action
65
+ $possibleParameters=array(array($pagename),array($pagename,$action));
66
+ $enqueueFileTypes=array('wp_enqueue_script'=>array('js'=>'js','php'=>'js'),'wp_enqueue_style'=>array('css'=>'css'));
67
+
68
+ foreach($possibleParameters as $params){
69
+ foreach($enqueueFileTypes as $wayToInclude =>$fileTypes){
70
+ foreach($fileTypes as $fileType=>$folderLocation){
71
+ if(file_exists($dirname.$folderLocation.DS.'admin-'.implode('-', $params).'.'.$fileType)){
72
+ $sourceIdentifier='wysija-autoinc-'.$extension.'-admin-'.implode('-', $params).'-'.$fileType;
73
+ $sourceUrl=$urlname.$folderLocation.'/admin-'.implode('-', $params).'.'.$fileType;
74
+ call_user_func_array($wayToInclude, array($sourceIdentifier,$sourceUrl,array(),WYSIJA::get_version()));
75
+ }
76
+ }
77
+ }
78
+ }
79
+
80
+ return true;
81
+ }
82
+
83
+ /**
84
+ * enqueu and load different scripts and style based on one script being requested in the controller
85
+ * @param type $controller
86
+ * @param type $pagename
87
+ * @param string $urlbase
88
+ */
89
+ function jsParse(&$controller,$pagename,$urlbase=WYSIJA_URL){
90
+
91
+ // find out the name of the plugin based on the urlbase parameter
92
+ $plugin = substr(strrchr(substr($urlbase, 0, strlen($urlbase)-1), '/'), 1);
93
+
94
+ /* enqueue all the scripts that have been declared in the controller */
95
+ if($controller->js){
96
+ foreach($controller->js as $kjs=> $js){
97
+ switch($js){
98
+ case 'jquery-ui-tabs':
99
+ wp_enqueue_script($js);
100
+ wp_enqueue_style('wysija-tabs-css', WYSIJA_URL."css/smoothness/jquery-ui-1.8.20.custom.css",array(),WYSIJA::get_version());
101
+ break;
102
+ case 'wysija-validator':
103
+ wp_enqueue_script('wysija-validator-lang');
104
+ wp_enqueue_script($js);
105
+ wp_enqueue_script('wysija-form');
106
+ wp_enqueue_style('validate-engine-css');
107
+ break;
108
+ case 'wysija-admin-ajax':
109
+ if($plugin!='wysija-newsletters') $ajaxvarname=$plugin;
110
+ else $ajaxvarname='wysija';
111
+
112
+ $dataajaxxx=array(
113
+ 'action' => 'wysija_ajax',
114
+ 'controller' => $pagename,
115
+ 'wysijaplugin' => $plugin,
116
+ 'dataType'=>"json",
117
+ 'ajaxurl'=>admin_url( 'admin-ajax.php', 'relative' ),
118
+ // 'ajaxurl'=>plugins_url( 'wysija-newsletters' ).'/core/ajax.php',
119
+ 'pluginurl'=>plugins_url( 'wysija-newsletters' ),
120
+ 'loadingTrans' =>__('Loading...',WYSIJA)
121
+ );
122
+
123
+ if(is_user_logged_in()){
124
+ $dataajaxxx['adminurl']=admin_url( 'admin.php' );
125
+ }
126
+
127
+ wp_localize_script( 'wysija-admin-ajax', $ajaxvarname.'AJAX',$dataajaxxx );
128
+ wp_enqueue_script('jquery-ui-dialog');
129
+ wp_enqueue_script($js);
130
+ wp_enqueue_style('wysija-tabs-css', WYSIJA_URL.'css/smoothness/jquery-ui-1.8.20.custom.css',array(),WYSIJA::get_version());
131
+ break;
132
+ case 'wysija-admin-ajax-proto':
133
+ wp_enqueue_script($js);
134
+ break;
135
+ case 'wysija-edit-autonl':
136
+ wp_enqueue_script('wysija-edit-autonl', WYSIJA_URL.'js/admin-campaigns-editAutonl.js',array('jquery'),WYSIJA::get_version());
137
+ break;
138
+ case 'wysija-scriptaculous':
139
+ // include prototypeJS + scriptaculous & addons
140
+ wp_enqueue_script('wysija-prototype', WYSIJA_URL.'js/prototype/prototype.js', array(), WYSIJA::get_version());
141
+ wp_enqueue_script('wysija-proto-scriptaculous', WYSIJA_URL.'js/prototype/scriptaculous.js', array('wysija-prototype'), WYSIJA::get_version());
142
+ wp_enqueue_script('wysija-proto-dragdrop', WYSIJA_URL.'js/prototype/dragdrop.js', array('wysija-proto-scriptaculous'), WYSIJA::get_version());
143
+ wp_enqueue_script('wysija-proto-controls', WYSIJA_URL.'js/prototype/controls.js', array('wysija-proto-scriptaculous'), WYSIJA::get_version());
144
+ wp_enqueue_script('wysija-proto-slider', WYSIJA_URL.'js/prototype/slider.js', array('wysija-proto-scriptaculous'), WYSIJA::get_version());
145
+ break;
146
+ case 'wysija-chosen-proto':
147
+ // chosen library
148
+ wp_enqueue_script('wysija-proto-chosen', WYSIJA_URL.'js/chosen/chosen.proto.min.js', array('wysija-prototype'), WYSIJA::get_version());
149
+ // chosen styles
150
+ wp_enqueue_style('wysija-chosen-styles', WYSIJA_URL.'js/chosen/chosen.min.css', array(), WYSIJA::get_version());
151
+ break;
152
+ case 'wysija-chosen-jquery':
153
+ // chosen library
154
+ wp_enqueue_script('wysija-chosen', WYSIJA_URL.'js/chosen/chosen.jquery.min.js', array('jquery'), WYSIJA::get_version());
155
+ // chosen styles
156
+ wp_enqueue_style('wysija-chosen-styles', WYSIJA_URL.'js/chosen/chosen.min.css', array(), WYSIJA::get_version());
157
+ break;
158
+ case 'wysija-form-editor':
159
+ wp_enqueue_script('wysija-prototype', WYSIJA_URL.'js/prototype/prototype.js',array(),WYSIJA::get_version());
160
+ wp_enqueue_script('wysija-proto-scriptaculous', WYSIJA_URL.'js/prototype/scriptaculous.js',array('wysija-prototype'),WYSIJA::get_version());
161
+ wp_enqueue_script('wysija-proto-dragdrop', WYSIJA_URL.'js/prototype/dragdrop.js',array('wysija-proto-scriptaculous'),WYSIJA::get_version());
162
+ wp_enqueue_script('wysija-proto-controls', WYSIJA_URL.'js/prototype/controls.js',array('wysija-proto-scriptaculous'),WYSIJA::get_version());
163
+ wp_enqueue_script('wysija-proto-slider', WYSIJA_URL.'js/prototype/slider.js',array('wysija-proto-scriptaculous'),WYSIJA::get_version());
164
+
165
+ // include form editor
166
+ wp_enqueue_script($js, WYSIJA_URL.'js/'.$js.'.js', array(), WYSIJA::get_version());
167
+
168
+ /* MailPoet form editor i18n */
169
+ wp_localize_script('wysija-form-editor', 'Wysija_i18n', $controller->jsTrans);
170
+
171
+ // form editor css
172
+ wp_enqueue_style('wysija-form-editor-css', WYSIJA_URL."css/wysija-form-editor.css",array(),WYSIJA::get_version());
173
+ break;
174
+ case 'wysija-amcharts':
175
+ // MailPoet chart
176
+ wp_enqueue_script("amcharts", WYSIJA_URL."js/amcharts/amcharts.js",array(),WYSIJA::get_version());
177
+ wp_enqueue_script("wysija-amcharts", WYSIJA_URL."js/wysija-charts.js",array(),WYSIJA::get_version());
178
+ break;
179
+ case 'wysija-editor':
180
+
181
+ wp_enqueue_script("wysija-prototype", WYSIJA_URL."js/prototype/prototype.js",array(),WYSIJA::get_version());
182
+ wp_deregister_script('thickbox');
183
+
184
+ wp_register_script('thickbox',WYSIJA_URL.'js/thickbox/thickbox.js',array('jquery'),WYSIJA::get_version());
185
+
186
+ wp_localize_script('thickbox', 'thickboxL10n', array(
187
+ 'next' => __('Next &gt;'),
188
+ 'prev' => __('&lt; Prev'),
189
+ 'image' => __('Image'),
190
+ 'of' => __('of'),
191
+ 'close' => __('Close'),
192
+ 'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'),
193
+ 'l10n_print_after' => 'try{convertEntities(thickboxL10n);}catch(e){};'
194
+ ));
195
+
196
+ wp_enqueue_script("wysija-proto-scriptaculous", WYSIJA_URL."js/prototype/scriptaculous.js",array("wysija-prototype"),WYSIJA::get_version());
197
+ wp_enqueue_script("wysija-proto-dragdrop", WYSIJA_URL."js/prototype/dragdrop.js",array("wysija-proto-scriptaculous"),WYSIJA::get_version());
198
+ wp_enqueue_script("wysija-proto-controls", WYSIJA_URL."js/prototype/controls.js",array("wysija-proto-scriptaculous"),WYSIJA::get_version());
199
+ wp_enqueue_script("wysija-timer", WYSIJA_URL."js/timer.js",array(),WYSIJA::get_version());
200
+ wp_enqueue_script($js, WYSIJA_URL."js/".$js.".js",array(),WYSIJA::get_version());
201
+ wp_enqueue_script('wysija-konami', WYSIJA_URL."js/konami.js",array(),WYSIJA::get_version());
202
+ wp_enqueue_script('wysija-tinymce', WYSIJA_URL."js/tinymce/tiny_mce.js",array(),WYSIJA::get_version());
203
+
204
+ wp_enqueue_script('wysija-tinymce-init', WYSIJA_URL."js/tinymce_init.js",array(),WYSIJA::get_version());
205
+ wp_enqueue_style('wysija-editor-css', WYSIJA_URL."css/wysija-editor.css",array(),WYSIJA::get_version());
206
+ wp_enqueue_script('wysija-colorpicker', WYSIJA_URL."js/excolor/jquery.modcoder.excolor.js",array(),WYSIJA::get_version());
207
+
208
+ /* MailPoet editor i18n */
209
+ wp_localize_script('wysija-editor', 'Wysija_i18n', $controller->jsTrans);
210
+ break;
211
+ case 'wysija-colorpicker':
212
+ wp_enqueue_script('wysija-colorpicker', WYSIJA_URL."js/excolor/jquery.modcoder.excolor.js",array(),WYSIJA::get_version());
213
+ break;
214
+ case 'wysija-tooltip':
215
+ wp_enqueue_script( 'jquery-qtip', WYSIJA_URL.'js/qtip2/jquery.qtip.min.js', array('jquery'), WYSIJA::get_version());
216
+ wp_enqueue_style('jquery-qtip-css', WYSIJA_URL.'css/qtip2/jquery.qtip.min.css');
217
+ break;
218
+ default:
219
+ if(is_string($kjs)) {
220
+ // check if there's a trailing slash in the urlbase
221
+ if(substr($urlbase, -1) !== '/') $urlbase .= '/';
222
+ // check if there's already an extension specified for the file
223
+ if(substr($urlbase, -3) !== '.js') $js .= '.js';
224
+ // enqueue script
225
+
226
+ wp_enqueue_script($kjs, $urlbase.'js/'.$js,array(),WYSIJA::get_version());
227
+ } else {
228
+ wp_enqueue_script($js);
229
+ }
230
+ }
231
+
232
+ }
233
+ }
234
+
235
+
236
+ }
237
+
238
+ /**
239
+ * add some js defined variable per script
240
+ * @param type $pagename
241
+ * @param type $dirname
242
+ * @param type $urlname
243
+ * @param type $controller
244
+ * @param type $extension
245
+ */
246
+ function localize($pagename,$dirname,$urlname,&$controller,$extension="newsletter"){
247
+ if($controller->jsLoc){
248
+ foreach($controller->jsLoc as $key =>$value){
249
+ foreach($value as $kf => $local){
250
+
251
+ //this function accepts multidimensional array some version like wp3.2.1 couldn't do that
252
+ $this->localizeme($key, $kf, $local);
253
+ }
254
+ }
255
+ }
256
+ }
257
+
258
+ /**
259
+ * multidimensional array are possible here
260
+ * @param type $handle
261
+ * @param type $object_name
262
+ * @param type $l10n
263
+ */
264
+ function localizeme( $handle, $object_name, $l10n ) {
265
+
266
+ foreach ( (array) $l10n as $key => $value ) {
267
+ if ( !is_scalar($value) )
268
+ continue;
269
+ $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
270
+ }
271
+
272
+ $this->jsVariables.= "var $object_name = " . json_encode($l10n) . ';';
273
+ add_action('admin_head',array($this,'printAdminLocalized'));
274
+ }
275
+
276
+ /**
277
+ * load the variables in the html
278
+ */
279
+ function printAdminLocalized(){
280
+ echo "<script type='text/javascript'>\n"; // CDATA and type='text/javascript' is not needed for HTML 5
281
+ echo "/* <![CDATA[ */\n";
282
+ echo $this->jsVariables."\n";
283
+ echo "/* ]]> */\n";
284
+ echo "</script>\n";
285
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
 
287
  }
288
+
289
+
290
+
helpers/bounce.php CHANGED
@@ -543,6 +543,7 @@ class WYSIJA_help_bounce extends WYSIJA_help {
543
  }
544
 
545
  if (isset($one_rule['action_user']) && in_array($one_rule['action_user'], array('unsub'))) {
 
546
  if (empty($this->_message->subemail)) {
547
  $currentUser = $this->subClass->getObject($this->_message->user_id);
548
  if (!empty($currentUser->email))
@@ -1083,7 +1084,7 @@ class WYSIJA_help_bounce extends WYSIJA_help {
1083
  if(!empty($result_subscriber[0]->email)){
1084
  $main_site_prefix = $this->subClass->get_site_prefix();
1085
  $query_insert_bounce_ms = 'INSERT IGNORE INTO `'.$main_site_prefix.'bounce` (`email`,`site_id`,`user_id`,`email_id`,`action_taken`,`case`,`message`,`created_at`)';
1086
- $query_insert_bounce_ms .= " VALUES ('".$result_subscriber[0]->email."','".(int)$this->_message->site_id."','".(int)$this->_message->user_id."','".(int)$this->_message->email_id."','".$action_taken."', '".$one_rule['key']."', '". esc_sql($email_copy)."', '".time()."')";
1087
 
1088
  $this->subClass->query($query_insert_bounce_ms);
1089
  }
543
  }
544
 
545
  if (isset($one_rule['action_user']) && in_array($one_rule['action_user'], array('unsub'))) {
546
+ $status = $this->subClass->getSubscriptionStatus($this->_message->user_id);
547
  if (empty($this->_message->subemail)) {
548
  $currentUser = $this->subClass->getObject($this->_message->user_id);
549
  if (!empty($currentUser->email))
1084
  if(!empty($result_subscriber[0]->email)){
1085
  $main_site_prefix = $this->subClass->get_site_prefix();
1086
  $query_insert_bounce_ms = 'INSERT IGNORE INTO `'.$main_site_prefix.'bounce` (`email`,`site_id`,`user_id`,`email_id`,`action_taken`,`case`,`message`,`created_at`)';
1087
+ $query_insert_bounce_ms .= " VALUES ('".$result_subscriber[0]->email."','".(int)$this->_message->site_id."','".(int)$this->_message->user_id."','".(int)$this->_message->email_id."','".$action_taken."', '".$one_rule['key']."', '". mysql_real_escape_string($email_copy)."', '".time()."')";
1088
 
1089
  $this->subClass->query($query_insert_bounce_ms);
1090
  }
helpers/campaigns.php CHANGED
@@ -1,52 +1,48 @@
1
  <?php
2
-
3
- /*
4
- add_action( 'wp_ajax_mailpoet.search_terms', 'WYSIJA_help_campaigns::ajax_search_terms' );
5
-
6
-
7
- */
8
  defined('WYSIJA') or die('Restricted access');
9
  class WYSIJA_help_campaigns extends WYSIJA_object{
10
- function WYSIJA_help_campaigns(){
11
-
12
- }
13
-
14
- function saveParameters($email_id, $key, $value)
15
- {
16
- // 1. get params field for given campaign
17
- $modelEmail = WYSIJA::get('email', 'model');
18
- $email = $modelEmail->getOne('params', array('email_id' => $email_id));
19
- $params = $email['params'];
20
-
21
- if(!is_array($params)) {
22
- $params = array();
23
- }
24
-
25
- // 2 update data for given key
26
- if(array_key_exists($key, $params)) {
27
- $params[$key] = $value;
28
- } else {
29
- $params = array_merge($params, array($key => $value));
30
- }
31
-
32
- // 3. update campaign
33
- return $modelEmail->update(array('params' => $params), array('email_id' => $email_id));
34
- }
35
-
36
- function getParameters($email_id, $key = null) {
37
- // 1. get params field for given campaign
38
- $modelEmail = WYSIJA::get('email', 'model');
39
- $email = $modelEmail->getOne('params', array('email_id' => $email_id));
40
- $params = $email['params'];
41
-
42
- if($key === null) {
43
- return $params;
44
- } else {
45
- if(!is_array($params) or array_key_exists($key, $params) === false) {
46
- return false;
47
- } else {
48
- return $params[$key];
49
- }
50
- }
51
- }
 
 
52
  }
1
  <?php
 
 
 
 
 
 
2
  defined('WYSIJA') or die('Restricted access');
3
  class WYSIJA_help_campaigns extends WYSIJA_object{
4
+
5
+
6
+ function WYSIJA_help_campaigns(){
7
+
8
+ }
9
+
10
+ function saveParameters($email_id, $key, $value)
11
+ {
12
+ // 1. get params field for given campaign
13
+ $modelEmail = WYSIJA::get('email', 'model');
14
+ $email = $modelEmail->getOne('params', array('email_id' => $email_id));
15
+ $params = $email['params'];
16
+
17
+ if(!is_array($params)) {
18
+ $params = array();
19
+ }
20
+
21
+ // 2 update data for given key
22
+ if(array_key_exists($key, $params)) {
23
+ $params[$key] = $value;
24
+ } else {
25
+ $params = array_merge($params, array($key => $value));
26
+ }
27
+
28
+ // 3. update campaign
29
+ return $modelEmail->update(array('params' => $params), array('email_id' => $email_id));
30
+ }
31
+
32
+ function getParameters($email_id, $key = null) {
33
+ // 1. get params field for given campaign
34
+ $modelEmail = WYSIJA::get('email', 'model');
35
+ $email = $modelEmail->getOne('params', array('email_id' => $email_id));
36
+ $params = $email['params'];
37
+
38
+ if($key === null) {
39
+ return $params;
40
+ } else {
41
+ if(!is_array($params) or array_key_exists($key, $params) === false) {
42
+ return false;
43
+ } else {
44
+ return $params[$key];
45
+ }
46
+ }
47
+ }
48
  }
helpers/email.php CHANGED
@@ -103,9 +103,9 @@ class WYSIJA_help_email extends WYSIJA_object{
103
  $this->error(__('The PHP Extension openssl is not enabled on your server. Ask your host to enable it if you want to use an SSL connection.',WYSIJA));
104
  }elseif(!empty($bounce) AND !in_array($config->getValue('sending_method'),array('smtp_com','elasticemail'))){
105
  $this->error(sprintf(__('The bounce email address "%1$s" might actually cause the problem. Leave the field empty and try again.',WYSIJA),$bounce));
106
- //Case 2 : you are using SMTP but you didn't add an authentication
107
  }elseif(in_array($config->getValue('sending_method'),array('smtp','gmail')) AND !$config->getValue('smtp_auth') AND strlen($config->getValue('smtp_password')) > 1){
108
- $this->error(__('You specified an SMTP password but you don\'t require an authentication, you might want to turn the SMTP authentication ON.',WYSIJA));
109
  //Case 3 : you are on localhost!
110
  }elseif((strpos(WYSIJA_URL,'localhost') || strpos(WYSIJA_URL,'127.0.0.1')) && in_array($config->getValue('sending_method'),array('sendmail','qmail','mail'))){
111
  $this->error(__('Your localhost may not have a mail server. To verify, please log out and click on the "Lost your password?" link on the login page. Do you receive the reset password email from your WordPress?',WYSIJA));
103
  $this->error(__('The PHP Extension openssl is not enabled on your server. Ask your host to enable it if you want to use an SSL connection.',WYSIJA));
104
  }elseif(!empty($bounce) AND !in_array($config->getValue('sending_method'),array('smtp_com','elasticemail'))){
105
  $this->error(sprintf(__('The bounce email address "%1$s" might actually cause the problem. Leave the field empty and try again.',WYSIJA),$bounce));
106
+ //Case 2 : you are using SMTP but you didn't add an authentification
107
  }elseif(in_array($config->getValue('sending_method'),array('smtp','gmail')) AND !$config->getValue('smtp_auth') AND strlen($config->getValue('smtp_password')) > 1){
108
+ $this->error(__('You specified an SMTP password but you don\'t require an authentification, you might want to turn the SMTP authentification ON.',WYSIJA));
109
  //Case 3 : you are on localhost!
110
  }elseif((strpos(WYSIJA_URL,'localhost') || strpos(WYSIJA_URL,'127.0.0.1')) && in_array($config->getValue('sending_method'),array('sendmail','qmail','mail'))){
111
  $this->error(__('Your localhost may not have a mail server. To verify, please log out and click on the "Lost your password?" link on the login page. Do you receive the reset password email from your WordPress?',WYSIJA));
helpers/forms.php CHANGED
@@ -2,79 +2,73 @@
2
  defined('WYSIJA') or die('Restricted access');
3
  /* some Functions are based on Codeigniter's Form Helper Class (http://www.codeigniter.com) */
4
  class WYSIJA_help_forms{
5
- var $eachValues = array();
6
- var $eachValuesSec = array();
7
-
8
- function WYSIJA_help_forms(){
9
- // I believe this is for translation purpose, making sure the correct language is loaded
10
- add_action( 'init', array( $this, 'apply_filters' ), 20 );
11
-
12
- $this->eachValues = array(
13
- 'one_min' => __( 'every minute', WYSIJA ),
14
- 'two_min' => __( 'every 2 minutes', WYSIJA ),
15
- 'five_min' => __( 'every 5 minutes', WYSIJA ),
16
- 'ten_min' => __( 'every 10 minutes', WYSIJA ),
17
- 'fifteen_min' => __( 'every 15 minutes', WYSIJA ),
18
- 'thirty_min' => __( 'every 30 minutes', WYSIJA ),
19
- 'hourly' => __( 'every hour', WYSIJA ),
20
- 'two_hours' => __( 'every 2 hours', WYSIJA )
21
- );
22
-
23
- $this->eachValuesSec = array(
24
- 'one_min' => '60',
25
- 'two_min' => '120',
26
- 'five_min' => '300',
27
- 'ten_min' => '600',
28
- 'fifteen_min' => '900',
29
- 'thirty_min' => '1800',
30
- 'hourly' => '3600',
31
- 'two_hours' => '7200',
32
- 'twicedaily' => '43200',
33
- 'daily' => '86400',
34
- );
35
- }
36
-
37
- function apply_filters() {
38
- $this->eachValues = apply_filters( 'mpoet_sending_frequency', $this->eachValues );
39
- $this->eachValuesSec = apply_filters( 'mpoet_sending_frequency_sec', $this->eachValuesSec );
40
- }
41
-
42
- function input($data = '', $value = '', $extra = '') {
43
- $defaults = array('type' => 'text', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
44
- $content="<input ".$this->setAttrib($data, $defaults).$extra." />";
45
- return $content;
46
- }
47
- function password($data = '', $value = '', $extra = '') {
48
- $defaults = array('type' => 'password', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
49
- $content="<input ".$this->setAttrib($data, $defaults).$extra." />";
50
- return $content;
51
- }
52
-
53
- function hidden($data = '', $value = '', $extra = '') {
54
- $defaults = array('type' => 'hidden', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
55
- $content="<input ".$this->setAttrib($data, $defaults).$extra." />";
56
- return $content;
57
- }
58
-
59
- function textarea($data = '', $value = '', $extra = '') {
60
- $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'cols' => '90', 'rows' => '12');
61
 
62
- if ( ! is_array($data) OR ! isset($data['value'])) {
63
- $val = $value;
64
- } else {
65
- $val = $data['value'];
66
- unset($data['value']);
67
- }
68
-
69
- return '<textarea '.$this->setAttrib($data, $defaults).$extra.'>'.$val.'</textarea>';
70
- }
71
-
72
-
73
- function tinymce($idName = '', $content = '') {
74
- $this->the_editor(stripslashes($content), $idName,'title',false);
75
- }
76
-
77
- function checkbox($data = '', $value = '', $checked = FALSE, $extra = '') {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  $defaults = array('type' => 'checkbox', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
79
 
80
  if (is_array($data) AND array_key_exists('checked', $data)) {
@@ -88,179 +82,179 @@ class WYSIJA_help_forms{
88
  else unset($defaults['checked']);
89
 
90
  return "<input ".$this->setAttrib($data, $defaults).$extra." />";
91
- }
92
-
93
- function checkboxes($data = '', $values = array(), $value = '', $extra = '') {
94
- $html='';
95
- foreach($values as $val => $valtitle){
96
- $checked=false;
97
- $data2=$data;
98
- $data2['id'].="-".$val;
99
- if($val==$value)$checked=true;
100
- $html.='<label for="'.$data2['id'].'">'.$this->checkbox($data2, $val, $checked, $extra).$valtitle."</label>";
101
- }
102
-
103
- return $html;
104
- }
105
-
106
- function radios($data = '', $values = array(), $value = '', $extra = '') {
107
- $html='';
108
- foreach($values as $val => $valtitle){
109
- $checked=false;
110
- $data2=$data;
111
- $data2['id'].="-".$val;
112
- if($val==$value)$checked=true;
113
- $html.='<label for="'.$data2['id'].'">'.$this->radio($data2, $val, $checked, $extra).$valtitle."</label>";
114
- }
115
-
116
- return $html;
117
- }
118
-
119
- function radio($data = '', $value = '', $checked = FALSE, $extra = '') {
120
- if ( ! is_array($data)) {
121
- $data = array('name' => $data);
122
- }
123
-
124
- $data['type'] = 'radio';
125
- return $this->checkbox($data, $value, $checked, $extra);
126
- }
127
-
128
-
129
- function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2){
130
- $rows = get_option('default_post_edit_rows');
131
- if (($rows < 3) || ($rows > 100))
132
- $rows = 12;
133
-
134
- if ( !current_user_can( 'upload_files' ) )
135
- $media_buttons = false;
136
-
137
- $richedit = user_can_richedit();
138
- $class = '';
139
-
140
- if ( $richedit || $media_buttons ) { ?>
141
- <div id="editor-toolbar">
142
- <?php
143
- if ( $richedit ) {
144
- $wp_default_editor=tap_get_option("visual_ed_disable");
145
- ?>
146
- <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>
147
- <?php if ( $wp_default_editor ) {
148
- add_filter('the_editor_content', 'wp_htmledit_pre'); ?>
149
- <a id="edButtonHTML" class="edButtonHTML active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
150
- <a id="edButtonPreview" class="edButtonPreview hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
151
- <?php } else {
152
- $class = " class='theEditor'";
153
- add_filter('the_editor_content', 'wp_richedit_pre'); ?>
154
- <a id="edButtonHTML" class="edButtonHTML hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
155
- <a id="edButtonPreview" class="edButtonPreview active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
156
- <?php }
157
- }
158
- ?><div id="media-buttons" class="hide-if-no-js"><?php
159
- if ( $media_buttons ) { ?>
160
-
161
- <?php do_action( 'media_buttons' ); ?>
162
-
163
- <?php
164
- } ?>
165
- </div>
166
- </div>
167
- <?php
168
- }
169
- ?>
170
- <div id="quicktags"><?php
171
- wp_print_scripts( 'quicktags' ); ?>
172
- </div>
173
-
174
- <?php
175
- $the_editor = apply_filters('the_editor', "<div id='editorcontainer'><textarea rows='$rows'$class cols='40' name='$id' tabindex='$tab_index' id='$id'>%s</textarea></div>\n");
176
- $the_editor_content = apply_filters('the_editor_content', $content);
177
-
178
- printf($the_editor, $the_editor_content);
179
-
180
- }
181
-
182
- function titleh($idName = '', $selected = '') {
183
- $options=array("default"=>"default","h2"=>"h2","h3"=>"h3","h4"=>"h4");
184
- echo $this->dropdown($idName,$options,$selected);
185
- }
186
-
187
- function enabled($idName = '', $selected = '') {
188
- $options=array(0=>"disabled",1=>"enabled");
189
- echo $this->dropdown($idName,$options,$selected);
190
- }
191
-
192
- function dropdown($data = '', $options = array(), $selected = array(), $extra = '') {
193
- if ( ! is_array($selected)) {
194
- $selected = array($selected);
195
- }
196
-
197
- if ( empty($options) ) {
198
- return false;
199
- }
200
-
201
- $defaults = array('name' => (( ! is_array($data)) ? $data : ''));
202
-
203
- /* buggy lines
204
- * if (count($selected) === 0) {
205
- if (isset($_POST[$name])) $selected = array($_POST[$name]);
206
- }*/
207
-
208
- if ($extra != '') $extra = ' '.$extra;
209
-
210
- $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : '';
211
- $form = '<select '.$this->setAttrib($data, $defaults).$extra.$multiple.">\n";
212
-
213
- foreach ($options as $key => $val) {
214
- $key = (string) $key;
215
- if (is_array($val)) {
216
- $form .= '<optgroup label="'.$key.'">'."\n";
217
- foreach ($val as $optgroup_key => $optgroup_val) {
218
- $sel = (in_array($optgroup_key, $selected)) ? ' selected="selected"' : '';
219
- $form .= '<option value="'.esc_attr($optgroup_key).'"'.$sel.'>'.(string) $optgroup_val."</option>\n";
220
- }
221
- $form .= '</optgroup>'."\n";
222
- } else {
223
- $sel = (in_array($key, $selected)) ? ' selected="selected"' : '';
224
- $form .= '<option value="'.esc_attr($key).'"'.$sel.'>'.(string) $val."</option>\n";
225
- }
226
- }
227
- $form .= '</select>';
228
- return $form;
229
- }
230
-
231
-
232
- function setAttrib($attributes, $default) {
233
- if (is_array($attributes)) {
234
- foreach ($default as $key => $val) {
235
- if (isset($attributes[$key])) {
236
- $default[$key] = $attributes[$key];
237
- unset($attributes[$key]);
238
- }
239
- }
240
- if(isset($attributes["default"])){
241
-
242
- $attributes["onBlur"]="if(this.value=='') {this.value='".$attributes["default"]."';this.style.color='#ccc';this.style.fontStyle='italic';}";
243
- $attributes["onFocus"]="if(this.value=='".$attributes["default"]."') {this.value='';this.style.color='#000';this.style.fontStyle='normal';}";
244
- if((!isset($default['value']) || !$default['value'])){
245
- $default['value']=$attributes["default"];
246
- $attributes["style"]="color:#ccc;font-style:italic;";
247
- }
248
- }
249
-
250
- if (count($attributes) > 0) {
251
- $default = array_merge($default, $attributes);
252
- }
253
- }
254
-
255
- $att = '';
256
-
257
- foreach ($default as $key => $val) {
258
- if($key=='value') $val=esc_attr($val);
259
- $att .= $key . '="' . $val . '" ';
260
- }
261
-
262
- return $att;
263
- }
264
 
265
  }
266
 
2
  defined('WYSIJA') or die('Restricted access');
3
  /* some Functions are based on Codeigniter's Form Helper Class (http://www.codeigniter.com) */
4
  class WYSIJA_help_forms{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
+ function WYSIJA_help_forms(){
7
+ add_action('init', array($this, 'init'), 20);
8
+
9
+ $this->eachValuesSec=array(
10
+ 'one_min'=> '60',
11
+ 'two_min'=> '120',
12
+ 'five_min'=> '300',
13
+ 'ten_min'=> '600',
14
+ 'fifteen_min'=> '900',
15
+ 'thirty_min'=> '1800',
16
+ 'hourly'=> '3600',
17
+ 'two_hours'=>'7200',
18
+ 'twicedaily'=> '43200',
19
+ 'daily'=> '86400'
20
+ );
21
+ }
22
+
23
+ function init() {
24
+ $this->eachValues = apply_filters('mpoet_sending_frequency', array(
25
+ 'one_min'=> __('every minute',WYSIJA),
26
+ 'two_min'=> __('every 2 minutes',WYSIJA),
27
+ 'five_min'=> __('every 5 minutes',WYSIJA),
28
+ 'ten_min'=> __('every 10 minutes',WYSIJA),
29
+ 'fifteen_min'=> __('every 15 minutes',WYSIJA),
30
+ 'thirty_min'=> __('every 30 minutes',WYSIJA),
31
+ 'hourly'=> __('every hour',WYSIJA),
32
+ 'two_hours'=> __('every 2 hours',WYSIJA)
33
+ ));
34
+ }
35
+
36
+ function input($data = '', $value = '', $extra = '') {
37
+ $defaults = array('type' => 'text', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
38
+ $content="<input ".$this->setAttrib($data, $defaults).$extra." />";
39
+ return $content;
40
+ }
41
+ function password($data = '', $value = '', $extra = '') {
42
+ $defaults = array('type' => 'password', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
43
+ $content="<input ".$this->setAttrib($data, $defaults).$extra." />";
44
+ return $content;
45
+ }
46
+
47
+ function hidden($data = '', $value = '', $extra = '') {
48
+ $defaults = array('type' => 'hidden', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
49
+ $content="<input ".$this->setAttrib($data, $defaults).$extra." />";
50
+ return $content;
51
+ }
52
+
53
+ function textarea($data = '', $value = '', $extra = '') {
54
+ $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'cols' => '90', 'rows' => '12');
55
+
56
+ if ( ! is_array($data) OR ! isset($data['value'])) {
57
+ $val = $value;
58
+ } else {
59
+ $val = $data['value'];
60
+ unset($data['value']);
61
+ }
62
+
63
+ return '<textarea '.$this->setAttrib($data, $defaults).$extra.'>'.$val.'</textarea>';
64
+ }
65
+
66
+
67
+ function tinymce($idName = '', $content = '') {
68
+ $this->the_editor(stripslashes($content), $idName,'title',false);
69
+ }
70
+
71
+ function checkbox($data = '', $value = '', $checked = FALSE, $extra = '') {
72
  $defaults = array('type' => 'checkbox', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
73
 
74
  if (is_array($data) AND array_key_exists('checked', $data)) {
82
  else unset($defaults['checked']);
83
 
84
  return "<input ".$this->setAttrib($data, $defaults).$extra." />";
85
+ }
86
+
87
+ function checkboxes($data = '', $values = array(), $value = '', $extra = '') {
88
+ $html='';
89
+ foreach($values as $val => $valtitle){
90
+ $checked=false;
91
+ $data2=$data;
92
+ $data2['id'].="-".$val;
93
+ if($val==$value)$checked=true;
94
+ $html.='<label for="'.$data2['id'].'">'.$this->checkbox($data2, $val, $checked, $extra).$valtitle."</label>";
95
+ }
96
+
97
+ return $html;
98
+ }
99
+
100
+ function radios($data = '', $values = array(), $value = '', $extra = '') {
101
+ $html='';
102
+ foreach($values as $val => $valtitle){
103
+ $checked=false;
104
+ $data2=$data;
105
+ $data2['id'].="-".$val;
106
+ if($val==$value)$checked=true;
107
+ $html.='<label for="'.$data2['id'].'">'.$this->radio($data2, $val, $checked, $extra).$valtitle."</label>";
108
+ }
109
+
110
+ return $html;
111
+ }
112
+
113
+ function radio($data = '', $value = '', $checked = FALSE, $extra = '') {
114
+ if ( ! is_array($data)) {
115
+ $data = array('name' => $data);
116
+ }
117
+
118
+ $data['type'] = 'radio';
119
+ return $this->checkbox($data, $value, $checked, $extra);
120
+ }
121
+
122
+
123
+ function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2){
124
+ $rows = get_option('default_post_edit_rows');
125
+ if (($rows < 3) || ($rows > 100))
126
+ $rows = 12;
127
+
128
+ if ( !current_user_can( 'upload_files' ) )
129
+ $media_buttons = false;
130
+
131
+ $richedit = user_can_richedit();
132
+ $class = '';
133
+
134
+ if ( $richedit || $media_buttons ) { ?>
135
+ <div id="editor-toolbar">
136
+ <?php
137
+ if ( $richedit ) {
138
+ $wp_default_editor=tap_get_option("visual_ed_disable");
139
+ ?>
140
+ <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>
141
+ <?php if ( $wp_default_editor ) {
142
+ add_filter('the_editor_content', 'wp_htmledit_pre'); ?>
143
+ <a id="edButtonHTML" class="edButtonHTML active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
144
+ <a id="edButtonPreview" class="edButtonPreview hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
145
+ <?php } else {
146
+ $class = " class='theEditor'";
147
+ add_filter('the_editor_content', 'wp_richedit_pre'); ?>
148
+ <a id="edButtonHTML" class="edButtonHTML hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
149
+ <a id="edButtonPreview" class="edButtonPreview active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
150
+ <?php }
151
+ }
152
+ ?><div id="media-buttons" class="hide-if-no-js"><?php
153
+ if ( $media_buttons ) { ?>
154
+
155
+ <?php do_action( 'media_buttons' ); ?>
156
+
157
+ <?php
158
+ } ?>
159
+ </div>
160
+ </div>
161
+ <?php
162
+ }
163
+ ?>
164
+ <div id="quicktags"><?php
165
+ wp_print_scripts( 'quicktags' ); ?>
166
+ </div>
167
+
168
+ <?php
169
+ $the_editor = apply_filters('the_editor', "<div id='editorcontainer'><textarea rows='$rows'$class cols='40' name='$id' tabindex='$tab_index' id='$id'>%s</textarea></div>\n");
170
+ $the_editor_content = apply_filters('the_editor_content', $content);
171
+
172
+ printf($the_editor, $the_editor_content);
173
+
174
+ }
175
+
176
+ function titleh($idName = '', $selected = '') {
177
+ $options=array("default"=>"default","h2"=>"h2","h3"=>"h3","h4"=>"h4");
178
+ echo $this->dropdown($idName,$options,$selected);
179
+ }
180
+
181
+ function enabled($idName = '', $selected = '') {
182
+ $options=array(0=>"disabled",1=>"enabled");
183
+ echo $this->dropdown($idName,$options,$selected);
184
+ }
185
+
186
+ function dropdown($data = '', $options = array(), $selected = array(), $extra = '') {
187
+ if ( ! is_array($selected)) {
188
+ $selected = array($selected);
189
+ }
190
+
191
+ if ( empty($options) ) {
192
+ return false;
193
+ }
194
+
195
+ $defaults = array('name' => (( ! is_array($data)) ? $data : ''));
196
+
197
+ /* buggy lines
198
+ * if (count($selected) === 0) {
199
+ if (isset($_POST[$name])) $selected = array($_POST[$name]);
200
+ }*/
201
+
202
+ if ($extra != '') $extra = ' '.$extra;
203
+
204
+ $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : '';
205
+ $form = '<select '.$this->setAttrib($data, $defaults).$extra.$multiple.">\n";
206
+
207
+ foreach ($options as $key => $val) {
208
+ $key = (string) $key;
209
+ if (is_array($val)) {
210
+ $form .= '<optgroup label="'.$key.'">'."\n";
211
+ foreach ($val as $optgroup_key => $optgroup_val) {
212
+ $sel = (in_array($optgroup_key, $selected)) ? ' selected="selected"' : '';
213
+ $form .= '<option value="'.esc_attr($optgroup_key).'"'.$sel.'>'.(string) $optgroup_val."</option>\n";
214
+ }
215
+ $form .= '</optgroup>'."\n";
216
+ } else {
217
+ $sel = (in_array($key, $selected)) ? ' selected="selected"' : '';
218
+ $form .= '<option value="'.esc_attr($key).'"'.$sel.'>'.(string) $val."</option>\n";
219
+ }
220
+ }
221
+ $form .= '</select>';
222
+ return $form;
223
+ }
224
+
225
+
226
+ function setAttrib($attributes, $default) {
227
+ if (is_array($attributes)) {
228
+ foreach ($default as $key => $val) {
229
+ if (isset($attributes[$key])) {
230
+ $default[$key] = $attributes[$key];
231
+ unset($attributes[$key]);
232
+ }
233
+ }
234
+ if(isset($attributes["default"])){
235
+
236
+ $attributes["onBlur"]="if(this.value=='') {this.value='".$attributes["default"]."';this.style.color='#ccc';this.style.fontStyle='italic';}";
237
+ $attributes["onFocus"]="if(this.value=='".$attributes["default"]."') {this.value='';this.style.color='#000';this.style.fontStyle='normal';}";
238
+ if((!isset($default['value']) || !$default['value'])){
239
+ $default['value']=$attributes["default"];
240
+ $attributes["style"]="color:#ccc;font-style:italic;";
241
+ }
242
+ }
243
+
244
+ if (count($attributes) > 0) {
245
+ $default = array_merge($default, $attributes);
246
+ }
247
+ }
248
+
249
+ $att = '';
250
+
251
+ foreach ($default as $key => $val) {
252
+ if($key=='value') $val=esc_attr($val);
253
+ $att .= $key . '="' . $val . '" ';
254
+ }
255
+
256
+ return $att;
257
+ }
258
 
259
  }
260
 
helpers/front.php CHANGED
@@ -236,14 +236,18 @@ class WYSIJA_help_front extends WYSIJA_help{
236
  $wysija_undo = $this->controller->undo_unsubscribe;
237
  }
238
 
239
- // only force our edit subscription screen at the bottom of the content of the page
240
- // if it's the right action and there is no wysija_page shortcode in teh page
241
- if(!empty($_REQUEST['action']) && $_REQUEST['action'] == 'subscriptions' && strpos($content, '[wysija_page]') == false){
242
- // we append the subscription form at the bottom of the page if we can't detect it
243
- return $content.'<div class="mpoet_profile_edit">'.$wysija_content.'</div>';
244
  }else{
245
- // we replace the shortcode by our automatic content, other wise if there is no shortcode the page stays the same
246
- return str_replace('[wysija_page]', $wysija_content.$wysija_undo, $content);
 
 
 
 
 
247
  }
248
 
249
  }
@@ -261,7 +265,7 @@ class WYSIJA_help_front extends WYSIJA_help{
261
  * @return string html
262
  */
263
  function scan_form_shortcode($attributes) {
264
- // IMPORTANT: this is to make sure MagicMember won't scan our form and find [user_list] as a code they should replace.
265
  remove_shortcode('user_list');
266
 
267
  if(isset($attributes['id']) && (int)$attributes['id']>0){
236
  $wysija_undo = $this->controller->undo_unsubscribe;
237
  }
238
 
239
+ // this is a special case so that the user who specifies his own unsubscribe page in the settings
240
+ // and don't add a [wysija_page] tag into it will still have the undo subscribe link and will write his own message.
241
+ if(!empty($_REQUEST['action']) && $_REQUEST['action'] == 'unsubscribe' && strpos($content, '[wysija_page]') == false){
242
+ return $content.'<div>'.$wysija_undo.'</div>';
 
243
  }else{
244
+ // this is the standard case where the shortcode is found in the page
245
+ if(strpos($content, '[wysija_page]') !== false){
246
+ return str_replace('[wysija_page]', $wysija_content.$wysija_undo, $content);
247
+ }else{
248
+ //where the shortcode is not found we append at the bottom of the page
249
+ return $content.$wysija_content;
250
+ }
251
  }
252
 
253
  }
265
  * @return string html
266
  */
267
  function scan_form_shortcode($attributes) {
268
+ // this is to make sure MagicMember won't scan our form and find [user_list] as a code they should replace.
269
  remove_shortcode('user_list');
270
 
271
  if(isset($attributes['id']) && (int)$attributes['id']>0){
helpers/install.php CHANGED
@@ -150,20 +150,17 @@ class WYSIJA_help_install extends WYSIJA_object{
150
 
151
  // save the config into the db
152
 
153
- if( (int) get_option('installation_step') < 16){
 
 
 
154
 
155
- $model_config = WYSIJA::get('config','model');
156
-
157
- $values['installed'] = true;
158
- $values['manage_subscriptions'] = true;
159
- $values['installed_time'] = time();
160
-
161
- $values['wysija_db_version'] = WYSIJA::get_version();
162
 
163
  $wptoolboxs = WYSIJA::get('toolbox', 'helper');
164
- $values['dkim_domain'] = $wptoolboxs->_make_domain_name();
165
 
166
- if( get_option('wysija_reinstall',0) ) $values['wysija_whats_new'] = WYSIJA::get_version();
167
  $model_config->save($values);
168
 
169
  WYSIJA::update_option('installation_step', '16');
@@ -479,15 +476,15 @@ class WYSIJA_help_install extends WYSIJA_object{
479
 
480
  // execute the queries one by one
481
  global $wpdb;
482
- $has_errors = false;
483
-
484
  foreach($queries as $qry){
485
- $last_error = $wpdb->last_error;
486
  $wpdb->query($qry);
 
 
 
 
 
487
 
488
- if( !empty($wpdb->last_error) && $last_error != $wpdb->last_error ){
489
- $this->notice($wpdb->last_error);
490
- $has_errors = true;
491
  }
492
 
493
  }
150
 
151
  // save the config into the db
152
 
153
+ if((int)get_option('installation_step')<16){
154
+ $values['installed']=true;
155
+ $values['manage_subscriptions']=true;
156
+ $values['installed_time']=time();
157
 
158
+ $values['wysija_db_version']=WYSIJA::get_version();
 
 
 
 
 
 
159
 
160
  $wptoolboxs = WYSIJA::get('toolbox', 'helper');
161
+ $values['dkim_domain']=$wptoolboxs->_make_domain_name();
162
 
163
+ if(get_option('wysija_reinstall',0)) $values['wysija_whats_new']=WYSIJA::get_version();
164
  $model_config->save($values);
165
 
166
  WYSIJA::update_option('installation_step', '16');
476
 
477
  // execute the queries one by one
478
  global $wpdb;
479
+ $has_errors=false;
 
480
  foreach($queries as $qry){
 
481
  $wpdb->query($qry);
482
+ $error = mysql_error( $wpdb->dbh );
483
+
484
+ if($error){
485
+ $this->notice(mysql_error());
486
+ $has_errors=true;
487
 
 
 
 
488
  }
489
 
490
  }
helpers/licence.php CHANGED
@@ -111,7 +111,7 @@ class WYSIJA_help_licence extends WYSIJA_help{
111
  case 1: //Domain \'%1$s\' does not exist.
112
  //$error_msg=__('\'%1$s\' does not exist!',WYSIJA);
113
 
114
- $error_msg=__('Your website doesn\'t seem to have a license! Log into your [link]account manager[/link] to add a license for this website.',WYSIJA);
115
  break;
116
  case 2: //'Licence (id: %d) does not exist for domain "%s"
117
  $error_msg=__('There\'s no license for "%1$s". If you\'re Premium, add this domain in your [link]account manager[/link].',WYSIJA);
111
  case 1: //Domain \'%1$s\' does not exist.
112
  //$error_msg=__('\'%1$s\' does not exist!',WYSIJA);
113
 
114
+ $error_msg=__('Your website doesn\'t seem to have a license! Log in to your [link]account manager[/link] to add a license for this website.',WYSIJA);
115
  break;
116
  case 2: //'Licence (id: %d) does not exist for domain "%s"
117
  $error_msg=__('There\'s no license for "%1$s". If you\'re Premium, add this domain in your [link]account manager[/link].',WYSIJA);
helpers/mailer.php CHANGED
@@ -885,10 +885,9 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
885
  /**
886
  * Detects if a link is on a same website
887
  * @param string $link
888
- * @access public
889
  * @return boolean
890
  */
891
- public function is_internal_link($link) {
892
  $helper_toolbox = WYSIJA::get('toolbox', 'helper');
893
  return (strpos($link, $helper_toolbox->_make_domain_name(site_url())) !== false);
894
  }
@@ -896,10 +895,9 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
896
  /**
897
  * is a wysija link
898
  * @param string $link
899
- * @access public
900
  * @return boolean
901
  */
902
- public function is_wysija_link($link) {
903
  // @todo: we should use pattern to remove all links with []
904
  return (
905
  strpos($link, '[view_in_browser_link]') !== false
@@ -911,10 +909,9 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
911
  /**
912
  * Get a character which is between the original url and the next param
913
  * @param string $link
914
- * @access public
915
  * @return string
916
  */
917
- public function get_started_character_of_param($link) {
918
  return (strpos($link, '?') !== false) ? '&' : '?';
919
  }
920
 
885
  /**
886
  * Detects if a link is on a same website
887
  * @param string $link
 
888
  * @return boolean
889
  */
890
+ protected function is_internal_link($link) {
891
  $helper_toolbox = WYSIJA::get('toolbox', 'helper');
892
  return (strpos($link, $helper_toolbox->_make_domain_name(site_url())) !== false);
893
  }
895
  /**
896
  * is a wysija link
897
  * @param string $link
 
898
  * @return boolean
899
  */
900
+ protected function is_wysija_link($link) {
901
  // @todo: we should use pattern to remove all links with []
902
  return (
903
  strpos($link, '[view_in_browser_link]') !== false
909
  /**
910
  * Get a character which is between the original url and the next param
911
  * @param string $link
 
912
  * @return string
913
  */
914
+ protected function get_started_character_of_param($link) {
915
  return (strpos($link, '?') !== false) ? '&' : '?';
916
  }
917
 
helpers/queue.php CHANGED
@@ -418,32 +418,27 @@ class WYSIJA_help_queue extends WYSIJA_object{
418
  */
419
  function clear(){
420
 
421
- $model_config = WYSIJA::get('config','model');
422
- $model_queue = WYSIJA::get('queue','model');
423
 
424
  //remove queued emails of unsubscribed users
425
- $real_query = 'DELETE a.* FROM `[wysija]queue` as a LEFT JOIN `[wysija]user` as b on a.user_id = b.user_id WHERE b.status< '.$model_config->getValue('confirm_dbleoptin');
426
  $model_queue->query($real_query);
427
 
428
  //remove queued emails of deleted emails
429
- $real_query = 'DELETE a.* FROM `[wysija]queue` as a LEFT JOIN `[wysija]email` as b on a.email_id = b.email_id WHERE b.email_id IS NULL';
430
  $model_queue->query($real_query);
431
 
432
  //remove queued emails of deleted users
433
- $real_query = 'DELETE a.* FROM `[wysija]queue` as a LEFT JOIN `[wysija]user` as b on a.user_id = b.user_id WHERE b.user_id IS NULL';
434
  $model_queue->query($real_query);
435
 
436
  //finally check if there are any queued emails left that stays unsent from 2 days ago
437
- $conditions = array();
438
- $conditions['less'] = array( 'send_at' => time() - (3600*48) );
439
-
440
- // replaced the exists function with a count
441
- $model_queue->setConditions( $conditions );
442
- $count_late_in_queue = $model_queue->count();
443
-
444
- if( $count_late_in_queue > 1000 ){
445
  //send message your queue cannot send very fast
446
- $model_config->save( array( 'queue_sends_slow' => 1 ) );
447
  }
448
 
449
  return true;
418
  */
419
  function clear(){
420
 
421
+ $model_config=WYSIJA::get('config','model');
422
+ $model_queue=WYSIJA::get('queue','model');
423
 
424
  //remove queued emails of unsubscribed users
425
+ $real_query='DELETE a.* FROM `[wysija]queue` as a LEFT JOIN `[wysija]user` as b on a.user_id = b.user_id WHERE b.status< '.$model_config->getValue('confirm_dbleoptin');
426
  $model_queue->query($real_query);
427
 
428
  //remove queued emails of deleted emails
429
+ $real_query='DELETE a.* FROM `[wysija]queue` as a LEFT JOIN `[wysija]email` as b on a.email_id = b.email_id WHERE b.email_id IS NULL';
430
  $model_queue->query($real_query);
431
 
432
  //remove queued emails of deleted users
433
+ $real_query='DELETE a.* FROM `[wysija]queue` as a LEFT JOIN `[wysija]user` as b on a.user_id = b.user_id WHERE b.user_id IS NULL';
434
  $model_queue->query($real_query);
435
 
436
  //finally check if there are any queued emails left that stays unsent from 2 days ago
437
+ $conditions=array();
438
+ $conditions['less']=array('send_at'=>time()-(3600*48));
439
+ if($model_queue->exists($conditions)){
 
 
 
 
 
440
  //send message your queue cannot send very fast
441
+ $model_config->save(array('queue_sends_slow'=>1));
442
  }
443
 
444
  return true;
helpers/quick_html.php CHANGED
@@ -1,36 +1,36 @@
1
- <?php
2
- defined('WYSIJA') or die('Restricted access');
3
- class WYSIJA_help_quick_html extends WYSIJA_object {
4
-
5
- function WYSIJA_help_quick_html() {
6
-
7
- }
8
-
9
- /**
10
- * quickly renders a row of 3 sales argument with a picture a title and description with an eventual link
11
- * pretty handy for the update page/welcome page and premium page
12
- * @param type $arguments the array includes 3 array with this format (key,title,desc,link,img)
13
- * @param type $cta_links the link in the descriptive text will be rendered as a button
14
- * @return string
15
- */
16
- function three_arguments($arguments, $cta_links = false){
17
- $html = $class_link = '';
18
- $count = 1;
19
- foreach ($arguments as $sale_argument) {
20
- if (isset($sale_argument['link'])) {
21
- if($cta_links) $class_link = 'class="argument-cta"';
22
- $sale_argument['desc'] = str_replace(array('[link]', '[/link]'), array('<a '.$class_link.' href="' . $sale_argument['link'] . '" target="_blank">', '</a>'), $sale_argument['desc']);
23
- }
24
- if($count==3) $sale_argument['key'] .= ' last-feature';
25
- $html .= '<div class="col-'.$count.' '.$sale_argument['key'].'">';
26
-
27
- if(isset($sale_argument['img'])) $html .= '<img src="'.$sale_argument['img'].'">';
28
- $html .= '<h3>'.$sale_argument['title'].'</h3>
29
- <p>'.$sale_argument['desc'].'</p>
30
- </div>';
31
- $count++;
32
- }
33
-
34
- return $html;
35
- }
36
- }
1
+ <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
+ class WYSIJA_help_quick_html extends WYSIJA_object {
4
+
5
+ function WYSIJA_help_quick_html() {
6
+
7
+ }
8
+
9
+ /**
10
+ * quickly renders a row of 3 sales argument with a picture a title and description with an eventual link
11
+ * pretty handy for the update page/welcome page and premium page
12
+ * @param type $arguments the array includes 3 array with this format (key,title,desc,link,img)
13
+ * @param type $cta_links the link in the descriptive text will be rendered as a button
14
+ * @return string
15
+ */
16
+ function three_arguments($arguments, $cta_links = false){
17
+ $html = $class_link = '';
18
+ $count = 1;
19
+ foreach ($arguments as $sale_argument) {
20
+ if (isset($sale_argument['link'])) {
21
+ if($cta_links) $class_link = 'class="argument-cta"';
22
+ $sale_argument['desc'] = str_replace(array('[link]', '[/link]'), array('<a '.$class_link.' href="' . $sale_argument['link'] . '" target="_blank">', '</a>'), $sale_argument['desc']);
23
+ }
24
+ if($count==3) $sale_argument['key'] .= ' last-feature';
25
+ $html .= '<div class="col-'.$count.' '.$sale_argument['key'].'">';
26
+
27
+ if(isset($sale_argument['img'])) $html .= '<img src="'.$sale_argument['img'].'">';
28
+ $html .= '<h3>'.$sale_argument['title'].'</h3>
29
+ <p>'.$sale_argument['desc'].'</p>
30
+ </div>';
31
+ $count++;
32
+ }
33
+
34
+ return $html;
35
+ }
36
+ }
helpers/render_engine.php CHANGED
@@ -170,13 +170,13 @@ class WYSIJA_help_render_engine extends WYSIJA_object {
170
 
171
  # position in list
172
  $i < $count-1 ? $line[self::_LAST] = false : $line[self::_LAST] = true;
173
- $i === 0 ? $line[self::_FIRST] = true : $line[self::_FIRST] = false;
174
 
175
  # rows and columns infos
176
  if ($loop_row_size) {
177
  # col position
178
  ($i+1)%$loop_row_size ? $line[self::_LAST_COL] = false : $line[self::_LAST_COL] = true;
179
- ($i+1)%$loop_row_size === 1 ? $line[self::_FIRST_COL] = true : $line[self::_FIRST_COL] = false;
180
 
181
  # row position
182
  $i<$loop_row_size ? $line[self::_FIRST_ROW] = true : $line[self::_FIRST_ROW] = false;
@@ -751,25 +751,6 @@ class WYSIJA_help_render_engine extends WYSIJA_object {
751
  }
752
  $value = $ratio;
753
  break;
754
- case 'format_line_height':
755
- // if value in px, don't modify
756
- if($value !== '0' && strpos($value, 'px') === FALSE && strpos($value, '%') === FALSE) {
757
- // if number value, convert to percent
758
- $percentage = ((float)$value * 100);
759
- $value = $percentage.'%';
760
- }
761
- break;
762
-
763
- case 'format_font_size_value':
764
- if(strpos($value, 'em') !== FALSE) {
765
- // if number value, convert to percent
766
- $percentage = ((float)$value * 100);
767
- $value = $percentage.'%';
768
- } else if(strpos($value, '%') === FALSE) {
769
- $value = $value.'px';
770
- }
771
- break;
772
-
773
  case 'inc':
774
  if (!isset ($arguments[0])) {
775
  $value++;
@@ -780,7 +761,7 @@ class WYSIJA_help_render_engine extends WYSIJA_object {
780
 
781
  case 'mult':
782
  if ($arguments) {
783
- $value = (float)$value * (float)$arguments[0];
784
  }
785
  break;
786
 
170
 
171
  # position in list
172
  $i < $count-1 ? $line[self::_LAST] = false : $line[self::_LAST] = true;
173
+ $i == 0 ? $line[self::_FIRST] = true : $line[self::_FIRST] = false;
174
 
175
  # rows and columns infos
176
  if ($loop_row_size) {
177
  # col position
178
  ($i+1)%$loop_row_size ? $line[self::_LAST_COL] = false : $line[self::_LAST_COL] = true;
179
+ ($i+1)%$loop_row_size==1 ? $line[self::_FIRST_COL] = true : $line[self::_FIRST_COL] = false;
180
 
181
  # row position
182
  $i<$loop_row_size ? $line[self::_FIRST_ROW] = true : $line[self::_FIRST_ROW] = false;
751
  }
752
  $value = $ratio;
753
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
754
  case 'inc':
755
  if (!isset ($arguments[0])) {
756
  $value++;
761
 
762
  case 'mult':
763
  if ($arguments) {
764
+ $value = $value * $arguments[0];
765
  }
766
  break;
767
 
helpers/server.php CHANGED
@@ -135,18 +135,18 @@ class WYSIJA_help_server extends WYSIJA_object {
135
  function can_sql_create_tables(){
136
 
137
  // test that we can create tables on the mysql server
138
- $model_user = WYSIJA::get('user','model');
139
 
140
  $this->_create_temp_sql_table_if_not_exists();
141
 
142
  $query="SHOW TABLES like '".$model_user->getPrefix()."user_list_temp';";
143
 
144
  global $wpdb;
145
- $res = $wpdb->get_var($query);
146
 
147
  if(!$res){
148
  $this->error(sprintf(
149
- __('The MySQL user you have setup on your WordPress site (wp-config.php) doesn\'t have enough privileges to CREATE MySQL tables. Please change this user yourself or contact the administrator of your site in order to complete MailPoet\'s installation. mysql errors:(%1$s)',WYSIJA), $wpdb->last_error));
150
  return false;
151
  }
152
  return true;
@@ -170,7 +170,7 @@ class WYSIJA_help_server extends WYSIJA_object {
170
  $wpdb->query($query);
171
  if(!$wpdb->result){
172
  $error_message=__('The MySQL user you have setup on your WordPress site (wp-config.php) doesn\'t have enough privileges to CREATE MySQL tables. Please change this user yourself or contact the administrator of your site in order to complete MailPoet\'s installation. mysql errors:(%1$s)',WYSIJA);
173
- $this->error(sprintf(str_replace('CREATE', 'ALTER', $error_message), $wpdb->last_error ));
174
  $this->_drop_temp_sql_table();
175
  return false;
176
  }
135
  function can_sql_create_tables(){
136
 
137
  // test that we can create tables on the mysql server
138
+ $model_user=WYSIJA::get('user','model');
139
 
140
  $this->_create_temp_sql_table_if_not_exists();
141
 
142
  $query="SHOW TABLES like '".$model_user->getPrefix()."user_list_temp';";
143
 
144
  global $wpdb;
145
+ $res=$wpdb->get_var($query);
146
 
147
  if(!$res){
148
  $this->error(sprintf(
149
+ __('The MySQL user you have setup on your WordPress site (wp-config.php) doesn\'t have enough privileges to CREATE MySQL tables. Please change this user yourself or contact the administrator of your site in order to complete MailPoet\'s installation. mysql errors:(%1$s)',WYSIJA), mysql_error()));
150
  return false;
151
  }
152
  return true;
170
  $wpdb->query($query);
171
  if(!$wpdb->result){
172
  $error_message=__('The MySQL user you have setup on your WordPress site (wp-config.php) doesn\'t have enough privileges to CREATE MySQL tables. Please change this user yourself or contact the administrator of your site in order to complete MailPoet\'s installation. mysql errors:(%1$s)',WYSIJA);
173
+ $this->error(sprintf(str_replace('CREATE', 'ALTER', $error_message), mysql_error($wpdb->dbh)));
174
  $this->_drop_temp_sql_table();
175
  return false;
176
  }
helpers/update.php CHANGED
@@ -1,926 +1,873 @@
1
- <?php
2
- defined( 'WYSIJA' ) or die( 'Restricted access' );
3
-
4
- class WYSIJA_help_update extends WYSIJA_object {
5
-
6
- function WYSIJA_help_update(){
7
- $this->modelWysija = new WYSIJA_model();
8
-
9
- //IMPORTANT when making db updated or running update processes, add the version and in the big switch below in the runUpdate() method
10
- $this->updates = array(
11
- '1.1',
12
- '2.0','2.1','2.1.6','2.1.7','2.1.8',
13
- '2.2','2.2.1',
14
- '2.3.3','2.3.4',
15
- '2.4', '2.4.1', '2.4.3','2.4.4',
16
- '2.5','2.5.2','2.5.5','2.5.9.6', '2.5.9.7',
17
- '2.6', '2.6.0.8',
18
- );
19
- }
20
-
21
- function runUpdate( $version ) {
22
- //run all the updates missing since the db-version
23
- //foreach ... $this->updateVersion($version);
24
- switch($version){
25
- case '1.1':
26
- //add column namekey to
27
- $model_config=WYSIJA::get('config','model');
28
- if(!$this->modelWysija->query("SHOW COLUMNS FROM `[wysija]list` LIKE 'namekey';")){
29
- $querys[]='ALTER TABLE `[wysija]list` ADD `namekey` VARCHAR( 255 ) NULL;';
30
- }
31
-
32
- $querys[]="UPDATE `[wysija]list` SET `namekey` = 'users' WHERE `list_id` =".$model_config->getValue('importwp_list_id').";";
33
- $errors=$this->runUpdateQueries($querys);
34
-
35
- $importHelp=WYSIJA::get('plugins_import','helper');
36
- $importHelp->testPlugins();
37
-
38
- // move data
39
- $installHelper = WYSIJA::get('install', 'helper');
40
- $installHelper->moveData('dividers');
41
- $installHelper->moveData('bookmarks');
42
- $installHelper->moveData('themes');
43
-
44
- if($errors){
45
- $this->error(implode($errors,"\n"));
46
- return false;
47
- }
48
- return true;
49
- break;
50
- case '2.0':
51
- //add column namekey to
52
- $model_config=WYSIJA::get('config','model');
53
- if(!$this->modelWysija->query("SHOW COLUMNS FROM `[wysija]email` LIKE 'modified_at';")){
54
- $querys[]="ALTER TABLE `[wysija]email` ADD `modified_at` INT UNSIGNED NOT NULL DEFAULT '0';";
55
- }
56
- if(!$model_config->getValue('update_error_20')){
57
- $querys[]="UPDATE `[wysija]email` SET `modified_at` = `sent_at` WHERE `sent_at`>=0;";
58
- $querys[]="UPDATE `[wysija]email` SET `modified_at` = `created_at` WHERE `modified_at`='0';";
59
- $querys[]="UPDATE `[wysija]email` SET `status` = '99' WHERE `status` ='1';";//change sending status from 1 to 99
60
- }
61
-
62
-
63
- $errors=$this->runUpdateQueries($querys);
64
-
65
- if($errors){
66
- $model_config->save(array('update_error_20'=>true));
67
- $this->error(implode($errors,"\n"));
68
- return false;
69
- }
70
- return true;
71
- break;
72
- case '2.1':
73
- $model_config=WYSIJA::get('config','model');
74
- if(!$model_config->getValue('update_error_21')){
75
- $modelEmails=WYSIJA::get('email','model');
76
- $modelEmails->reset();
77
- $emailsLoaded=$modelEmails->get(array('subject','email_id'),array('status'=>2,'type'=>1));
78
-
79
- //set the default new role caps for super admin and admin
80
- $wp_tools_helper = WYSIJA::get('wp_tools', 'helper');
81
- $wp_tools_helper->set_default_rolecaps();
82
-
83
- //based on the config values for role_campaign and role_subscribers
84
- //let's give the each core roles the right capability
85
-
86
- $minimumroles=array('role_campaign'=>'wysija_newsletters','role_subscribers'=>'wysija_subscribers');
87
-
88
- foreach($minimumroles as $rolename=>$capability){
89
- $rolesetting=$model_config->getValue($rolename);
90
- switch($rolesetting){
91
- case 'switch_themes':
92
- $keyrole=1;
93
- break;
94
- case 'moderate_comments':
95
- $keyrole=3;
96
- break;
97
- case 'upload_files':
98
- $keyrole=4;
99
- break;
100
- case 'edit_posts':
101
- $keyrole=5;
102
- break;
103
- case 'read':
104
- $keyrole=6;
105
- break;
106
- default:
107
- $keyrole=false;
108
- }
109
-
110
- if(!$keyrole){
111
- //add the setting to a custom role
112
- $role = get_role($rolesetting);
113
- //added for invalid roles ...
114
- if($role){
115
- $role->add_cap( $capability );
116
- }
117
- }else{
118
- //get all the minimum roles getting that capability
119
- $editable_roles=$wp_tools_helper->wp_get_roles();
120
- $startcount=1;
121
- if(!isset($editable_roles[$startcount])) $startcount++;
122
- for($i = $startcount; $i <= $keyrole; $i++) {
123
- $rolename=$editable_roles[$i];
124
- //add the setting to a custom role
125
- $role = get_role($rolename['key']);
126
- $role->add_cap( $capability );
127
- }
128
- }
129
- }
130
- $wptoolboxs = WYSIJA::get('toolbox', 'helper');
131
- $model_config->save(array('dkim_domain'=>$wptoolboxs->_make_domain_name()));
132
- }
133
-
134
- if(!$this->modelWysija->query("SHOW COLUMNS FROM `[wysija]list` LIKE 'is_public';")){
135
- $querys[]="ALTER TABLE `[wysija]list` ADD `is_public` TINYINT UNSIGNED NOT NULL DEFAULT 0;";
136
- $errors=$this->runUpdateQueries($querys);
137
- if($errors){
138
- $model_config->save(array('update_error_21'=>true));
139
- $this->error(implode($errors,"\n"));
140
- return false;
141
- }
142
- }
143
- return true;
144
- break;
145
- case '2.1.6':
146
- $querys[]="UPDATE `[wysija]user_list` as A inner join `[wysija]user` as B on (A.user_id= B.user_id) set A.sub_date= B.created_at where A.sub_date=0 and A.unsub_date=0 and B.status>-1;";
147
- $errors=$this->runUpdateQueries($querys);
148
-
149
- if($errors){
150
- $this->error(implode($errors,"\n"));
151
- return false;
152
- }
153
- return true;
154
- break;
155
- case '2.1.7':
156
- $querys[]='UPDATE `[wysija]user_list` as A inner join `[wysija]user` as B on (A.user_id= B.user_id) set A.sub_date= '.time().' where A.sub_date=0 and B.status>-1;';
157
- $errors=$this->runUpdateQueries($querys);
158
-
159
- if($errors){
160
- $this->error(implode($errors,"\n"));
161
- return false;
162
- }
163
- return true;
164
- break;
165
- case '2.1.8':
166
- $mConfig=WYSIJA::get('config','model');
167
-
168
- $querys[]='UPDATE `[wysija]user_list` as A set A.sub_date= '.time().' where A.list_id='.$mConfig->getValue('importwp_list_id').';';
169
- $errors=$this->runUpdateQueries($querys);
170
-
171
- if($errors){
172
- $this->error(implode($errors,"\n"));
173
- return false;
174
- }
175
- return true;
176
- break;
177
- case '2.2':
178
- $mConfig=WYSIJA::get('config','model');
179
-
180
- //let's rename the Synched WordPress list into WordPress Users
181
- $mList=WYSIJA::get('list','model');
182
- $mList->update(array('name'=>'WordPress Users'),array('list_id'=>$mConfig->getValue('importwp_list_id'), 'namekey'=>'users'));
183
-
184
- //remove subscribers that should not be in the WordPress Users list
185
- $querys[]='DELETE FROM `[wysija]user_list` WHERE `list_id` = '.$mConfig->getValue('importwp_list_id').' AND `user_id` in ( SELECT user_id FROM `[wysija]user` where wpuser_id=0 );';
186
- $errors=$this->runUpdateQueries($querys);
187
-
188
- if($errors){
189
- $this->error(implode($errors,"\n"));
190
- return false;
191
- }
192
-
193
- return true;
194
- break;
195
- case '2.2.1':
196
- $helperU=WYSIJA::get('user','helper');
197
- $helperU->cleanWordpressUsersList();
198
-
199
- return true;
200
- break;
201
- case '2.3.3':
202
- update_option('wysija_log', '');
203
-
204
- return true;
205
- break;
206
-
207
-
208
- case '2.3.4':
209
- $model_config=WYSIJA::get('config','model');
210
-
211
- $dbl_optin=(int)$model_config->getValue('confirm_dbleoptin');
212
- //count issue for people who went through all of the versions and now are left with some users in a limbo
213
- $querys[]='UPDATE `[wysija]user_list` as A inner join `[wysija]user` as B on (A.user_id = B.user_id) set A.sub_date= '.time().' where A.sub_date=0 and A.unsub_date=0 and B.status>='.$dbl_optin.';';
214
- $errors=$this->runUpdateQueries($querys);
215
-
216
- if($errors){
217
- $this->error(implode($errors,"\n"));
218
- return false;
219
- }
220
- return true;
221
- break;
222
-
223
- case '2.4':
224
- $queries = array();
225
- $queries[] = 'CREATE TABLE IF NOT EXISTS `[wysija]form` ('.
226
- '`form_id` INT unsigned AUTO_INCREMENT NOT NULL,'.
227
- '`name` tinytext COLLATE utf8_bin,'.
228
- '`data` longtext COLLATE utf8_bin,'.
229
- '`styles` longtext COLLATE utf8_bin,'.
230
- '`subscribed` int(10) unsigned NOT NULL DEFAULT "0",'.
231
- 'PRIMARY KEY (`form_id`)'.
232
- ') ENGINE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci*/';
233
-
234
- $errors = $this->runUpdateQueries($queries);
235
-
236
- if($errors) {
237
- $this->error(implode($errors,"\n"));
238
- return false;
239
- } else {
240
- // the table should be created now. let's make sure:
241
- if((bool)$this->modelWysija->query('SHOW TABLES LIKE "[wysija]form";') === false) {
242
- return false;
243
- } else {
244
- // the form table has been successfully created, let's convert all previously added widgets
245
- $widgets_converted = $this->convert_widgets_to_forms();
246
- if($widgets_converted === 0) {
247
- $helper_install = WYSIJA::get('install', 'helper');
248
- $helper_install->create_default_subscription_form();
249
- }
250
- }
251
- }
252
-
253
- return true;
254
- break;
255
-
256
- case '2.4.1':
257
- $model_email=WYSIJA::get('email','model');
258
- $model_email->setConditions(array('type'=>'2'));
259
- $emails = $model_email->getRows(array('email_id','params'));
260
-
261
- // we don't want parent post notification to send emails
262
- foreach($emails as $email){
263
- $model_email->getParams($email);
264
- if(isset($email['params']) && $email['params']['autonl']['event']=='new-articles'){
265
- $model_queue=WYSIJA::get('queue','model');
266
- $model_queue->delete(array('email_id'=>$email['email_id']));
267
- }
268
- }
269
- return true;
270
-
271
- break;
272
-
273
- case '2.4.3':
274
- // convert data for previously saved forms
275
- /*
276
- * 1. get all forms and loop through each form
277
- * 2. check data['settings']['success_message'] is base64 valid -> decode it
278
- * 3. loop through data['body'], if type="text" -> is base64 valid -> decode it
279
- * 4. save form
280
- */
281
- $model_forms = WYSIJA::get('forms', 'model');
282
- $forms = $model_forms->getRows();
283
- if(is_array($forms) && count($forms) > 0) {
284
-
285
- foreach ($forms as $i => $form) {
286
- $requires_update = false;
287
-
288
- // decode form data
289
- $data = unserialize(base64_decode($form['data']));
290
-
291
- // convert success_message if necessary
292
- if(strlen($data['settings']['success_message']) % 4 === 0 && preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $data['settings']['success_message'])) {
293
- // this is a potential base64 string so decode it
294
- $data['settings']['success_message'] = base64_decode($data['settings']['success_message']);
295
-
296
- $requires_update = true;
297
- }
298
-
299
- // loop through each block
300
- foreach ($data['body'] as $j => $block) {
301
- // in case we find a text block
302
- if($block['type'] === 'text') {
303
- // convert text if necessary
304
- if(strlen($block['params']['text']) % 4 === 0 && preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $block['params']['text'])) {
305
-
306
- // this is a potential base64 string so decode it
307
- $data['body'][$j]['params']['text'] = base64_decode($block['params']['text']);
308
- $requires_update = true;
309
- }
310
- }
311
- }
312
-
313
- // if the form requires update, let's do it
314
- if($requires_update === true) {
315
- $model_forms->reset();
316
- $model_forms->update(array('data' => base64_encode(serialize($data))), array('form_id' => (int)$form['form_id']));
317
- }
318
- }
319
- }
320
-
321
- return true;
322
- break;
323
- case '2.4.4':
324
- // we now have steps in the installation process to make sure we don't rerun two processes
325
- WYSIJA::update_option('installation_step', '16');
326
- return true;
327
- break;
328
-
329
- case '2.5':
330
- // set the default new role caps for super admin and admin
331
- $wp_tools_helper = WYSIJA::get('wp_tools', 'helper');
332
- $wp_tools_helper->set_default_rolecaps();
333
-
334
- // get the main site bounce settings and save them to the global ms settings
335
- if(is_multisite()){
336
- $main_blog_id=1;
337
- switch_to_blog( $main_blog_id );
338
- $main_site_encoded_option = unserialize(base64_decode(get_option( 'wysija' )));
339
- restore_current_blog();
340
-
341
- $data_bounce=array();
342
- foreach($main_site_encoded_option as $key => $val){
343
- if((strpos($key, 'bounce_')!==false || strpos($key, 'bouncing_')!==false) && !empty($val)) $data_bounce['ms_'.$key]=$val;
344
- }
345
-
346
- $data_saved_ms_before= unserialize(base64_decode(get_site_option('ms_wysija')));
347
-
348
- // we don't want to run that multiple times
349
- if(empty($data_saved_ms_before['ms_bounce_host'])){
350
- if(!empty($data_saved_ms_before)) $data_bounce=array_merge($data_saved_ms_before, $data_bounce);
351
- update_site_option('ms_wysija',base64_encode(serialize($data_bounce)));
352
- }
353
-
354
- }
355
-
356
- // Sending method: remove "once a day" & "twice daily", fallback on "every 2 hours"
357
- $model_config = WYSIJA::get('config','model');
358
- $removed_sending_methods = array('twicedaily','daily');
359
- $target_sending_method = 'two_hours';
360
- if(in_array($model_config->getValue('sending_emails_each'), $removed_sending_methods))
361
- $model_config->save(array('sending_emails_each'=>$target_sending_method));
362
- if(in_array($model_config->getValue('ms_sending_emails_each'), $removed_sending_methods))
363
- $model_config->save(array('ms_sending_emails_each'=>$target_sending_method));
364
-
365
- return true;
366
- break;
367
-
368
- case '2.5.2':
369
- $queries = array();
370
- $queries[] = 'UPDATE `[wysija]user_list` AS A JOIN `[wysija]user` AS B ON A.user_id = B.user_id SET A.unsub_date = 0, A.sub_date = '.time().' WHERE STATUS = 1 AND sub_date =0';
371
- $errors = $this->runUpdateQueries( $queries );
372
-
373
- if ( $errors ) {
374
- $this->error( implode( $errors, "\n" ) );
375
- return false;
376
- }
377
- return true;
378
- break;
379
-
380
- case '2.5.5':
381
- $model_email = WYSIJA::get( 'email', 'model', false, 'wysija-newsletters', false );
382
- $model_config = WYSIJA::get( 'config', 'model' );
383
-
384
- $model_email->update(
385
- array(
386
- 'replyto_name' => $model_config->getValue( 'replyto_name' ),
387
- 'replyto_email' => $model_config->getValue( 'replyto_email' ),
388
- ),
389
- array(
390
- 'email_id' => $model_config->getValue( 'confirm_email_id' ),
391
- )
392
- );
393
- return true;
394
- break;
395
-
396
- case '2.5.9.6':
397
- $alter_queries = array();
398
- $alter_queries[] = 'ALTER TABLE [wysija]user ADD COLUMN `domain` VARCHAR(255);';
399
- $errors = $this->run_update_queries( $alter_queries );
400
-
401
- if ( $this->does_column_exist( 'domain', '[wysija]user' ) ) {
402
- $queries = array();
403
- $queries[] = "UPDATE [wysija]user SET `domain` = SUBSTRING(`email`,LOCATE('@',`email`)+1);";
404
- $errors = $this->run_update_queries( $queries );
405
- if ( $errors ) {
406
- $this->error( implode( $errors, "\n" ) );
407
- return false;
408
- }
409
-
410
- } else {
411
- if(!empty($errors)){
412
- $this->error( implode( $errors, "\n" ) );
413
- }
414
- return false;
415
- }
416
-
417
- return true;
418
- break;
419
-
420
- case '2.5.9.7':
421
- $queries = array();
422
-
423
- //add column namekey to
424
- $model_config = WYSIJA::get( 'config', 'model' );
425
- $columns_to_add_to_user_table = array(
426
- 'confirmed_ip' => 'VARCHAR(100) NOT NULL DEFAULT 0',
427
- 'confirmed_at' => 'INT unsigned NULL',
428
- 'last_opened' => 'INT unsigned NULL',
429
- 'last_clicked' => 'INT unsigned NULL',
430
- );
431
-
432
- foreach ( $columns_to_add_to_user_table as $column_to_add => $sql_definition ){
433
- if ( ! $this->modelWysija->query( "SHOW COLUMNS FROM `[wysija]user` LIKE '{$column_to_add}';" ) ){
434
- $queries[] = "ALTER TABLE `[wysija]user` ADD `{$column_to_add}` {$sql_definition};";
435
- }
436
- }
437
-
438
- // Custom Fields main table.
439
- $queries[] = 'CREATE TABLE IF NOT EXISTS `[wysija]custom_field` ('.
440
- '`id` mediumint(9) NOT NULL AUTO_INCREMENT,'.
441
- '`name` tinytext NOT NULL,'.
442
- '`type` tinytext NOT NULL,'.
443
- '`required` tinyint(1) DEFAULT "0" NOT NULL,'.
444
- '`settings` text DEFAULT NULL,'.
445
- 'PRIMARY KEY (`id`)'.
446
- ') ENGINE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci*/';
447
-
448
- $errors = $this->runUpdateQueries( $queries );
449
-
450
- if ( $errors ) {
451
- $this->error( implode( $errors, "\n" ) );
452
- return false;
453
- }
454
- // update the new page_selection options with the default MailPoet's page
455
- $default_page_id = $model_config->getValue( 'confirm_email_link' );
456
- $model_config->save(
457
- array(
458
- 'confirmation_page' => $default_page_id,
459
- 'unsubscribe_page' => $default_page_id,
460
- 'subscriptions_page' => $default_page_id,
461
- )
462
- );
463
-
464
- return true;
465
- break;
466
-
467
- case '2.6':
468
- case '2.6.0.8':
469
- $queries = array();
470
-
471
- // Correct links which are missing 'h'
472
- $queries[] = "UPDATE `[wysija]url` SET `url` = CONCAT('h', `url`) WHERE `url` LIKE 'ttp://%'";
473
- $errors = $this->run_update_queries( $queries );
474
-
475
- if ( $errors ) {
476
- $this->error( implode( $errors, "\n" ) );
477
- return false;
478
- }
479
-
480
- return true;
481
- break;
482
-
483
- default:
484
- return false;
485
- }
486
- return false;
487
- }
488
-
489
-
490
- /**
491
- *
492
- * @return type
493
- */
494
- function check(){
495
-
496
- //we can go there if this is not a new installation and it's an admin
497
- if(WYSIJA::current_user_can('switch_themes') ){
498
-
499
- // check that the redirection is only processed from wysija's interfaces
500
- if(isset($_REQUEST['page']) && in_array($_REQUEST['page'], array('wysija_config','wysija_campaigns','wysija_subscribers'))){
501
-
502
- // we are earlier than 1.1 or earlier than the current file version so we can run what's needed to reach the right version number
503
- $config=WYSIJA::get('config','model');
504
-
505
- if(!$config->getValue('wysija_db_version') || version_compare($config->getValue('wysija_db_version'),WYSIJA::get_version()) < 0){
506
- $this->update(WYSIJA::get_version());
507
- }
508
- // once the update procedure is done we can redirect to the what's new/fixed page
509
- $noredirect=false;
510
-
511
- //get the right option name based on the type of site we're in
512
- $whats_new_option='wysija_whats_new';
513
- $is_multisite=is_multisite();
514
- $is_network_admin=WYSIJA::current_user_can('manage_network');
515
-
516
- // check that in case of a multisite configuration only the network admin sees that update page
517
- if($is_multisite){
518
- if($is_network_admin){
519
- $whats_new_option='ms_wysija_whats_new';
520
- }else {
521
- return;
522
- }
523
- }
524
-
525
- // a whats_new option is set and it is less than the current version so that means we need to display it
526
- if((!$config->getValue($whats_new_option) || version_compare($config->getValue($whats_new_option),WYSIJA::get_version()) < 0)){
527
-
528
- //if there is an action set and it's one of those then we just don't redirect
529
- if(isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('whats_new','welcome_new','activate-plugin'))) $noredirect=true;
530
-
531
- if(!$noredirect) {
532
- $timeInstalled=$config->getValue('installed_time')+3600;
533
- //if it is a fresh install then it redirects to the welcome screen otherwise to the update one
534
- if(time()>$timeInstalled){
535
- WYSIJA::redirect('admin.php?page=wysija_campaigns&action=whats_new');
536
- }else{
537
- WYSIJA::redirect('admin.php?page=wysija_campaigns&action=welcome_new');
538
- }
539
- }
540
- }
541
- }
542
-
543
-
544
- }
545
- }
546
-
547
- /**
548
- * this is a central function which will run every update until the current version
549
- * @param string $version_current // not used since we use the wysija_db_version
550
- * @return boolean
551
- */
552
- function update($version_current){
553
- $config=WYSIJA::get('config','model');
554
- $config->getValue('wysija_db_version');
555
-
556
- foreach($this->updates as $version){
557
- if(version_compare($config->getValue('wysija_db_version'),$version) < 0){
558
- if(!$this->runUpdate($version)){
559
- $this->error(sprintf(__('Update procedure to MailPoet version "%1$s" failed!',WYSIJA),$version),true);
560
- return false;
561
- }else{
562
- $config->save(array('wysija_db_version' => $version));
563
- }
564
- }
565
- }
566
-
567
- }
568
-
569
- /**
570
- * return the failed queries
571
- * @param type $queries
572
- * @return type
573
- * @deprecated since version 2.6
574
- */
575
- function runUpdateQueries($queries){
576
- return $this->run_update_queries($queries);
577
- }
578
-
579
- /**
580
- * run a list of specified queries and return a list of failed queries
581
- * @param array $queries
582
- * <pre>
583
- * array(
584
- * 0 => full_query_1,
585
- * 1 => full_query_2,
586
- * ...
587
- * n => full_query_n
588
- * )
589
- *
590
- * @return false or array
591
- * <pre>
592
- * array(
593
- * 0 => full_query_1,
594
- * 1 => full_query_2,
595
- * ...
596
- * n => full_query_n
597
- * )
598
- */
599
- function run_update_queries($queries) {
600
- $failed = array();
601
-
602
- //we use mysql query instead of wordpress query to make sure we don't miss the sql errors
603
- global $wpdb;
604
- foreach($queries as $query){
605
- $query=str_replace('[wysija]',$this->modelWysija->getPrefix(),$query);
606
- $last_error = $wpdb->last_error;
607
- $wpdb->query($query);
608
-
609
- if( (empty($wpdb->result) || !$wpdb->result) && !empty( $wpdb->last_error ) && $last_error != $wpdb->last_error ){
610
- $failed[]= $wpdb->last_error." ($query)";
611
- }
612
- }
613
- if($failed) return $failed;
614
- else return false;
615
- }
616
-
617
- /**
618
- * Detects if a column already exsits in a table
619
- * @global wpdb $wpdb
620
- * @param string $column_name name of the column
621
- * @param string $table_name name of a table which the column should belong to
622
- * @return boolean
623
- */
624
- protected function does_column_exist($column_name, $table_name) {
625
- global $wpdb;
626
- $sql = "SHOW COLUMNS FROM `$table_name` LIKE '$column_name';";
627
-
628
- $results = $wpdb->get_results(str_replace('[wysija]',$this->modelWysija->getPrefix(),$sql));
629
-
630
- return (!empty($results));
631
- }
632
-
633
-
634
- /**
635
- * Version 2.4 introduces the Form Editor
636
- * This function converts all previously saved subscription widgets into forms
637
- *
638
- */
639
- function convert_widget_to_form($values = array()) {
640
- // $values needs to be an array
641
- if(!is_array($values)) return false;
642
-
643
- // make sure we don't convert wysija forms into wysija forms.... that would be silly isn't it?
644
- if(isset($values['form']) && (int)$values['form'] > 0) return false;
645
-
646
- $settings = $body = array();
647
-
648
- // SETTINGS
649
- // specify who selects the list (user | admin)
650
- if($values['autoregister'] === 'not_auto_register') {
651
- $settings['lists_selected_by'] = 'admin';
652
- } else {
653
- // the user will select his own list so let's add the list selection
654
- $settings['lists_selected_by'] = 'user';
655
- }
656
-
657
- // lists
658
- $settings['lists'] = $values['lists'];
659
-
660
- // success message
661
- $settings['on_success'] = 'message';
662
- $settings['success_message'] = $values['success'];
663
-
664
- // are the labels in or out?
665
- if($values['labelswithin'] === 'labels_within') {
666
- $label_within = true;
667
- } else {
668
- $label_within = false;
669
- }
670
-
671
- // The order of the fields were: firstname, lastname, email, list_selection, submit
672
- $blocks = array();
673
-
674
- // INSTRUCTIONS
675
- if(isset($values['instruction']) && strlen(trim($values['instruction'])) > 0) {
676
- $blocks[] = array(
677
- 'params' => array(
678
- 'text' => base64_encode($values['instruction']),
679
- ),
680
- 'type' => 'text',
681
- 'field' => 'text',
682
- 'name' => __('Random text or instructions', WYSIJA)
683
- );
684
- }
685
-
686
- // CUSTOM FIELDS (firstname, lastname, email)
687
- $has_email_field = false;
688
- foreach($values['customfields'] as $field => $params) {
689
- switch($field) {
690
- case 'firstname':
691
- $name = __('First name', WYSIJA);
692
- break;
693
- case 'lastname':
694
- $name = __('Last name', WYSIJA);
695
- break;
696
- case 'email':
697
- $has_email_field = true;
698
- $name = __('Email', WYSIJA);
699
- break;
700
-
701
- }
702
-
703
- $blocks[] = array(
704
- 'name' => $name,
705
- 'type' => 'input',
706
- 'field' => $field,
707
- 'params' => array(
708
- 'label' => $params['label'],
709
- 'required' => 1,
710
- 'label_within' => (int)$label_within
711
- )
712
- );
713
- }
714
-
715
- // make really sure we have an email field
716
- if($has_email_field === false) {
717
- $blocks[] = array(
718
- 'name' => __('Email', WYSIJA),
719
- 'type' => 'input',
720
- 'field' => 'email',
721
- 'params' => array(
722
- 'label' => __('Email', WYSIJA),
723
- 'required' => 1,
724
- 'label_within' => (int)$label_within
725
- )
726
- );
727
- }
728
-
729
- // LIST SELECTION (only if the user can pick his own lists)
730
- if($settings['lists_selected_by'] === 'user') {
731
-
732
- $list_values = array();
733
-
734
- foreach($settings['lists'] as $list_id) {
735
- $list_values[] = array(
736
- 'list_id' => $list_id,
737
- 'is_checked' => 1
738
- );
739
- }
740
- $blocks[] = array(
741
- 'name' => __('List selection', WYSIJA),
742
- 'type' => 'list',
743
- 'field' => 'list',
744
- 'params' => array(
745
- 'label' => __('Select list(s):', WYSIJA),
746
- 'values' => $list_values
747
- )
748
- );
749
- }
750
-
751
- // ADD SUBMIT BUTTON
752
- $submit_label = __('Subscribe!', WYSIJA);
753
- if(isset($values['submit']) && strlen(trim($values['submit'])) > 0) {
754
- $submit_label = $values['submit'];
755
- }
756
- $blocks[] = array(
757
- 'name' => __('Submit', WYSIJA),
758
- 'type' => 'submit',
759
- 'field' => 'submit',
760
- 'params' => array(
761
- 'label' => $submit_label
762
- )
763
- );
764
-
765
- // Format body based on blocks
766
- for($i = 0, $count = count($blocks); $i < $count; $i++) {
767
- $body['block-'.($i + 1)] = array_merge($blocks[$i], array('position' => ($i + 1)));
768
- }
769
-
770
- // set default form name
771
- $form_name = __('New Form', WYSIJA);
772
-
773
- // check if title exists and override default form name
774
- if(isset($values['title']) && strlen(trim($values['title'])) > 0) {
775
- $form_name = $values['title'];
776
- }
777
-
778
- // form engine helper
779
- $helper_form_engine = WYSIJA::get('form_engine', 'helper');
780
-
781
- // insert form into db
782
- $model_forms = WYSIJA::get('forms', 'model');
783
- $model_forms->reset();
784
- // get form id back because it's required to generate the html form
785
- $form_id = $model_forms->insert(array('name' => $form_name));
786
-
787
- if((int)$form_id > 0) {
788
- $model_forms->reset();
789
- // set form engine data
790
- $helper_form_engine->set_data(array(
791
- 'form_id' => (int)$form_id,
792
- 'settings' => $settings,
793
- 'body' => $body
794
- ));
795
-
796
- // update form in database
797
- $model_forms->update(array('data' => $helper_form_engine->get_encoded('data')), array('form_id' => $form_id));
798
-
799
- return $form_id;
800
- } else {
801
- return false;
802
- }
803
- }
804
-
805
- /**
806
- * very important function to convert subscription widget to our new forms in 2.4
807
- * @return int
808
- */
809
- function convert_widgets_to_forms() {
810
- $widgets_converted = 0;
811
-
812
- // get all wysija widgets
813
- $widgets = get_option('widget_wysija');
814
-
815
- foreach($widgets as $key => &$values) {
816
- $form_id = $this->convert_widget_to_form($values);
817
- if($form_id!==false) {
818
- $values['default_form'] = $form_id;
819
- $widgets_converted++;
820
- }
821
- }
822
-
823
- update_option('widget_wysija',$widgets);
824
- return $widgets_converted;
825
- }
826
-
827
- /**
828
- * Deprecated Methods
829
- */
830
- function checkForNewVersion(){
831
- /*
832
- $current = get_site_transient( 'update_plugins' );
833
-
834
- if ( !isset( $current->response[ $file ] ) )
835
- return false;
836
-
837
- $r = $current->response[ $file ];
838
- $default_headers = array(
839
- 'Name' => 'Plugin Name',
840
- 'PluginURI' => 'Plugin URI',
841
- 'Version' => 'Version',
842
- 'Description' => 'Description',
843
- 'Author' => 'Author',
844
- 'AuthorURI' => 'Author URI',
845
- 'TextDomain' => 'Text Domain',
846
- 'DomainPath' => 'Domain Path',
847
- 'Network' => 'Network',
848
- );
849
-
850
- $plugin_data = get_file_data( WP_PLUGIN_DIR . DS.$file, $default_headers, 'plugin' );
851
-
852
- $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
853
- $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
854
-
855
- $details_url = self_admin_url((is_multisite()? 'network/' : '' ).'plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '&section=changelog&TB_iframe=true&width=600&height=400');
856
-
857
- if(((is_multisite() && current_user_can('manage_network') ) || current_user_can('update_plugins') ) && !empty($r->package) ){
858
- $this->notice(
859
- sprintf(
860
- __('Hey! %1$s has an update (version %4$s), <a href="%5$s">click here to update</a>.', WYSIJA)
861
- , '<strong>'.$plugin_name.'</strong>',
862
- esc_url($details_url),
863
- esc_attr($plugin_name),
864
- $r->new_version,
865
- wp_nonce_url( self_admin_url('update.php?action=upgrade-plugin&plugin=') . $file, 'upgrade-plugin_' . $file) ),true,true);
866
- }
867
- */
868
- }
869
-
870
- /**
871
- * in some cases scenario our update helper can't be run simply because a version is missing
872
- */
873
- function repair_settings(){
874
- static $is_repairing = FALSE;
875
-
876
- if($is_repairing === FALSE){
877
- $is_repairing = TRUE;
878
-
879
- // set installed as true
880
- $values['installed'] = true;
881
- // set installed_time: minus 7200 on it so that we don't display the welcome page again on the
882
- // view condition in the check() function above WYSIJA::redirect('admin.php?page=wysija_campaigns&action=welcome_new');
883
- $values['installed_time'] = time() - 7200;
884
-
885
- // find our current db version
886
- $values['wysija_db_version'] = $this->_find_db_version();
887
-
888
- // save the missing settings to repair the installation
889
- $model_config = WYSIJA::get('config','model');
890
- $model_config->save($values);
891
-
892
- }
893
-
894
- }
895
-
896
- /**
897
- * find out what is the db version based on the existing columns of some tables
898
- */
899
- private function _find_db_version(){
900
- $model_wysija = new WYSIJA_model();
901
-
902
- // test against 2.0 and set it to 1.1 if true
903
- $test = $model_wysija->query('get_res', "SHOW COLUMNS FROM `[wysija]email` like 'modified_at';" );
904
- if(empty($test)){
905
- return '1.1';
906
- }
907
- // test against 2.4 and set it to 2.3.4 if true
908
- $test = $model_wysija->query('get_res', "SHOW COLUMNS FROM `[wysija]form`;" );
909
- if(empty($test)){
910
- return '2.3.4';
911
- }
912
-
913
- // test against 2.5.9.6 and set it to 2.5.5 if true
914
- $test = $model_wysija->query('get_res', "SHOW COLUMNS FROM `[wysija]user` like 'domain';" );
915
- if(empty($test)){
916
- return '2.5.5';
917
- }
918
- // test against 2.5.9.7 and set it to 2.5.9.6 if true
919
- $test = $model_wysija->query('get_res', "SHOW COLUMNS FROM `[wysija]user` like 'last_opened';" );
920
- if(empty($test)){
921
- return '2.5.9.6';
922
- }
923
-
924
- return WYSIJA::get_version();
925
- }
926
- }
1
+ <?php
2
+ defined( 'WYSIJA' ) or die( 'Restricted access' );
3
+
4
+ class WYSIJA_help_update extends WYSIJA_object {
5
+
6
+ function WYSIJA_help_update(){
7
+ $this->modelWysija = new WYSIJA_model();
8
+
9
+ //IMPORTANT when making db updated or running update processes, add the version and in the big switch below in the runUpdate() method
10
+ $this->updates = array(
11
+ '1.1',
12
+ '2.0','2.1','2.1.6','2.1.7','2.1.8',
13
+ '2.2','2.2.1',
14
+ '2.3.3','2.3.4',
15
+ '2.4', '2.4.1', '2.4.3','2.4.4',
16
+ '2.5','2.5.2','2.5.5','2.5.9.6', '2.5.9.7',
17
+ '2.6', '2.6.0.8',
18
+ );
19
+ }
20
+
21
+ function runUpdate( $version ) {
22
+ //run all the updates missing since the db-version
23
+ //foreach ... $this->updateVersion($version);
24
+ switch($version){
25
+ case '1.1':
26
+ //add column namekey to
27
+ $model_config=WYSIJA::get('config','model');
28
+ if(!$this->modelWysija->query("SHOW COLUMNS FROM `[wysija]list` LIKE 'namekey';")){
29
+ $querys[]='ALTER TABLE `[wysija]list` ADD `namekey` VARCHAR( 255 ) NULL;';
30
+ }
31
+
32
+ $querys[]="UPDATE `[wysija]list` SET `namekey` = 'users' WHERE `list_id` =".$model_config->getValue('importwp_list_id').";";
33
+ $errors=$this->runUpdateQueries($querys);
34
+
35
+ $importHelp=WYSIJA::get('plugins_import','helper');
36
+ $importHelp->testPlugins();
37
+
38
+ // move data
39
+ $installHelper = WYSIJA::get('install', 'helper');
40
+ $installHelper->moveData('dividers');
41
+ $installHelper->moveData('bookmarks');
42
+ $installHelper->moveData('themes');
43
+
44
+ if($errors){
45
+ $this->error(implode($errors,"\n"));
46
+ return false;
47
+ }
48
+ return true;
49
+ break;
50
+ case '2.0':
51
+ //add column namekey to
52
+ $model_config=WYSIJA::get('config','model');
53
+ if(!$this->modelWysija->query("SHOW COLUMNS FROM `[wysija]email` LIKE 'modified_at';")){
54
+ $querys[]="ALTER TABLE `[wysija]email` ADD `modified_at` INT UNSIGNED NOT NULL DEFAULT '0';";
55
+ }
56
+ if(!$model_config->getValue('update_error_20')){
57
+ $querys[]="UPDATE `[wysija]email` SET `modified_at` = `sent_at` WHERE `sent_at`>=0;";
58
+ $querys[]="UPDATE `[wysija]email` SET `modified_at` = `created_at` WHERE `modified_at`='0';";
59
+ $querys[]="UPDATE `[wysija]email` SET `status` = '99' WHERE `status` ='1';";//change sending status from 1 to 99
60
+ }
61
+
62
+
63
+ $errors=$this->runUpdateQueries($querys);
64
+
65
+ if($errors){
66
+ $model_config->save(array('update_error_20'=>true));
67
+ $this->error(implode($errors,"\n"));
68
+ return false;
69
+ }
70
+ return true;
71
+ break;
72
+ case '2.1':
73
+ $model_config=WYSIJA::get('config','model');
74
+ if(!$model_config->getValue('update_error_21')){
75
+ $modelEmails=WYSIJA::get('email','model');
76
+ $modelEmails->reset();
77
+ $emailsLoaded=$modelEmails->get(array('subject','email_id'),array('status'=>2,'type'=>1));
78
+
79
+ //set the default new role caps for super admin and admin
80
+ $wp_tools_helper = WYSIJA::get('wp_tools', 'helper');
81
+ $wp_tools_helper->set_default_rolecaps();
82
+
83
+ //based on the config values for role_campaign and role_subscribers
84
+ //let's give the each core roles the right capability
85
+
86
+ $minimumroles=array('role_campaign'=>'wysija_newsletters','role_subscribers'=>'wysija_subscribers');
87
+
88
+ foreach($minimumroles as $rolename=>$capability){
89
+ $rolesetting=$model_config->getValue($rolename);
90
+ switch($rolesetting){
91
+ case 'switch_themes':
92
+ $keyrole=1;
93
+ break;
94
+ case 'moderate_comments':
95
+ $keyrole=3;
96
+ break;
97
+ case 'upload_files':
98
+ $keyrole=4;
99
+ break;
100
+ case 'edit_posts':
101
+ $keyrole=5;
102
+ break;
103
+ case 'read':
104
+ $keyrole=6;
105
+ break;
106
+ default:
107
+ $keyrole=false;
108
+ }
109
+
110
+ if(!$keyrole){
111
+ //add the setting to a custom role
112
+ $role = get_role($rolesetting);
113
+ //added for invalid roles ...
114
+ if($role){
115
+ $role->add_cap( $capability );
116
+ }
117
+ }else{
118
+ //get all the minimum roles getting that capability
119
+ $editable_roles=$wp_tools_helper->wp_get_roles();
120
+ $startcount=1;
121
+ if(!isset($editable_roles[$startcount])) $startcount++;
122
+ for($i = $startcount; $i <= $keyrole; $i++) {
123
+ $rolename=$editable_roles[$i];
124
+ //add the setting to a custom role
125
+ $role = get_role($rolename['key']);
126
+ $role->add_cap( $capability );
127
+ }
128
+ }
129
+ }
130
+ $wptoolboxs = WYSIJA::get('toolbox', 'helper');
131
+ $model_config->save(array('dkim_domain'=>$wptoolboxs->_make_domain_name()));
132
+ }
133
+
134
+ if(!$this->modelWysija->query("SHOW COLUMNS FROM `[wysija]list` LIKE 'is_public';")){
135
+ $querys[]="ALTER TABLE `[wysija]list` ADD `is_public` TINYINT UNSIGNED NOT NULL DEFAULT 0;";
136
+ $errors=$this->runUpdateQueries($querys);
137
+ if($errors){
138
+ $model_config->save(array('update_error_21'=>true));
139
+ $this->error(implode($errors,"\n"));
140
+ return false;
141
+ }
142
+ }
143
+ return true;
144
+ break;
145
+ case '2.1.6':
146
+ $querys[]="UPDATE `[wysija]user_list` as A inner join `[wysija]user` as B on (A.user_id= B.user_id) set A.sub_date= B.created_at where A.sub_date=0 and A.unsub_date=0 and B.status>-1;";
147
+ $errors=$this->runUpdateQueries($querys);
148
+
149
+ if($errors){
150
+ $this->error(implode($errors,"\n"));
151
+ return false;
152
+ }
153
+ return true;
154
+ break;
155
+ case '2.1.7':
156
+ $querys[]='UPDATE `[wysija]user_list` as A inner join `[wysija]user` as B on (A.user_id= B.user_id) set A.sub_date= '.time().' where A.sub_date=0 and B.status>-1;';
157
+ $errors=$this->runUpdateQueries($querys);
158
+
159
+ if($errors){
160
+ $this->error(implode($errors,"\n"));
161
+ return false;
162
+ }
163
+ return true;
164
+ break;
165
+ case '2.1.8':
166
+ $mConfig=WYSIJA::get('config','model');
167
+
168
+ $querys[]='UPDATE `[wysija]user_list` as A set A.sub_date= '.time().' where A.list_id='.$mConfig->getValue('importwp_list_id').';';
169
+ $errors=$this->runUpdateQueries($querys);
170
+
171
+ if($errors){
172
+ $this->error(implode($errors,"\n"));
173
+ return false;
174
+ }
175
+ return true;
176
+ break;
177
+ case '2.2':
178
+ $mConfig=WYSIJA::get('config','model');
179
+
180
+ //let's rename the Synched WordPress list into WordPress Users
181
+ $mList=WYSIJA::get('list','model');
182
+ $mList->update(array('name'=>'WordPress Users'),array('list_id'=>$mConfig->getValue('importwp_list_id'), 'namekey'=>'users'));
183
+
184
+ //remove subscribers that should not be in the WordPress Users list
185
+ $querys[]='DELETE FROM `[wysija]user_list` WHERE `list_id` = '.$mConfig->getValue('importwp_list_id').' AND `user_id` in ( SELECT user_id FROM `[wysija]user` where wpuser_id=0 );';
186
+ $errors=$this->runUpdateQueries($querys);
187
+
188
+ if($errors){
189
+ $this->error(implode($errors,"\n"));
190
+ return false;
191
+ }
192
+
193
+ return true;
194
+ break;
195
+ case '2.2.1':
196
+ $helperU=WYSIJA::get('user','helper');
197
+ $helperU->cleanWordpressUsersList();
198
+
199
+ return true;
200
+ break;
201
+ case '2.3.3':
202
+ update_option('wysija_log', $optionlog);
203
+
204
+ return true;
205
+ break;
206
+
207
+
208
+ case '2.3.4':
209
+ $model_config=WYSIJA::get('config','model');
210
+
211
+ $dbl_optin=(int)$model_config->getValue('confirm_dbleoptin');
212
+ //count issue for people who went through all of the versions and now are left with some users in a limbo
213
+ $querys[]='UPDATE `[wysija]user_list` as A inner join `[wysija]user` as B on (A.user_id = B.user_id) set A.sub_date= '.time().' where A.sub_date=0 and A.unsub_date=0 and B.status>='.$dbl_optin.';';
214
+ $errors=$this->runUpdateQueries($querys);
215
+
216
+ if($errors){
217
+ $this->error(implode($errors,"\n"));
218
+ return false;
219
+ }
220
+ return true;
221
+ break;
222
+
223
+ case '2.4':
224
+ $queries = array();
225
+ $queries[] = 'CREATE TABLE IF NOT EXISTS `[wysija]form` ('.
226
+ '`form_id` INT unsigned AUTO_INCREMENT NOT NULL,'.
227
+ '`name` tinytext COLLATE utf8_bin,'.
228
+ '`data` longtext COLLATE utf8_bin,'.
229
+ '`styles` longtext COLLATE utf8_bin,'.
230
+ '`subscribed` int(10) unsigned NOT NULL DEFAULT "0",'.
231
+ 'PRIMARY KEY (`form_id`)'.
232
+ ') ENGINE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci*/';
233
+
234
+ $errors = $this->runUpdateQueries($queries);
235
+
236
+ if($errors) {
237
+ $this->error(implode($errors,"\n"));
238
+ return false;
239
+ } else {
240
+ // the table should be created now. let's make sure:
241
+ if((bool)$this->modelWysija->query('SHOW TABLES LIKE "[wysija]form";') === false) {
242
+ return false;
243
+ } else {
244
+ // the form table has been successfully created, let's convert all previously added widgets
245
+ $widgets_converted = $this->convert_widgets_to_forms();
246
+ if($widgets_converted === 0) {
247
+ $helper_install = WYSIJA::get('install', 'helper');
248
+ $helper_install->create_default_subscription_form();
249
+ }
250
+ }
251
+ }
252
+
253
+ return true;
254
+ break;
255
+
256
+ case '2.4.1':
257
+ $model_email=WYSIJA::get('email','model');
258
+ $model_email->setConditions(array('type'=>'2'));
259
+ $emails = $model_email->getRows(array('email_id','params'));
260
+
261
+ // we don't want parent post notification to send emails
262
+ foreach($emails as $email){
263
+ $model_email->getParams($email);
264
+ if(isset($email['params']) && $email['params']['autonl']['event']=='new-articles'){
265
+ $model_queue=WYSIJA::get('queue','model');
266
+ $model_queue->delete(array('email_id'=>$email['email_id']));
267
+ }
268
+ }
269
+ return true;
270
+
271
+ break;
272
+
273
+ case '2.4.3':
274
+ // convert data for previously saved forms
275
+ /*
276
+ * 1. get all forms and loop through each form
277
+ * 2. check data['settings']['success_message'] is base64 valid -> decode it
278
+ * 3. loop through data['body'], if type="text" -> is base64 valid -> decode it
279
+ * 4. save form
280
+ */
281
+ $model_forms = WYSIJA::get('forms', 'model');
282
+ $forms = $model_forms->getRows();
283
+ if(is_array($forms) && count($forms) > 0) {
284
+
285
+ foreach ($forms as $i => $form) {
286
+ $requires_update = false;
287
+
288
+ // decode form data
289
+ $data = unserialize(base64_decode($form['data']));
290
+
291
+ // convert success_message if necessary
292
+ if(strlen($data['settings']['success_message']) % 4 === 0 && preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $data['settings']['success_message'])) {
293
+ // this is a potential base64 string so decode it
294
+ $data['settings']['success_message'] = base64_decode($data['settings']['success_message']);
295
+
296
+ $requires_update = true;
297
+ }
298
+
299
+ // loop through each block
300
+ foreach ($data['body'] as $j => $block) {
301
+ // in case we find a text block
302
+ if($block['type'] === 'text') {
303
+ // convert text if necessary
304
+ if(strlen($block['params']['text']) % 4 === 0 && preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $block['params']['text'])) {
305
+
306
+ // this is a potential base64 string so decode it
307
+ $data['body'][$j]['params']['text'] = base64_decode($block['params']['text']);
308
+ $requires_update = true;
309
+ }
310
+ }
311
+ }
312
+
313
+ // if the form requires update, let's do it
314
+ if($requires_update === true) {
315
+ $model_forms->reset();
316
+ $model_forms->update(array('data' => base64_encode(serialize($data))), array('form_id' => (int)$form['form_id']));
317
+ }
318
+ }
319
+ }
320
+
321
+ return true;
322
+ break;
323
+ case '2.4.4':
324
+ // we now have steps in the installation process to make sure we don't rerun two processes
325
+ WYSIJA::update_option('installation_step', '16');
326
+ return true;
327
+ break;
328
+
329
+ case '2.5':
330
+ // set the default new role caps for super admin and admin
331
+ $wp_tools_helper = WYSIJA::get('wp_tools', 'helper');
332
+ $wp_tools_helper->set_default_rolecaps();
333
+
334
+ // get the main site bounce settings and save them to the global ms settings
335
+ if(is_multisite()){
336
+ $main_blog_id=1;
337
+ switch_to_blog( $main_blog_id );
338
+ $main_site_encoded_option = unserialize(base64_decode(get_option( 'wysija' )));
339
+ restore_current_blog();
340
+
341
+ $data_bounce=array();
342
+ foreach($main_site_encoded_option as $key => $val){
343
+ if((strpos($key, 'bounce_')!==false || strpos($key, 'bouncing_')!==false) && !empty($val)) $data_bounce['ms_'.$key]=$val;
344
+ }
345
+
346
+ $data_saved_ms_before= unserialize(base64_decode(get_site_option('ms_wysija')));
347
+
348
+ // we don't want to run that multiple times
349
+ if(empty($data_saved_ms_before['ms_bounce_host'])){
350
+ if(!empty($data_saved_ms_before)) $data_bounce=array_merge($data_saved_ms_before, $data_bounce);
351
+ update_site_option('ms_wysija',base64_encode(serialize($data_bounce)));
352
+ }
353
+
354
+ }
355
+
356
+ // Sending method: remove "once a day" & "twice daily", fallback on "every 2 hours"
357
+ $model_config = WYSIJA::get('config','model');
358
+ $removed_sending_methods = array('twicedaily','daily');
359
+ $target_sending_method = 'two_hours';
360
+ if(in_array($model_config->getValue('sending_emails_each'), $removed_sending_methods))
361
+ $model_config->save(array('sending_emails_each'=>$target_sending_method));
362
+ if(in_array($model_config->getValue('ms_sending_emails_each'), $removed_sending_methods))
363
+ $model_config->save(array('ms_sending_emails_each'=>$target_sending_method));
364
+
365
+ return true;
366
+ break;
367
+
368
+ case '2.5.2':
369
+ $queries = array();
370
+ $queries[] = 'UPDATE `[wysija]user_list` AS A JOIN `[wysija]user` AS B ON A.user_id = B.user_id SET A.unsub_date = 0, A.sub_date = '.time().' WHERE STATUS = 1 AND sub_date =0';
371
+ $errors = $this->runUpdateQueries( $queries );
372
+
373
+ if ( $errors ) {
374
+ $this->error( implode( $errors, "\n" ) );
375
+ return false;
376
+ }
377
+ return true;
378
+ break;
379
+
380
+ case '2.5.5':
381
+ $model_email = WYSIJA::get( 'email', 'model', false, 'wysija-newsletters', false );
382
+ $model_config = WYSIJA::get( 'config', 'model' );
383
+
384
+ $model_email->update(
385
+ array(
386
+ 'replyto_name' => $model_config->getValue( 'replyto_name' ),
387
+ 'replyto_email' => $model_config->getValue( 'replyto_email' ),
388
+ ),
389
+ array(
390
+ 'email_id' => $model_config->getValue( 'confirm_email_id' ),
391
+ )
392
+ );
393
+ return true;
394
+ break;
395
+
396
+ case '2.5.9.6':
397
+ $alter_queries = array();
398
+ $alter_queries[] = 'ALTER TABLE [wysija]user ADD COLUMN `domain` VARCHAR(255);';
399
+ $errors = $this->run_update_queries( $alter_queries );
400
+
401
+ if ( $this->does_column_exist( 'domain', '[wysija]user' ) ) {
402
+ $queries = array();
403
+ $queries[] = "UPDATE [wysija]user SET `domain` = SUBSTRING(`email`,LOCATE('@',`email`)+1);";
404
+ $errors = $this->run_update_queries( $queries );
405
+ if ( $errors ) {
406
+ $this->error( implode( $errors, "\n" ) );
407
+ return false;
408
+ }
409
+
410
+ } else {
411
+ if(!empty($errors)){
412
+ $this->error( implode( $errors, "\n" ) );
413
+ }
414
+ return false;
415
+ }
416
+
417
+ return true;
418
+ break;
419
+
420
+ case '2.5.9.7':
421
+ $queries = array();
422
+
423
+ //add column namekey to
424
+ $model_config = WYSIJA::get( 'config', 'model' );
425
+ $columns_to_add_to_user_table = array(
426
+ 'confirmed_ip' => 'VARCHAR(100) NOT NULL DEFAULT 0',
427
+ 'confirmed_at' => 'INT unsigned NULL',
428
+ 'last_opened' => 'INT unsigned NULL',
429
+ 'last_clicked' => 'INT unsigned NULL',
430
+ );
431
+
432
+ foreach ( $columns_to_add_to_user_table as $column_to_add => $sql_definition ){
433
+ if ( ! $this->modelWysija->query( "SHOW COLUMNS FROM `[wysija]user` LIKE '{$column_to_add}';" ) ){
434
+ $queries[] = "ALTER TABLE `[wysija]user` ADD `{$column_to_add}` {$sql_definition};";
435
+ }
436
+ }
437
+
438
+ // Custom Fields main table.
439
+ $queries[] = 'CREATE TABLE IF NOT EXISTS `[wysija]custom_field` ('.
440
+ '`id` mediumint(9) NOT NULL AUTO_INCREMENT,'.
441
+ '`name` tinytext NOT NULL,'.
442
+ '`type` tinytext NOT NULL,'.
443
+ '`required` tinyint(1) DEFAULT "0" NOT NULL,'.
444
+ '`settings` text DEFAULT NULL,'.
445
+ 'PRIMARY KEY (`id`)'.
446
+ ') ENGINE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci*/';
447
+
448
+ $errors = $this->runUpdateQueries( $queries );
449
+
450
+ if ( $errors ) {
451
+ $this->error( implode( $errors, "\n" ) );
452
+ return false;
453
+ }
454
+ // update the new page_selection options with the default MailPoet's page
455
+ $default_page_id = $model_config->getValue( 'confirm_email_link' );
456
+ $model_config->save(
457
+ array(
458
+ 'confirmation_page' => $default_page_id,
459
+ 'unsubscribe_page' => $default_page_id,
460
+ 'subscriptions_page' => $default_page_id,
461
+ )
462
+ );
463
+
464
+ return true;
465
+ break;
466
+
467
+ case '2.6':
468
+ case '2.6.0.8':
469
+ $queries = array();
470
+
471
+ // Correct links which are missing 'h'
472
+ $queries[] = "UPDATE `[wysija]url` SET `url` = CONCAT('h', `url`) WHERE `url` LIKE 'ttp://%'";
473
+ $errors = $this->run_update_queries( $queries );
474
+
475
+ if ( $errors ) {
476
+ $this->error( implode( $errors, "\n" ) );
477
+ return false;
478
+ }
479
+
480
+ return true;
481
+ break;
482
+
483
+ default:
484
+ return false;
485
+ }
486
+ return false;
487
+ }
488
+
489
+
490
+ /**
491
+ *
492
+ * @return type
493
+ */
494
+ function check(){
495
+
496
+ //we can go there if this is not a new installation and it's an admin
497
+ if(WYSIJA::current_user_can('switch_themes') ){
498
+
499
+ // check that the redirection is only processed from wysija's interfaces
500
+ if(isset($_REQUEST['page']) && in_array($_REQUEST['page'], array('wysija_config','wysija_campaigns','wysija_subscribers'))){
501
+
502
+ // we are earlier than 1.1 or earlier than the current file version so we can run what's needed to reach the right version number
503
+ $config=WYSIJA::get('config','model');
504
+
505
+ if(!$config->getValue('wysija_db_version') || version_compare($config->getValue('wysija_db_version'),WYSIJA::get_version()) < 0){
506
+ $this->update(WYSIJA::get_version());
507
+ }
508
+ // once the update procedure is done we can redirect to the what's new/fixed page
509
+ $noredirect=false;
510
+
511
+ //get the right option name based on the type of site we're in
512
+ $whats_new_option='wysija_whats_new';
513
+ $is_multisite=is_multisite();
514
+ $is_network_admin=WYSIJA::current_user_can('manage_network');
515
+
516
+ // check that in case of a multisite configuration only the network admin sees that update page
517
+ if($is_multisite){
518
+ if($is_network_admin){
519
+ $whats_new_option='ms_wysija_whats_new';
520
+ }else {
521
+ return;
522
+ }
523
+ }
524
+
525
+ // a whats_new option is set and it is less than the current version so that means we need to display it
526
+ if((!$config->getValue($whats_new_option) || version_compare($config->getValue($whats_new_option),WYSIJA::get_version()) < 0)){
527
+
528
+ //if there is an action set and it's one of those then we just don't redirect
529
+ if(isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('whats_new','welcome_new','activate-plugin'))) $noredirect=true;
530
+
531
+ if(!$noredirect) {
532
+ $timeInstalled=$config->getValue('installed_time')+3600;
533
+ //if it is a fresh install then it redirects to the welcome screen otherwise to the update one
534
+ if(time()>$timeInstalled){
535
+ WYSIJA::redirect('admin.php?page=wysija_campaigns&action=whats_new');
536
+ }else{
537
+ WYSIJA::redirect('admin.php?page=wysija_campaigns&action=welcome_new');
538
+ }
539
+ }
540
+ }
541
+ }
542
+
543
+
544
+ }
545
+ }
546
+
547
+ /**
548
+ * this is a central function which will run every update until the current version
549
+ * @param string $version_current // not used since we use the wysija_db_version
550
+ * @return boolean
551
+ */
552
+ function update($version_current){
553
+ $config=WYSIJA::get('config','model');
554
+ $config->getValue('wysija_db_version');
555
+
556
+ foreach($this->updates as $version){
557
+ if(version_compare($config->getValue('wysija_db_version'),$version) < 0){
558
+ if(!$this->runUpdate($version)){
559
+ $this->error(sprintf(__('Update procedure to MailPoet version "%1$s" failed!',WYSIJA),$version),true);
560
+ return false;
561
+ }else{
562
+ $config->save(array('wysija_db_version' => $version));
563
+ }
564
+ }
565
+ }
566
+
567
+ }
568
+
569
+ /**
570
+ * return the failed queries
571
+ * @param type $queries
572
+ * @return type
573
+ * @deprecated since version 2.6
574
+ */
575
+ function runUpdateQueries($queries){
576
+ return $this->run_update_queries($queries);
577
+ }
578
+
579
+ /**
580
+ * run a list of specified queries and return a list of failed queries
581
+ * @param array $queries
582
+ * <pre>
583
+ * array(
584
+ * 0 => full_query_1,
585
+ * 1 => full_query_2,
586
+ * ...
587
+ * n => full_query_n
588
+ * )
589
+ *
590
+ * @return false or array
591
+ * <pre>
592
+ * array(
593
+ * 0 => full_query_1,
594
+ * 1 => full_query_2,
595
+ * ...
596
+ * n => full_query_n
597
+ * )
598
+ */
599
+ function run_update_queries($queries) {
600
+ $failed=array();
601
+
602
+ //we use mysql query instead of wordpress query to make sure we don't miss the sql errors
603
+ global $wpdb;
604
+ foreach($queries as $query){
605
+ $query=str_replace('[wysija]',$this->modelWysija->getPrefix(),$query);
606
+ $wpdb->query($query);
607
+
608
+
609
+
610
+ if(empty($wpdb->result) || !$wpdb->result) $failed[]= mysql_error($wpdb->dbh)." ($query)";
611
+
612
+ }
613
+ if($failed) return $failed;
614
+ else return false;
615
+ }
616
+
617
+ /**
618
+ * Detects if a column already exsits in a table
619
+ * @global wpdb $wpdb
620
+ * @param string $column_name name of the column
621
+ * @param string $table_name name of a table which the column should belong to
622
+ * @return boolean
623
+ */
624
+ protected function does_column_exist($column_name, $table_name) {
625
+ global $wpdb;
626
+ $sql = "SHOW COLUMNS FROM `$table_name` LIKE '$column_name';";
627
+
628
+ $results = $wpdb->get_results(str_replace('[wysija]',$this->modelWysija->getPrefix(),$sql));
629
+
630
+
631
+
632
+ return (!empty($results));
633
+ }
634
+
635
+
636
+ /**
637
+ * Version 2.4 introduces the Form Editor
638
+ * This function converts all previously saved subscription widgets into forms
639
+ *
640
+ */
641
+ function convert_widget_to_form($values = array()) {
642
+ // $values needs to be an array
643
+ if(!is_array($values)) return false;
644
+
645
+ // make sure we don't convert wysija forms into wysija forms.... that would be silly isn't it?
646
+ if(isset($values['form']) && (int)$values['form'] > 0) return false;
647
+
648
+ $settings = $body = array();
649
+
650
+ // SETTINGS
651
+ // specify who selects the list (user | admin)
652
+ if($values['autoregister'] === 'not_auto_register') {
653
+ $settings['lists_selected_by'] = 'admin';
654
+ } else {
655
+ // the user will select his own list so let's add the list selection
656
+ $settings['lists_selected_by'] = 'user';
657
+ }
658
+
659
+ // lists
660
+ $settings['lists'] = $values['lists'];
661
+
662
+ // success message
663
+ $settings['on_success'] = 'message';
664
+ $settings['success_message'] = $values['success'];
665
+
666
+ // are the labels in or out?
667
+ if($values['labelswithin'] === 'labels_within') {
668
+ $label_within = true;
669
+ } else {
670
+ $label_within = false;
671
+ }
672
+
673
+ // The order of the fields were: firstname, lastname, email, list_selection, submit
674
+ $blocks = array();
675
+
676
+ // INSTRUCTIONS
677
+ if(isset($values['instruction']) && strlen(trim($values['instruction'])) > 0) {
678
+ $blocks[] = array(
679
+ 'params' => array(
680
+ 'text' => base64_encode($values['instruction']),
681
+ ),
682
+ 'type' => 'text',
683
+ 'field' => 'text',
684
+ 'name' => __('Random text or instructions', WYSIJA)
685
+ );
686
+ }
687
+
688
+ // CUSTOM FIELDS (firstname, lastname, email)
689
+ $has_email_field = false;
690
+ foreach($values['customfields'] as $field => $params) {
691
+ switch($field) {
692
+ case 'firstname':
693
+ $name = __('First name', WYSIJA);
694
+ break;
695
+ case 'lastname':
696
+ $name = __('Last name', WYSIJA);
697
+ break;
698
+ case 'email':
699
+ $has_email_field = true;
700
+ $name = __('Email', WYSIJA);
701
+ break;
702
+
703
+ }
704
+
705
+ $blocks[] = array(
706
+ 'name' => $name,
707
+ 'type' => 'input',
708
+ 'field' => $field,
709
+ 'params' => array(
710
+ 'label' => $params['label'],
711
+ 'required' => 1,
712
+ 'label_within' => (int)$label_within
713
+ )
714
+ );
715
+ }
716
+
717
+ // make really sure we have an email field
718
+ if($has_email_field === false) {
719
+ $blocks[] = array(
720
+ 'name' => __('Email', WYSIJA),
721
+ 'type' => 'input',
722
+ 'field' => 'email',
723
+ 'params' => array(
724
+ 'label' => __('Email', WYSIJA),
725
+ 'required' => 1,
726
+ 'label_within' => (int)$label_within
727
+ )
728
+ );
729
+ }
730
+
731
+ // LIST SELECTION (only if the user can pick his own lists)
732
+ if($settings['lists_selected_by'] === 'user') {
733
+
734
+ $list_values = array();
735
+
736
+ foreach($settings['lists'] as $list_id) {
737
+ $list_values[] = array(
738
+ 'list_id' => $list_id,
739
+ 'is_checked' => 1
740
+ );
741
+ }
742
+ $blocks[] = array(
743
+ 'name' => __('List selection', WYSIJA),
744
+ 'type' => 'list',
745
+ 'field' => 'list',
746
+ 'params' => array(
747
+ 'label' => __('Select list(s):', WYSIJA),
748
+ 'values' => $list_values
749
+ )
750
+ );
751
+ }
752
+
753
+ // ADD SUBMIT BUTTON
754
+ $submit_label = __('Subscribe!', WYSIJA);
755
+ if(isset($values['submit']) && strlen(trim($values['submit'])) > 0) {
756
+ $submit_label = $values['submit'];
757
+ }
758
+ $blocks[] = array(
759
+ 'name' => __('Submit', WYSIJA),
760
+ 'type' => 'submit',
761
+ 'field' => 'submit',
762
+ 'params' => array(
763
+ 'label' => $submit_label
764
+ )
765
+ );
766
+
767
+ // Format body based on blocks
768
+ for($i = 0, $count = count($blocks); $i < $count; $i++) {
769
+ $body['block-'.($i + 1)] = array_merge($blocks[$i], array('position' => ($i + 1)));
770
+ }
771
+
772
+ // set default form name
773
+ $form_name = __('New Form', WYSIJA);
774
+
775
+ // check if title exists and override default form name
776
+ if(isset($values['title']) && strlen(trim($values['title'])) > 0) {
777
+ $form_name = $values['title'];
778
+ }
779
+
780
+ // form engine helper
781
+ $helper_form_engine = WYSIJA::get('form_engine', 'helper');
782
+
783
+ // insert form into db
784
+ $model_forms = WYSIJA::get('forms', 'model');
785
+ $model_forms->reset();
786
+ // get form id back because it's required to generate the html form
787
+ $form_id = $model_forms->insert(array('name' => $form_name));
788
+
789
+ if((int)$form_id > 0) {
790
+ $model_forms->reset();
791
+ // set form engine data
792
+ $helper_form_engine->set_data(array(
793
+ 'form_id' => (int)$form_id,
794
+ 'settings' => $settings,
795
+ 'body' => $body
796
+ ));
797
+
798
+ // update form in database
799
+ $model_forms->update(array('data' => $helper_form_engine->get_encoded('data')), array('form_id' => $form_id));
800
+
801
+ return $form_id;
802
+ } else {
803
+ return false;
804
+ }
805
+ }
806
+
807
+ /**
808
+ * very important function to convert subscription widget to our new forms in 2.4
809
+ * @return int
810
+ */
811
+ function convert_widgets_to_forms() {
812
+ $widgets_converted = 0;
813
+
814
+ // get all wysija widgets
815
+ $widgets = get_option('widget_wysija');
816
+
817
+ foreach($widgets as $key => &$values) {
818
+ $form_id = $this->convert_widget_to_form($values);
819
+ if($form_id!==false) {
820
+ $values['default_form'] = $form_id;
821
+ $widgets_converted++;
822
+ }
823
+ }
824
+
825
+ update_option('widget_wysija',$widgets);
826
+ return $widgets_converted;
827
+ }
828
+
829
+ /**
830
+ * Deprecated Methods
831
+ */
832
+ function checkForNewVersion(){
833
+ /*
834
+ $current = get_site_transient( 'update_plugins' );
835
+
836
+ if ( !isset( $current->response[ $file ] ) )
837
+ return false;
838
+
839
+ $r = $current->response[ $file ];
840
+ $default_headers = array(
841
+ 'Name' => 'Plugin Name',
842
+ 'PluginURI' => 'Plugin URI',
843
+ 'Version' => 'Version',
844
+ 'Description' => 'Description',
845
+ 'Author' => 'Author',
846
+ 'AuthorURI' => 'Author URI',
847
+ 'TextDomain' => 'Text Domain',
848
+ 'DomainPath' => 'Domain Path',
849
+ 'Network' => 'Network',
850
+ );
851
+
852
+ $plugin_data = get_file_data( WP_PLUGIN_DIR . DS.$file, $default_headers, 'plugin' );
853
+
854
+ $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
855
+ $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
856
+
857
+ $details_url = self_admin_url((is_multisite()? 'network/' : '' ).'plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '&section=changelog&TB_iframe=true&width=600&height=400');
858
+
859
+ if(((is_multisite() && current_user_can('manage_network') ) || current_user_can('update_plugins') ) && !empty($r->package) ){
860
+ $this->notice(
861
+ sprintf(
862
+ __('Hey! %1$s has an update (version %4$s), <a href="%5$s">click here to update</a>.', WYSIJA)
863
+ , '<strong>'.$plugin_name.'</strong>',
864
+ esc_url($details_url),
865
+ esc_attr($plugin_name),
866
+ $r->new_version,
867
+ wp_nonce_url( self_admin_url('update.php?action=upgrade-plugin&plugin=') . $file, 'upgrade-plugin_' . $file) ),true,true);
868
+ }
869
+ */
870
+ }
871
+
872
+
873
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
helpers/user.php CHANGED
@@ -265,12 +265,9 @@ class WYSIJA_help_user extends WYSIJA_object {
265
  if (!empty($message_success))
266
  $this->notice($message_success);
267
  }else {
268
- if ($backend) {
269
- $this->notice(__('Subscriber has not been saved.', WYSIJA));
270
- } else {
271
- $this->notice(__('Oops! We could not add you!', WYSIJA));
272
- }
273
- return false;
274
  }
275
 
276
  $subscribe_to_list = $subscriber_status = 0;
@@ -925,16 +922,20 @@ class WYSIJA_help_user extends WYSIJA_object {
925
  */
926
  function cleanWordpressUsersList() {
927
  // update the screwed up wpuser_id
928
- $model_list = WYSIJA::get('list', 'model');
929
- $query = 'UPDATE [wysija]user as A JOIN [wp]users as B on A.email=B.user_email SET A.wpuser_id = B.ID WHERE A.wpuser_id = 0';
930
- $model_list->query($query);
 
931
 
932
  // get all the wysija user with a wpuser_id >0 and insert them into the WordPress user list
933
- $model_config = WYSIJA::get('config', 'model');
934
- $selectuserCreated = 'SELECT [wysija]user.user_id, ' . $model_config->getValue('importwp_list_id') . ', ' . time() . ' FROM [wysija]user WHERE wpuser_id > 0';
 
 
 
935
  $query = 'INSERT IGNORE INTO `[wysija]user_list` (`user_id`,`list_id`,`sub_date`) ' . $selectuserCreated;
936
- $model_list->reset();
937
- $model_list->query($query);
938
  return true;
939
  }
940
 
265
  if (!empty($message_success))
266
  $this->notice($message_success);
267
  }else {
268
+ $this->notice(__('Subscriber has not been saved.', WYSIJA));
269
+ if ($backend)
270
+ return false;
 
 
 
271
  }
272
 
273
  $subscribe_to_list = $subscriber_status = 0;
922
  */
923
  function cleanWordpressUsersList() {
924
  // update the screwed up wpuser_id
925
+ $model = WYSIJA::get('list', 'model');
926
+ $query = 'UPDATE [wysija]user as A LEFT JOIN [wp]users as B on A.email=B.user_email SET A.wpuser_id = B.ID WHERE A.wpuser_id=0';
927
+ $model->query($query);
928
+
929
 
930
  // get all the wysija user with a wpuser_id >0 and insert them into the WordPress user list
931
+ $model->reset();
932
+ $model->query($query);
933
+
934
+ $mConfig = WYSIJA::get('config', 'model');
935
+ $selectuserCreated = 'SELECT [wysija]user.user_id, ' . $mConfig->getValue('importwp_list_id') . ', ' . time() . ' FROM [wysija]user WHERE wpuser_id>0';
936
  $query = 'INSERT IGNORE INTO `[wysija]user_list` (`user_id`,`list_id`,`sub_date`) ' . $selectuserCreated;
937
+ $model->reset();
938
+ $model->query($query);
939
  return true;
940
  }
941
 
helpers/wj_engine.php CHANGED
@@ -4,1624 +4,1463 @@ defined('WYSIJA') or die('Restricted access');
4
  * @class Wysija Engine Helper (PHP4 version)
5
  */
6
  class WYSIJA_help_wj_engine extends WYSIJA_object {
7
- // debug mode
8
- var $_debug = false;
9
-
10
- // contains email data
11
- var $_email_data = null;
12
-
13
- // rendering context (editor, email)
14
- var $_context = 'editor';
15
-
16
- // toggles for vib & unsub
17
- var $_hide_viewbrowser = false;
18
- var $_hide_unsubscribe = false;
19
-
20
- // data holders
21
- var $_data = null;
22
- var $_styles = null;
23
-
24
- // styles: defaults
25
- var $VIEWBROWSER_SIZES = array(7, 8, 9, 10, 11, 12, 13, 14);
26
- var $TEXT_SIZES = array(8, 9, 10, 11, 12, 13, 14, 16, 18, 24, 36, 48, 72);
27
- var $TITLE_SIZES = array(16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 40, 44, 48, 54, 60, 66, 72);
28
- var $FONTS = array("Arial", "Arial Black", "Comic Sans MS", "Courier New", "Georgia", "Impact", "Tahoma", "Times New Roman", "Trebuchet MS", "Verdana");
29
-
30
- /* Constructor */
31
- function WYSIJA_help_wj_engine() { }
32
-
33
- /* i18n methods */
34
- function getTranslations() {
35
- return array(
36
- 'dropHeaderNotice' => __('Drop your logo in this header.',WYSIJA),
37
- 'dropFooterNotice' => __('Drop your footer image here.',WYSIJA),
38
- 'dropBannerNotice' => __('If you leave this area empty, it will not display once you send your email',WYSIJA),
39
- 'clickToEditText' => __('Click here to add a title or text.', WYSIJA),
40
- 'alignmentLeft' => __('Align left',WYSIJA),
41
- 'alignmentCenter' => __('Align center',WYSIJA),
42
- 'alignmentRight' => __('Align right',WYSIJA),
43
- 'addImageLink' => __('Add link / Alternative text',WYSIJA),
44
- 'removeImageLink' => __('Remove link',WYSIJA),
45
- 'removeImage' => __('Remove image',WYSIJA),
46
- 'remove' => __('Remove', WYSIJA),
47
- 'editText' => __( 'Edit text',WYSIJA),
48
- 'removeText' => __('Remove text',WYSIJA),
49
- 'textLabel' => __('Titles & text',WYSIJA),
50
- 'dividerLabel' => __('Horizontal line',WYSIJA),
51
- 'customDividerLabel' => __('Custom horizontal line',WYSIJA),
52
- 'postLabel' => __('WordPress post',WYSIJA),
53
- 'styleBodyLabel' => __('Text',WYSIJA),
54
- 'styleViewbrowserLabel' => __('"View in browser"', WYSIJA),
55
- 'styleH1Label' => __('Heading 1',WYSIJA),
56
- 'styleH2Label' => __('Heading 2',WYSIJA),
57
- 'styleH3Label' => __('Heading 3',WYSIJA),
58
- 'styleLinksLabel' => __('Links',WYSIJA),
59
- 'styleLinksDecorationLabel' => __('underline',WYSIJA),
60
- 'styleFooterLabel' => __('Footer text',WYSIJA),
61
- 'styleFooterBackgroundLabel' => __('Footer background',WYSIJA),
62
- 'styleBodyBackgroundLabel' => __('Newsletter',WYSIJA),
63
- 'styleHtmlBackgroundLabel' => __('Background', WYSIJA),
64
- 'styleHeaderBackgroundLabel' => __('Header background', WYSIJA),
65
- 'styleDividerLabel' => __('Horizontal line',WYSIJA),
66
- 'styleUnsubscribeColorLabel' => __('Unsubscribe',WYSIJA),
67
- 'articleSelectionTitle' => __('Post Selection', WYSIJA),
68
- 'bookmarkSelectionTitle' => __('Social Bookmark Selection', WYSIJA),
69
- 'dividerSelectionTitle' => __('Divider Selection', WYSIJA),
70
- 'abouttodeletetheme' => __('You are about to delete the theme : %1$s. Do you really want to do that?', WYSIJA),
71
- 'addLinkTitle' => __('Add Link & Alternative text', WYSIJA),
72
- 'styleTransparent' => __('Check this box if you want transparency', WYSIJA),
73
- 'ajaxLoading' => __('Loading...', WYSIJA),
74
- 'customFieldsLabel' => __('Insert dynamic data about your subscribers, the newsletter, today\'s date, etc...', WYSIJA),
75
- 'autoPostSettingsTitle' => __('Selection options', WYSIJA),
76
- 'autoPostEditSettings' => __('Edit Automatic latest content', WYSIJA),
77
- 'autoPostImmediateNotice' => __('You can only add one widget when designing a post notification sent immediately after an article is published', WYSIJA),
78
- 'toggleImagesTitle' => __('Preview without images', WYSIJA),
79
- // Tags labels
80
- 'tags_user' => __('Subscriber', WYSIJA),
81
- 'tags_user_firstname' => __('First Name', WYSIJA),
82
- 'tags_user_lastname' => __('Last Name', WYSIJA),
83
- 'tags_user_email' => __('Email Address', WYSIJA),
84
- 'tags_user_displayname' => __('WordPress user display name', WYSIJA),
85
- 'tags_user_count' => __('Total of subscribers', WYSIJA),
86
- 'tags_newsletter' => __('Newsletter', WYSIJA),
87
- 'tags_newsletter_subject' => __('Newsletter Subject', WYSIJA),
88
- 'tags_newsletter_autonl' => __('Post Notifications', WYSIJA),
89
- 'tags_newsletter_total' => __('Total number of posts or pages', WYSIJA),
90
- 'tags_newsletter_post_title' => __('Latest post title', WYSIJA),
91
- 'tags_newsletter_number' => __('Issue number', WYSIJA),
92
- 'tags_date' => __('Date', WYSIJA),
93
- 'tags_date_d' => __('Current day of the month number', WYSIJA),
94
- 'tags_date_dordinal' => __('Current day of the month in ordinal, ie. 2nd, 3rd, etc.', WYSIJA),
95
- 'tags_date_dtext' => __('Full name of current day', WYSIJA),
96
- 'tags_date_m' => __('Current month number', WYSIJA),
97
- 'tags_date_mtext' => __('Full name of current month', WYSIJA),
98
- 'tags_date_y' => __('Year', WYSIJA),
99
- 'tags_global' => __('Links', WYSIJA),
100
- 'tags_global_unsubscribe' => __('Unsubscribe link', WYSIJA),
101
- 'tags_global_manage' => __('Edit subscription page link', WYSIJA),
102
- 'tags_global_browser' => __('View in browser link', WYSIJA),
103
- 'custom_fields_title' => __('Custom Fields', WYSIJA),
104
- 'custom_fields_list' => WJ_Field::get_all_names(),
105
- // Themes specific labels
106
- 'theme_setting_default' => __('Saving default style...', WYSIJA),
107
- 'theme_saved_default' => __('Default style saved.', WYSIJA),
108
- 'theme_save_as_default' => __('Set as default style.', WYSIJA),
109
- // Placeholders
110
- 'drop_block_here' => __('Insert block here', WYSIJA)
111
- );
112
- }
113
-
114
- /* Data methods */
115
- function getData($type = null) {
116
- if($type !== null) {
117
- if(array_key_exists($type, $this->_data)) {
118
- return $this->_data[$type];
119
- } else {
120
- // return default value
121
- $defaults = $this->getDefaultData();
122
- return $defaults[$type];
123
- }
124
- }
125
- return $this->_data;
126
- }
127
-
128
- function setData($value = null, $decode = false) {
129
- if(!$value) {
130
- $this->_data = $this->getDefaultData();
131
- } else {
132
- $this->_data = $value;
133
- if($decode) {
134
- $this->_data = $this->getDecoded('data');
135
- }
136
- }
137
- }
138
-
139
- function getEmailData($key = null) {
140
- if($key === null) {
141
- return $this->_email_data;
142
- } else {
143
- if(array_key_exists($key, $this->_email_data)) {
144
- return $this->_email_data[$key];
145
- }
146
- }
147
- return null;
148
- }
149
-
150
- function setEmailData($value = null) {
151
- if($value !== null) {
152
- $this->_email_data = $value;
153
- }
154
- }
155
-
156
- function getDefaultData() {
157
- $dividersHelper = WYSIJA::get('dividers', 'helper');
158
- return array(
159
- 'header' => array(
160
- 'alignment' => 'center',
161
- 'type' => 'header',
162
- 'static' => '1',
163
- 'text' => null,
164
- 'image' => array(
165
- 'src' => null,
166
- 'width' => 600,
167
- 'height' => 86,
168
- 'url' => null,
169
- 'alignment' => 'center',
170
- 'static' => '1'
171
- )
172
- ),
173
- 'body' => array(),
174
- 'footer' => array(
175
- 'alignment' => 'center',
176
- 'type' => 'footer',
177
- 'static' => '1',
178
- 'text' => null,
179
- 'image' => array(
180
- 'src' => null,
181
- 'width' => 600,
182
- 'height' => 86,
183
- 'url' => null,
184
- 'alignment' => 'center',
185
- 'static' => '1'
186
- )
187
- ),
188
- 'widgets' => array(
189
- 'divider' => array_merge($dividersHelper->getDefault(), array('type' => 'divider'))
190
- )
191
- );
192
- }
193
-
194
- /* Styles methods */
195
- function getStyles($keys = null) {
196
- if($keys === null) return $this->_styles;
197
-
198
- if(!is_array($keys)) {
199
- $keys = array($keys);
200
- }
201
- $output = array();
202
- for($i=0; $i<count($keys);$i++) {
203
- if(isset($this->_styles[$keys[$i]])) {
204
- $output = array_merge($output, $this->_styles[$keys[$i]]);
205
- }
206
- }
207
- return $output;
208
- }
209
-
210
- function getStyle($key, $subkey) {
211
- $styles = $this->getStyles($key);
212
- return $styles[$subkey];
213
- }
214
-
215
- function setStyles($value = null, $decode = false) {
216
- if(!$value) {
217
- $this->_styles = $this->getDefaultStyles();
218
- } else {
219
- $this->_styles = $value;
220
- if($decode) {
221
- $this->_styles = $this->getDecoded('styles');
222
- }
223
- }
224
- }
225
-
226
- function getDefaultStyles() {
227
-
228
- $defaults = array(
229
- 'html' => array(
230
- 'background' => 'FFFFFF'
231
- ),
232
- 'header' => array(
233
- 'background' => 'FFFFFF'
234
- ),
235
- 'body' => array(
236
- 'color' => '000000',
237
- 'family' => 'Arial',
238
- 'size' => $this->TEXT_SIZES[5],
239
- 'background' => 'FFFFFF'
240
- ),
241
- 'footer' => array(
242
- 'color' => '000000',
243
- 'family' => 'Arial',
244
- 'size' => $this->TEXT_SIZES[5],
245
- 'background' => 'cccccc'
246
- ),
247
- 'h1' => array(
248
- 'color' => '000000',
249
- 'family' => 'Arial',
250
- 'size' => $this->TITLE_SIZES[6]
251
- ),
252
- 'h2' => array(
253
- 'color' => '424242',
254
- 'family' => 'Arial',
255
- 'size' => $this->TITLE_SIZES[5]
256
- ),
257
- 'h3' => array(
258
- 'color' => '424242',
259
- 'family' => 'Arial',
260
- 'size' => $this->TITLE_SIZES[4]
261
- ),
262
- 'a' => array(
263
- 'color' => '4a91b0',
264
- 'underline' => false
265
- ),
266
- 'unsubscribe' => array(
267
- 'color' => '000000'
268
- ),
269
- 'viewbrowser' => array(
270
- 'color' => '000000',
271
- 'family' => 'Arial',
272
- 'size' => $this->VIEWBROWSER_SIZES[4]
273
- )
274
- );
275
-
276
- // get default selected theme
277
- $model_config = WYSIJA::get('config', 'model');
278
- $default_theme = $model_config->getValue('newsletter_default_theme', 'default');
279
-
280
- if($default_theme === 'default') {
281
- return $defaults;
282
- } else {
283
- $helper_themes = WYSIJA::get('themes', 'helper');
284
- $stylesheet = $helper_themes->getStylesheet($default_theme);
285
-
286
- $styles = array();
287
- // look for each tags
288
- foreach($defaults as $tag => $values) {
289
- // look for css rules
290
- preg_match('/\.?'.$tag.'\s?{(.+)}/Ui', $stylesheet, $matches);
291
- if(isset($matches[1])) {
292
- // extract styles
293
- $styles[$tag] = $this->extractStyles($matches[1]);
294
- } else {
295
- // fallback to default
296
- $styles[$tag] = $defaults[$tag];
297
- }
298
- }
299
-
300
- return $styles;
301
- }
302
- }
303
-
304
- function getApplicationData() {
305
- $app = array();
306
-
307
- $app['domain'] = WJ_Utils::get_domain();
308
-
309
- return $app;
310
- }
311
-
312
- /* Editor methods */
313
- function renderEditor() {
314
- $this->setContext('editor');
315
-
316
- if($this->isDataValid() === false) {
317
- throw new Exception('data is not valid');
318
- } else {
319
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
320
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
321
-
322
- // get company addressfrom settings
323
- $config=WYSIJA::get("config","model");
324
-
325
- $data = array(
326
- 'header' => $this->renderEditorHeader(),
327
- 'body' => $this->renderEditorBody(),
328
- 'footer' => $this->renderEditorFooter(),
329
- 'unsubscribe' => $config->emailFooterLinks(true),
330
- 'company_address' => nl2br($config->getValue('company_address')),
331
- 'is_debug' => $this->isDebug(),
332
- 'i18n' => $this->getTranslations()
333
- );
334
-
335
- $viewbrowser = $config->viewInBrowserLink(true);
336
- if($viewbrowser) {
337
- $data['viewbrowser'] = $viewbrowser;
338
- }
339
-
340
- return $helper_render_engine->render($data, 'templates/newsletter/editor/editor_template.html');
341
- }
342
- }
343
-
344
- function renderEditorHeader($data = null) {
345
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
346
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
347
- $helper_render_engine->setStripSpecialchars(true);
348
-
349
- if($data !== null) {
350
- $block = $data;
351
- } else {
352
- $block = $this->getData('header');
353
- }
354
-
355
- $data = array_merge($block, array('i18n' => $this->getTranslations()));
356
- return $helper_render_engine->render($data, 'templates/newsletter/editor/header_template.html');
357
- }
358
-
359
- function renderEditorBody() {
360
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
361
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
362
-
363
- $blocks = $this->getData('body');
364
- if(empty($blocks)) return '';
365
-
366
- $body = '';
367
- foreach($blocks as $key => $block) {
368
- // generate block template
369
- $data = array_merge($block, array('i18n' => $this->getTranslations()));
370
- $body .= $helper_render_engine->render($data, 'templates/newsletter/editor/block_template.html');
371
- }
372
-
373
- return $body;
374
- }
375
-
376
- function renderEditorFooter($data = null)
377
- {
378
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
379
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
380
-
381
- if($data !== null) {
382
- $block = $data;
383
- } else {
384
- $block = $this->getData('footer');
385
- }
386
-
387
- $data = array_merge($block, array('i18n' => $this->getTranslations()));
388
-
389
- return $helper_render_engine->render($data, 'templates/newsletter/editor/footer_template.html');
390
- }
391
-
392
- function renderEditorBlock($block = array()) {
393
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
394
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
395
- $helper_render_engine->setStripSpecialchars(true);
396
-
397
- $block['i18n'] = $this->getTranslations();
398
-
399
- return $helper_render_engine->render($block, 'templates/newsletter/editor/block_'.$block['type'].'.html');
400
- }
401
-
402
- /* render auto post */
403
- function renderEditorAutoPost($posts = array(), $params = array()) {
404
- $output = '';
405
- if(isset($params['post_ids'])) {
406
- $output .= '<input type="hidden" name="post_ids" value="'.$params['post_ids'].'" />';
407
- }
408
-
409
- // check if there are posts to display
410
- if(empty($posts)) {
411
- // set background color
412
- $background_color = '';
413
- if(isset($params['bgcolor1'])) {
414
- $background_color = $params['bgcolor1'];
415
- }
416
-
417
- // display a message stating that the latest content has been sent
418
- $block = array(
419
- 'no-block' => true,
420
- 'type' => 'content',
421
- 'alignment' => 'center',
422
- 'background_color' => $background_color,
423
- 'image' => null,
424
- 'text' => array('value' => base64_encode(__('Latest content already sent.', WYSIJA)))
425
- );
426
- $output .= $this->renderEditorBlock($block);
427
- } else {
428
- // otherwise, render all posts into blocks
429
- $output .= $this->renderPostsToBlocks($posts, $params, 'autopost');
430
- }
431
-
432
- return $output;
433
- }
434
-
435
- function renderEmailAutoPost($posts = array(), $params = array()) {
436
- if(empty($posts)) {
437
- return '';
438
- } else {
439
- return $this->renderPostsToBlocks($posts, $params, 'autopost');
440
- }
441
- }
442
-
443
- function renderEmailBlock($block = array()) {
444
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
445
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
446
- $helper_render_engine->setStripSpecialchars(true);
447
-
448
- // set block background color
449
- $background_color = null;
450
- if(isset($block['background_color'])) {
451
- $background_color = $block['background_color'];
452
- }
453
-
454
- return $this->applyInlineStyles(
455
- 'body',
456
- //$helper_render_engine->render($block, 'templates/email_v3/block_'.$block['type'].'.html'),
457
- $helper_render_engine->render($block, 'templates/newsletter/email/block_template.html'),
458
- array('background_color' => $background_color)
459
- );
460
- }
461
-
462
- function renderPostsToBlocks($posts = array(), $params = array(), $mode = 'post') {
463
- $html = '';
464
- $context = $this->getContext();
465
-
466
- $helper_articles = WYSIJA::get('articles', 'helper');
467
-
468
- if($params['title_tag'] === 'list') {
469
- $list = '<ul class="align-'.$params['title_alignment'].'">';
470
- }
471
-
472
- // make sure empty bgcolors are set to transparent
473
- if(!isset($params['bgcolor1']) || (isset($params['bgcolor1']) && strlen($params['bgcolor1']) === 0)) {
474
- $params['bgcolor1'] = '';
475
- }
476
- if(!isset($params['bgcolor2']) || (isset($params['bgcolor2']) && strlen($params['bgcolor2']) === 0)) {
477
- $params['bgcolor2'] = '';
478
- }
479
-
480
- // BEGIN - posts
481
- for($i = 0, $count = count($posts); $i < $count; $i++) {
482
- $post = $posts[$i];
483
- $is_odd = (bool)($i % 2);
484
- $is_last = (bool)($i === ($count - 1));
485
-
486
- // set default background color to transparent
487
- $background_color = '';
488
-
489
- // set background color for each post
490
- if($is_odd === false) $background_color = $params['bgcolor1'];
491
- if($is_odd === true) $background_color = $params['bgcolor2'];
492
-
493
- if($params['image_alignment'] === 'alternate') {
494
- $image_alignment = ($is_odd === false) ? 'left' : 'right';
495
- } else if($params['image_alignment'] === 'none') {
496
- $image_alignment = 'left';
497
- $post['post_image'] = null;
498
- } else {
499
- $image_alignment = $params['image_alignment'];
500
- }
501
-
502
- // build basic block data
503
- $block = array(
504
- 'position' => $i,
505
- 'type' => 'content',
506
- 'alignment' => $image_alignment,
507
- 'background_color' => $background_color,
508
- 'image' => null,
509
- 'text' => null
510
- );
511
-
512
- // in case of autopost, we need to remove the "block" container because each block will be rendered within the autopost block
513
- if($mode === 'autopost') {
514
- $block['no-block'] = true;
515
- }
516
-
517
- // get title
518
- $title = $helper_articles->getPostTitle($post, $params);
519
-
520
- if(!isset($params['title_position'])) {
521
- $params['title_position'] = 'inside';
522
- }
523
-
524
- // if post content is title, force title position inside
525
- if($params['post_content'] === 'title') {
526
- $params['title_position'] = 'inside';
527
- }
528
-
529
- // only display titles as a list
530
- if($params['title_tag'] === 'list') {
531
- $list .= $title;
532
- continue;
533
- }
534
-
535
- // if the title is outside, generate its own block
536
- if($params['title_position'] === 'outside') {
537
- // generate title
538
- $title_block = array_merge($block, array(
539
- 'alignment' => 'left',
540
- 'text' => array(
541
- 'value' => base64_encode($title)
542
- )
543
- ));
544
-
545
- if($context === 'editor') {
546
- $html .= $this->renderEditorBlock($title_block);
547
- } else if($context === 'email') {
548
- $html .= $this->renderEmailBlock($title_block);
549
- }
550
- }
551
-
552
- // generate content
553
- $content_block = array_merge($block, $helper_articles->convertPostToBlock($post, array_merge($params, array('image_alignment' => $image_alignment))));
554
-
555
- if($context === 'editor') {
556
- $html .= $this->renderEditorBlock($content_block);
557
- } else if($context === 'email') {
558
- $html .= $this->renderEmailBlock($content_block);
559
- }
560
-
561
- // display divider if required
562
- if(isset($params['divider']) && ($params['divider'] !== null && $is_last === false)) {
563
- // display divider only if there is one and if it's not the last post
564
- $divider_block = array_merge(
565
- array(
566
- 'type' => 'divider',
567
- 'no-block' => ($mode === 'autopost')
568
- ),
569
- $params['divider']
570
- );
571
-
572
- if($context === 'editor') {
573
- $html .= $this->renderEditorBlock($divider_block);
574
- } else if($context === 'email') {
575
- $html .= $this->renderEmailBlock($divider_block);
576
- }
577
- }
578
- }
579
- // END - Posts
580
-
581
- if($params['title_tag'] === 'list') {
582
- $list .= '</ul>';
583
- $list_block = array_merge($block, array(
584
- 'alignment' => 'center',
585
- 'type' => 'content',
586
- 'text' => array(
587
- 'value' => base64_encode($list)
588
- )
589
- ));
590
- $html .= $this->renderEditorBlock($list_block);
591
- }
592
-
593
- return $html;
594
- }
595
-
596
- /* render draggable images list */
597
- function renderImages($data = array()) {
598
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
599
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
600
-
601
- return $helper_render_engine->render(array('images' => $data), 'templates/newsletter/editor/toolbar/images.html');
602
- }
603
-
604
- /* render themes list */
605
- function renderThemes() {
606
- $themes = array();
607
- $hThemes = WYSIJA::get('themes', 'helper');
608
-
609
- $installed = $hThemes->getInstalled();
610
-
611
- // get default selected theme
612
- $model_config = WYSIJA::get('config', 'model');
613
- $default_theme = $model_config->getValue('newsletter_default_theme', 'default');
614
-
615
- if(empty($installed)) {
616
- return '';
617
- } else {
618
- foreach($installed as $theme) {
619
- $theme_info = $hThemes->getInformation($theme);
620
- $theme_info['is_selected'] = (bool)($default_theme === $theme);
621
- $themes[] = $theme_info;
622
- }
623
- }
624
-
625
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
626
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
627
-
628
- return $helper_render_engine->render(array('themes' => $themes, 'i18n' => $this->getTranslations()), 'templates/newsletter/editor/toolbar/themes.html');
629
- }
630
-
631
- function renderThemeStyles($theme = 'default') {
632
- $this->setContext('editor');
633
-
634
- $hThemes = WYSIJA::get('themes', 'helper');
635
- $stylesheet = $hThemes->getStylesheet($theme);
636
-
637
- if($stylesheet === NULL) {
638
- // load default settings
639
- $this->setStyles(null);
640
- } else {
641
- // a stylesheet has been found, let's extract styles
642
- $styles = array();
643
- $defaults = $this->getDefaultStyles();
644
- // look for each tags
645
- foreach($defaults as $tag => $values) {
646
- // look for css rules
647
- preg_match('/\.?'.$tag.'\s?{(.+)}/Ui', $stylesheet, $matches);
648
- if(isset($matches[1])) {
649
- // extract styles
650
- $styles[$tag] = $this->extractStyles($matches[1]);
651
- } else {
652
- // fallback to default
653
- $styles[$tag] = $defaults[$tag];
654
- }
655
- }
656
- $this->setStyles($styles);
657
- }
658
-
659
- return array(
660
- 'css' => $this->renderStyles(),
661
- 'form' => $this->renderStylesBar()
662
- );
663
- }
664
-
665
- function extractStyles($raw) {
666
- $rules = explode(';', $raw);
667
- $output = array();
668
- foreach($rules as $rule) {
669
- $sub_property = false;
670
- $combo = explode(':', $rule);
671
- if(count($combo) === 2) {
672
- list($property, $value) = $combo;
673
- // remove leading and trailing space
674
- $property = trim($property);
675
- $value = trim($value);
676
- } else {
677
- continue;
678
- }
679
-
680
- switch($property) {
681
- case 'background':
682
- case 'background-color':
683
- $property = 'background';
684
- case 'color':
685
- // remove # from color
686
- $value = str_replace('#', '', $value);
687
- // check if its a 3 chars color
688
- if(strlen($value) === 3) {
689
- $value = sprintf('%s%s%s%s%s%s', substr($value, 0, 1), substr($value, 0, 1), substr($value, 1, 1), substr($value, 1, 1), substr($value, 2, 1), substr($value, 2, 1));
690
- }
691
- break;
692
- case 'font-family':
693
- $property = 'family';
694
- $fonts = explode(',', $value);
695
- $value = array_shift($fonts);
696
- break;
697
- case 'font-size':
698
- $property = 'size';
699
- case 'height':
700
- $value = (int)$value;
701
- break;
702
- case 'text-decoration':
703
- $property = 'underline';
704
- $value = ($value === 'none') ? '-1' : '1';
705
- break;
706
- case 'border-color':
707
- // remove # from color
708
- $value = str_replace('#', '', $value);
709
- // check if its a 3 chars color
710
- if(strlen($value) === 3) {
711
- $value = sprintf('%s%s%s%s%s%s', substr($value, 0, 1), substr($value, 0, 1), substr($value, 1, 1), substr($value, 1, 1), substr($value, 2, 1), substr($value, 2, 1));
712
- }
713
- list($property, $sub_property) = explode('-', $property);
714
- break;
715
- case 'border-size':
716
- $value = (int)$value;
717
- list($property, $sub_property) = explode('-', $property);
718
- break;
719
- case 'border-style':
720
- list($property, $sub_property) = explode('-', $property);
721
- break;
722
- }
723
-
724
- if($sub_property !== FALSE) {
725
- $output[$property][$sub_property] = $value;
726
- } else {
727
- $output[$property] = $value;
728
- }
729
- }
730
- return $output;
731
- }
732
-
733
- function renderTheme($theme = 'default') {
734
- $output = array(
735
- 'header' => null,
736
- 'footer' => null,
737
- 'divider' => null
738
- );
739
-
740
- $hThemes = WYSIJA::get('themes', 'helper');
741
- $data = $hThemes->getData($theme);
742
-
743
- if($data['header'] !== NULL) {
744
- $output['header'] = $this->renderEditorHeader($data['header']);
745
- }
746
-
747
- if($data['footer'] !== NULL) {
748
- $output['footer'] = $this->renderEditorFooter($data['footer']);
749
- }
750
-
751
- if($data['divider'] !== NULL) {
752
- $output['divider'] = $this->renderEditorBlock(array_merge(array('no-block' => true), $data['divider']));
753
- $output['divider_options'] = $data['divider'];
754
- }
755
-
756
- return $output;
757
- }
758
-
759
- /* render styles bar */
760
- function renderStylesBar() {
761
- $this->setContext('editor');
762
-
763
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
764
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
765
- $helper_render_engine->setStripSpecialchars(true);
766
-
767
- $data = $this->getStyles();
768
- $data['i18n'] = $this->getTranslations();
769
- $data['TEXT_SIZES'] = $this->TEXT_SIZES;
770
- $data['VIEWBROWSER_SIZES'] = $this->VIEWBROWSER_SIZES;
771
- $data['TITLE_SIZES'] = $this->TITLE_SIZES;
772
- $data['FONTS'] = $this->FONTS;
773
-
774
- return $helper_render_engine->render($data, 'templates/newsletter/editor/toolbar/styles.html');
775
- }
776
-
777
- function formatStyles($styles = array()) {
778
- if(empty($styles)) return;
779
-
780
- $data = array();
781
- foreach($styles as $style => $value) {
782
- $stylesArray = explode('-', $style);
783
- if(count($stylesArray) === 2) {
784
- $data[$stylesArray[0]][$stylesArray[1]] = $value;
785
- } else if(count($stylesArray) === 3) {
786
- // handle transparent colors
787
- if($stylesArray[2] === 'transparent') {
788
- $data[$stylesArray[0]][$stylesArray[1]] = $stylesArray[2];
789
- } else {
790
- $data[$stylesArray[0]][$stylesArray[1]][$stylesArray[2]] = $value;
791
- }
792
- }
793
- }
794
-
795
- return $data;
796
- }
797
-
798
- function getContext() {
799
- return $this->_context;
800
- }
801
-
802
- function setContext($value = null) {
803
- if($value !== null) $this->_context = $value;
804
- }
805
-
806
- function isDebug() {
807
- return ($this->_debug === true);
808
- }
809
-
810
- function getEncoded($type = 'data') {
811
- return base64_encode(serialize($this->{'get'.ucfirst($type)}()));
812
- }
813
-
814
- function getDecoded($type = 'data') {
815
- return unserialize(base64_decode($this->{'get'.ucfirst($type)}()));
816
- }
817
-
818
- /* methods */
819
- function isDataValid() {
820
- return ($this->getData() !== null);
821
- }
822
-
823
- /* Styles methods */
824
- function renderStyles() {
825
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
826
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
827
- $helper_render_engine->setStripSpecialchars(true);
828
- $helper_render_engine->setInline(true);
829
-
830
- $data = $this->getStyles();
831
- $data['context'] = $this->getContext();
832
-
833
- // right to left language property
834
- if(function_exists('is_rtl')) {
835
- $data['is_rtl'] = is_rtl();
836
- } else {
837
- $data['is_rtl'] = false;
838
- }
839
-
840
- switch($data['context']) {
841
- case 'editor':
842
- $helper_render_engine->setStripSpecialchars(false);
843
- $data['viewbrowser_container'] = '#wysija_viewbrowser';
844
- $data['wysija_container'] = '#wysija_wrapper';
845
- $data['header_container'] = '#wysija_header';
846
- $data['body_container'] = '#wysija_body';
847
- $data['text_container'] = '.editable';
848
- $data['footer_container'] = '#wysija_footer';
849
- $data['placeholder_container'] = '#wysija_block_placeholder';
850
- $data['unsubscribe_container'] = '#wysija_unsubscribe';
851
- return $helper_render_engine->render($data, 'styles/css-'.$data['context'].'.html');
852
- break;
853
-
854
- case 'email':
855
- $helper_render_engine->setStripSpecialchars(true);
856
- $data['wysija_container'] = '#wysija_wrapper';
857
- $data['viewbrowser_container'] = '.wysija_viewbrowser_container';
858
- $data['header'] = '.wysija_header';
859
- $data['header_container'] = '.wysija_header_container';
860
- $data['body_container'] = '.wysija_block';
861
- $data['text_container'] = '.wysija_text_container';
862
- $data['image_container'] = '.wysija_image_container';
863
- $data['image_placeholder'] = '.wysija_image_placeholder';
864
- $data['title_1'] = '.wysija_title_1';
865
- $data['title_2'] = '.wysija_title_2';
866
- $data['title_3'] = '.wysija_title_3';
867
-
868
- $data['footer'] = '.wysija_footer';
869
- $data['footer_container'] = '.wysija_footer_container';
870
- $data['unsubscribe_container'] = '.wysija_unsubscribe_container';
871
- //right to left language property
872
- if(function_exists('is_rtl')) {
873
- $data['is_rtl'] = is_rtl();
874
- } else {
875
- $data['is_rtl'] = false;
876
- }
877
- return $helper_render_engine->render($data, 'templates/newsletter/email/css.html');
878
- break;
879
- }
880
- }
881
-
882
- /* Email methods */
883
- function renderNotification($email = NULL) {
884
- $this->_hide_viewbrowser = true;
885
- $this->_hide_unsubscribe = true;
886
- return $this->renderEmail($email);
887
- }
888
-
889
- function renderEmail($email = NULL) {
890
-
891
- // fixes issue with pcre functions
892
- @ini_set('pcre.backtrack_limit', 1000000);
893
-
894
- $this->setContext('email');
895
-
896
- if($this->isDataValid() === false) {
897
- throw new Exception('data is not valid');
898
- } else {
899
- // set email data for later use
900
- $this->setEmailData($email);
901
-
902
- // render header
903
- $data = array(
904
- 'viewbrowser' => $this->renderEmailViewBrowser(),
905
- 'header' => $this->renderEmailHeader(),
906
- 'body' => $this->renderEmailBody(),
907
- 'footer' => $this->renderEmailFooter(),
908
- 'unsubscribe' => $this->renderEmailUnsubscribe(),
909
- 'css' => $this->renderStyles(),
910
- 'styles' => $this->getStyles(),
911
- 'hide_viewbrowser' => $this->_hide_viewbrowser,
912
- 'hide_unsubscribe' => $this->_hide_unsubscribe
913
- );
914
-
915
- //right to left language property
916
- if(function_exists('is_rtl')) {
917
- $data['is_rtl'] = is_rtl();
918
- } else {
919
- $data['is_rtl'] = false;
920
- }
921
-
922
- // set email subject if specified
923
- $data['subject'] = $this->getEmailData('subject');
924
-
925
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
926
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
927
- $helper_render_engine->setStripSpecialchars(true);
928
- $helper_render_engine->setInline(true);
929
-
930
- try {
931
- $template = $helper_render_engine->render($data, 'templates/newsletter/email/email_template.html');
932
-
933
- return $template;
934
- } catch(Exception $e) {
935
- return '';
936
- }
937
- }
938
- }
939
-
940
- function renderEmailViewBrowser() {
941
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
942
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
943
- $helper_render_engine->setStripSpecialchars(true);
944
-
945
- $config=WYSIJA::get('config','model');
946
- $data = $config->viewInBrowserLink();
947
- if(!isset($data['link'])) {
948
- return '';
949
- } else {
950
- // generate block template
951
- $viewbrowser = $helper_render_engine->render($data, 'templates/newsletter/email/viewbrowser_template.html');
952
-
953
- // apply inline styles
954
- $viewbrowser = $this->applyInlineStyles('viewbrowser', $viewbrowser);
955
-
956
- return $viewbrowser;
957
- }
958
- }
959
-
960
- function renderEmailUnsubscribe() {
961
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
962
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
963
- $helper_render_engine->setStripSpecialchars(true);
964
-
965
- $config = WYSIJA::get('config','model');
966
-
967
- $data = array(
968
- 'unsubscribe' => $config->emailFooterLinks(),
969
- 'company_address' => nl2br($config->getValue('company_address'))
970
- );
971
-
972
- // generate block template
973
- $unsubscribe = $helper_render_engine->render($data, 'templates/newsletter/email/unsubscribe_template.html');
974
-
975
- // apply inline styles
976
- $unsubscribe = $this->applyInlineStyles('unsubscribe', $unsubscribe);
977
-
978
- return $unsubscribe;
979
- }
980
-
981
- function renderEmailHeader() {
982
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
983
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
984
- $helper_render_engine->setStripSpecialchars(true);
985
-
986
- $data = $this->getData('header');
987
- $data['styles'] = array('header' => $this->getStyles('header'));
988
-
989
- // check for emptyness
990
- if($data['text'] === NULL and $data['image']['static'] === TRUE) {
991
- return NULL;
992
- }
993
-
994
- // set header content width
995
- $data['block_width'] = 600;
996
-
997
- // generate block template
998
- $header = $helper_render_engine->render($data, 'templates/newsletter/email/header_template.html');
999
-
1000
- // apply inline styles
1001
- $header = $this->applyInlineStyles('header', $header);
1002
-
1003
- return $header;
1004
- }
1005
-
1006
- function encodeParameters($params = array()) {
1007
- // encode string parameters
1008
- $keys_to_encode = array('author_label', 'category_label', 'readmore');
1009
- foreach($keys_to_encode as $key) {
1010
- if(isset($params[$key]) && strlen(trim($params[$key])) > 0) {
1011
- $params[$key] = base64_encode(stripslashes($params[$key]));
1012
- }
1013
- }
1014
- return $params;
1015
  }
1016
 
1017
  function decodeParameters($params = array()) {
1018
- // decode string parameters
1019
- $keys_to_decode = array('author_label', 'category_label', 'readmore');
1020
- foreach($keys_to_decode as $key) {
1021
- if(isset($params[$key]) && strlen(trim($params[$key])) > 0) {
1022
- $params[$key] = base64_decode($params[$key]);
1023
- }
1024
- }
1025
- return $params;
1026
  }
1027
 
1028
- function renderEmailBody() {
1029
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
1030
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
1031
- $helper_render_engine->setStripSpecialchars(true);
1032
-
1033
- $blocks = $this->getData('body');
1034
- $styles = array('body' => $this->getStyles('body'));
1035
-
1036
- // default newsletter type
1037
- $newsletter_type = 'default';
1038
-
1039
- // check if we need to interpret shortcodes
1040
- $model_config = WYSIJA::get('config', 'model');
1041
- $interpret_shortcode = (bool)$model_config->getValue('interp_shortcode');
1042
-
1043
- $body = '';
1044
-
1045
- // check if we are dealing with an auto newsletter
1046
- $email = $this->getEmailData();
1047
- if(isset($email['params']['autonl']) && !empty($email['params']['autonl'])) {
1048
- // set newsletter type to automattic newsletter
1049
- $newsletter_type = 'automatic';
1050
-
1051
- // posts data
1052
- $first_subject = null;
1053
- $post_count = 0;
1054
- $post_ids = array();
1055
-
1056
- }
1057
-
1058
- foreach($blocks as $key => $block) {
1059
- // reset block HTML so as to avoid duplicates
1060
- $blockHTML = '';
1061
-
1062
- // reset category_ids
1063
- $include_category_ids = array();
1064
- $exclude_category_ids = array();
1065
- $category_ids = array();
1066
-
1067
- // specific background color
1068
- $block_background_color = null;
1069
-
1070
- // get background color if specified
1071
- if(isset($block['background_color']) && strlen($block['background_color']) === 6) {
1072
- $block_background_color = $block['background_color'];
1073
- }
1074
-
1075
- // block width
1076
- $block['block_width'] = 600;
1077
-
1078
- if($block['type'] === 'auto-post') {
1079
- // special case for auto post, we need to fetch posts, taking previously sent posts into account
1080
-
1081
- // get email data
1082
- //$email = $this->getEmailData();
1083
-
1084
- // get block params
1085
- $blockParams = $block['params'];
1086
-
1087
- // format parameters
1088
- $params = array();
1089
-
1090
- $category_ids = array();
1091
- $category_condition = 'include';
1092
-
1093
- foreach($blockParams as $pairs) {
1094
- // store category_ids in email for better performance on immediate sending of WP Posts.
1095
- if($pairs['key'] === 'category_ids') {
1096
- $pair_value = trim($pairs['value']);
1097
- if(!empty($pair_value)) {
1098
- $category_ids = array_map('intval', explode(',', trim($pairs['value'])));
1099
- }
1100
- }
1101
- // store category condition (include / exclude) for same above reason.
1102
- if($pairs['key'] === 'category_condition') {
1103
- $category_condition = (in_array(trim($pairs['value']), array('include', 'exclude'))) ? trim($pairs['value']) : 'include';
1104
- }
1105
- $params[$pairs['key']] = $pairs['value'];
1106
- }
1107
-
1108
- // make sure we store category_ids
1109
- if(!empty($category_ids)) {
1110
- if($category_condition === 'include') {
1111
- $include_category_ids = array_unique($category_ids);
1112
- }
1113
- if($category_condition === 'exclude') {
1114
- $exclude_category_ids = array_unique($category_ids);
1115
- }
1116
- }
1117
-
1118
- // make sure empty bgcolors are set to transparent
1119
- if(isset($params['bgcolor1']) && strlen($params['bgcolor1']) === 0) {
1120
- $params['bgcolor1'] = 'transparent';
1121
- }
1122
- if(isset($params['bgcolor2']) && strlen($params['bgcolor2']) === 0) {
1123
- $params['bgcolor2'] = 'transparent';
1124
- }
1125
-
1126
- // make sure the default params are set
1127
- if(array_key_exists('autonl', $email['params']) === false) {
1128
- $email['params']['autonl'] = array();
1129
- }
1130
- if(array_key_exists('articles', $email['params']['autonl']) === false) {
1131
- $email['params']['autonl']['articles'] = array(
1132
- 'ids' => array(),
1133
- 'count' => 0,
1134
- 'first_subject' => ''
1135
- );
1136
- }
1137
-
1138
- // exclude already sent post ids from selection
1139
- if(!empty($email['params']['autonl']['articles']['ids'])) {
1140
- $params['exclude'] = $email['params']['autonl']['articles']['ids'];
1141
- } else {
1142
- $email['params']['autonl']['articles']['ids'] = array();
1143
- }
1144
-
1145
- //we set the post_date to filter articles only older than that one
1146
- if(isset($email['params']['autonl']['firstSend'])){
1147
- $params['post_date'] = $email['params']['autonl']['firstSend'];
1148
- }
1149
-
1150
- // if immediate let it know to the get post
1151
- if(isset($email['params']['autonl']['articles']['immediatepostid'])){
1152
- $params['include'] = (int)$email['params']['autonl']['articles']['immediatepostid'];
1153
- $params['post_limit'] = 1;
1154
- }else{
1155
- //we set the post_date to filter articles only older than the last time we sent articles
1156
- if(isset($email['params']['autonl']['lastSend'])){
1157
- $params['post_date'] = $email['params']['autonl']['lastSend'];
1158
- }else{
1159
- //get the latest child newsletter sent_at value
1160
- $mEmail=WYSIJA::get('email','model');
1161
- $mEmail->reset();
1162
- $mEmail->orderBy('email_id','DESC');
1163
- $lastEmailSent=$mEmail->getOne(false,array('campaign_id'=>$email['campaign_id'],'type'=>'1'));
1164
-
1165
- if(!empty($lastEmailSent)) $params['post_date'] = $lastEmailSent['sent_at'];
1166
- }
1167
- }
1168
-
1169
- // decode specific keys
1170
- $params = $this->decodeParameters($params);
1171
-
1172
- // include/exclude category_ids
1173
- $params['include_category_ids'] = $include_category_ids;
1174
- $params['exclude_category_ids'] = $exclude_category_ids;
1175
-
1176
- // check for already inserted posts
1177
- if(!empty($post_ids)) {
1178
- $params['exclude'] = $post_ids;
1179
- }
1180
-
1181
- // get posts for this block
1182
- $model_wp_posts = WYSIJA::get('wp_posts','model');
1183
- $posts = $model_wp_posts->get_posts($params);
1184
-
1185
- // check if we have posts to display
1186
- if(!empty($posts)) {
1187
- // get divider if necessary
1188
- if(isset($params['show_divider']) && $params['show_divider'] === 'yes') {
1189
- if(isset($email['params']['divider'])) {
1190
- // either from the email params
1191
- $params['divider'] = $email['params']['divider'];
1192
- } else {
1193
- // get default divider otherwise
1194
- $helper_dividers = WYSIJA::get('dividers', 'helper');
1195
- $params['divider'] = $helper_dividers->getDefault();
1196
- }
1197
- }
1198
-
1199
- $helper_articles = WYSIJA::get('articles', 'helper');
1200
-
1201
- foreach($posts as $key => $post) {
1202
- // assign first post title to autonl parameters (this is used to display the [newsletter:post_title] shortcode in the subject)
1203
- if($first_subject === null && strlen(trim($posts[$key]['post_title'])) > 0) {
1204
- $first_subject = trim($posts[$key]['post_title']);
1205
- }
1206
-
1207
- // check if shortcodes should be interpreted (value comes from WP options)
1208
- if($interpret_shortcode === true) {
1209
- // interpret shortcodes
1210
- $posts[$key]['post_content'] = apply_filters('the_content', $post['post_content']);
1211
- }
1212
- if($params['image_alignment'] !== 'none') {
1213
- // get thumbnail
1214
- $posts[$key]['post_image'] = $helper_articles->getImage($post);
1215
- }
1216
- $post_ids[] = (int)$post['ID'];
1217
- $post_count++;
1218
- }
1219
- // render html from post data and params
1220
- $blockHTML = $this->renderEmailAutoPost($posts, $params);
1221
- }
1222
-
1223
- $this->setEmailData($email);
1224
- } else {
1225
- // set styles
1226
- $block['styles'] = $styles;
1227
- // generate block template
1228
- $blockHTML = $helper_render_engine->render($block, 'templates/newsletter/email/block_template.html');
1229
-
1230
- if($block['type'] !== 'raw') {
1231
- // convert lists in block
1232
- $blockHTML = $this->convertLists($blockHTML);
1233
-
1234
- // apply specific classes on titles and children (strong, em, a)
1235
- $blockHTML = $this->applyTitleClasses($blockHTML);
1236
-
1237
- // apply inline styles
1238
- $blockHTML = $this->applyInlineStyles('body', $blockHTML, array('background_color' => $block_background_color));
1239
-
1240
- // convert titles in block
1241
- $blockHTML = $this->convertTitles($blockHTML);
1242
- }
1243
- }
1244
-
1245
- // append generated html to body
1246
- if($blockHTML !== '') {
1247
- // render each block
1248
- $body .= $blockHTML;
1249
- }
1250
- }
1251
-
1252
- if($newsletter_type === 'automatic') {
1253
- $email = $this->getEmailData();
1254
- // set auto newsletter parameters
1255
- $email['params']['autonl']['articles']['count'] = $post_count;
1256
- $email['params']['autonl']['articles']['first_subject'] = $first_subject;
1257
- $email['params']['autonl']['articles']['ids'] = array_unique(array_merge($email['params']['autonl']['articles']['ids'], $post_ids));
1258
-
1259
- $this->setEmailData($email);
1260
- }
1261
-
1262
- return $body;
1263
- }
1264
-
1265
- function renderEmailFooter() {
1266
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
1267
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
1268
- $helper_render_engine->setStripSpecialchars(true);
1269
-
1270
- $data = $this->getData('footer');
1271
- $data['styles'] = array('footer' => $this->getStyles('footer'));
1272
-
1273
- // check for emptyness
1274
- if($data['text'] === NULL and $data['image']['static'] === TRUE) {
1275
- return NULL;
1276
- }
1277
-
1278
- // set footer content width
1279
- $data['block_width'] = 600;
1280
-
1281
- // generate block template
1282
- $footer = $helper_render_engine->render($data, 'templates/newsletter/email/footer_template.html');
1283
-
1284
- // apply inline styles
1285
- $footer = $this->applyInlineStyles('footer', $footer);
1286
-
1287
- return $footer;
1288
- }
1289
-
1290
- /**
1291
- * area : header, body, footer, unsubscribe, viewbrowser
1292
- * block : raw html
1293
- */
1294
- function applyInlineStyles($area, $block, $extra = array()) {
1295
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
1296
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
1297
- $helper_render_engine->setInline(true);
1298
-
1299
- // common tags
1300
- $tags = array(
1301
- 'table' => array(
1302
- 'border-collapse' => 'collapse',
1303
- 'mso-table-space' => '0pt',
1304
- 'clear' => 'both'
1305
- ),
1306
- 'td' => array(
1307
- 'border-collapse' => 'collapse'
1308
- )
1309
- );
1310
- // common classes
1311
- $classes = array();
1312
-
1313
- // set block background color
1314
- if(array_key_exists('background_color', $extra) and $extra['background_color'] !== null) {
1315
- $background_color = $extra['background_color'];
1316
- } else {
1317
- switch ($area) {
1318
- case 'header':
1319
- case 'footer':
1320
- case 'body':
1321
- $background_color = $this->getStyle($area, 'background');
1322
- break;
1323
- case 'unsubscribe':
1324
- $background_color = $this->getStyle('html', 'background');
1325
- break;
1326
- default:
1327
- $background_color = $this->getStyle('html', 'background');
1328
- break;
1329
- }
1330
- }
1331
-
1332
- // set common styles
1333
- $styles = array(
1334
- 'titles' => array(
1335
- 'word-wrap' => true,
1336
- 'padding' => '0',
1337
- 'margin' => '3px 0 10px 0',
1338
- 'font-weight' => 'normal',
1339
- 'line-height' => '1.25em'
1340
- ),
1341
- 'images' => array(
1342
- 'margin' => '0',
1343
- 'padding' => '0',
1344
- 'display' => 'block',
1345
- 'border' => array(
1346
- 'size' => '1px',
1347
- 'style' => 'solid',
1348
- 'color' => $this->formatColor($background_color)
1349
- )
1350
- )
1351
- );
1352
-
1353
- // area specific classes/tags
1354
- switch($area) {
1355
- case 'header':
1356
- case 'footer':
1357
- $classes = array(
1358
- 'wysija_'.$area => array('min-width' => '100%'),
1359
- 'wysija_'.$area.'_container' => $this->getStyles($area),
1360
- 'wysija_content_container' => array_merge($this->getStyles($area), array('padding' => '0')),
1361
- // images alignments
1362
- 'wysija_image_container center' => array_merge($styles['images'], array('margin' => '0 auto 0 auto', 'text-align' => 'center', 'border' => '0')),
1363
- 'wysija_image_container left' => array_merge($styles['images'], array('border' => '0')),
1364
- 'wysija_image_container right' => array_merge($styles['images'], array('border' => '0')),
1365
- // image placeholder
1366
- 'wysija_image_placeholder' => array('padding' => '0 0 0 0', 'margin' => '0 0 0 0', 'display' => 'block'),
1367
-
1368
- // links around images
1369
- 'wysija_image_link' => array('outline' => '0', 'border' => '0', 'margin' => '0', 'padding' => '0', 'display' => 'block'),
1370
-
1371
- // images
1372
- 'image_fix' => array('display' => 'block', 'outline' => '0', 'text-decoration' => 'none', 'interpolation' => 'bicubic')
1373
- );
1374
- break;
1375
-
1376
- case 'body':
1377
- $tags = array_merge($tags, array(
1378
- 'h1' => array_merge($styles['titles'], $this->getStyles('h1')),
1379
- 'h2' => array_merge($styles['titles'], $this->getStyles('h2')),
1380
- 'h3' => array_merge($styles['titles'], $this->getStyles('h3')),
1381
- 'p' => array_merge($this->getStyles('body'), array('word-wrap' => true, 'padding' => '0', 'margin' => '1em 0', 'line-height' => '1.5em', 'vertical-align' => 'top')),
1382
- 'a' => array_merge($this->getStyles('body'), $this->getStyles('a'), array('word-wrap' => true))
1383
- ));
1384
-
1385
- $classes = array(
1386
- // blocks
1387
- 'wysija_block' => array('min-width' => '100%'),
1388
- 'wysija_content_container' => array('padding' => '10px 17px 10px 17px'),
1389
- 'wysija_divider_container' => array('padding' => '15px 17px 15px 17px'),
1390
- 'wysija_gallery_container' => array('padding' => '10px 17px 10px 17px'),
1391
-
1392
- // text
1393
- 'wysija_text_container' => array('margin' => '1em 0'),
1394
- 'align-left' => array('text-align' => 'left'),
1395
- 'align-center' => array('text-align' => 'center'),
1396
- 'align-right' => array('text-align' => 'right'),
1397
- 'align-justify' => array('text-align' => 'justify'),
1398
-
1399
- // links in titles
1400
- 'wysija_title_1_link' => array_merge($styles['titles'], $this->getStyles('h1'), $this->getStyles('a')),
1401
- 'wysija_title_2_link' => array_merge($styles['titles'], $this->getStyles('h2'), $this->getStyles('a')),
1402
- 'wysija_title_3_link' => array_merge($styles['titles'], $this->getStyles('h3'), $this->getStyles('a')),
1403
- // strong tags in titles
1404
- 'wysija_title_1_strong' => array_merge($styles['titles'], $this->getStyles('h1'), array('font-weight' => 'bold')),
1405
- 'wysija_title_2_strong' => array_merge($styles['titles'], $this->getStyles('h2'), array('font-weight' => 'bold')),
1406
- 'wysija_title_3_strong' => array_merge($styles['titles'], $this->getStyles('h3'), array('font-weight' => 'bold')),
1407
- // italic tags in titles
1408
- 'wysija_title_1_italic' => array_merge($styles['titles'], $this->getStyles('h1'), array('font-style' => 'italic')),
1409
- 'wysija_title_2_italic' => array_merge($styles['titles'], $this->getStyles('h2'), array('font-style' => 'italic')),
1410
- 'wysija_title_3_italic' => array_merge($styles['titles'], $this->getStyles('h3'), array('font-style' => 'italic')),
1411
-
1412
- // links around images
1413
- 'wysija_image_link' => array('outline' => '0', 'border' => '0', 'margin' => '0', 'padding' => '0', 'display' => 'block'),
1414
-
1415
- // images
1416
- 'image_fix' => array('display' => 'block', 'outline' => '0', 'text-decoration' => 'none', 'interpolation' => 'bicubic'),
1417
-
1418
- // images alignments
1419
- 'wysija_image_table center' => array('margin' => '0 auto 0 auto', 'text-align' => 'center'),
1420
-
1421
- 'wysija_image_container center' => array_merge($styles['images'], array('padding' => '1em 0 0 0', 'margin' => '0 auto 0 auto', 'text-align' => 'left')),
1422
- 'wysija_image_container left' => array_merge($styles['images'], array('padding' => '1em 10px 1em 0')),
1423
- 'wysija_image_container right' => array_merge($styles['images'], array('padding' => '1em 0 1em 10px')),
1424
-
1425
- 'wysija_image_placeholder left' => array('padding' => '0 0 0 0', 'margin' => '3px 10px 1em 0', 'display' => 'block'),
1426
- 'wysija_image_placeholder right' => array('padding' => '0 0 0 0', 'margin' => '3px 0 1em 10px', 'display' => 'block'),
1427
-
1428
- // gallery
1429
- 'wysija_gallery_table center' => array('margin' => '0 auto 0 auto', 'text-align' => 'center'),
1430
- 'wysija_cell_container' => array('border' => $styles['images']['border'])
1431
- );
1432
- break;
1433
-
1434
- case 'viewbrowser':
1435
- $tags = array_merge($tags, array(
1436
- 'a' => $this->getStyles('viewbrowser')
1437
- ));
1438
-
1439
- $classes = array(
1440
- 'wysija_viewbrowser_container' => array_merge(
1441
- $this->getStyles('html'),
1442
- $this->getStyles('viewbrowser'),
1443
- array(
1444
- 'text-align' => 'center',
1445
- 'padding' => '8px'
1446
- )
1447
- )
1448
- );
1449
- break;
1450
-
1451
- case 'unsubscribe':
1452
- $tags = array_merge($tags, array(
1453
- 'a' => $this->getStyles('unsubscribe')
1454
- ));
1455
-
1456
- $classes = array(
1457
- 'wysija_unsubscribe_container' => array_merge(
1458
- $this->getStyles('html'),
1459
- $this->getStyles('unsubscribe'),
1460
- array(
1461
- 'family' => 'Verdana',
1462
- 'size' => '12',
1463
- 'text-align' => 'center',
1464
- 'padding' => '8px'
1465
- )
1466
- )
1467
- );
1468
- break;
1469
- }
1470
-
1471
- $tags_to_check = array('p', 'a', 'ul', 'li', 'h2');
1472
- $classes_to_check = array('wysija_content_container', 'wysija_image_container', 'wysija_divider_container', 'wysija_gallery_container', 'wysija_cell_container', 'wysija_list_bullet', 'wysija_list_value');
1473
-
1474
- // check tags and set custom background color
1475
- foreach($tags_to_check as $tag) {
1476
- if(isset($tags[$tag])) {
1477
- $tags[$tag]['background'] = $background_color;
1478
- }
1479
- }
1480
-
1481
- // check classes and set custom background color
1482
- foreach($classes_to_check as $class) {
1483
- if(isset($classes[$class])) {
1484
- $classes[$class]['background'] = $background_color;
1485
- }
1486
- }
1487
-
1488
- if(empty($tags) === FALSE) {
1489
-
1490
- foreach($tags as $tag => $styles) {
1491
- $styles = $this->splitSpacing($styles);
1492
- $inlineStyles = $helper_render_engine->render(array_merge($styles, array('tag' => $tag)), 'styles/inline.html');
1493
- $inlineStyles = preg_replace('/(\n*)/', '', $inlineStyles);
1494
- $tags['#< *'.$tag.'((?:(?!style).)*)>#Ui'] = '<'.$tag.' style="'.$inlineStyles.'"$1>';
1495
- unset($tags[$tag]);
1496
- }
1497
-
1498
- $block = preg_replace(array_keys($tags), $tags, $block);
1499
- }
1500
-
1501
- if(empty($classes) === FALSE) {
1502
- foreach($classes as $class => $styles) {
1503
- // split spacing styles
1504
- $styles = $this->splitSpacing($styles);
1505
- $inlineStyles = $helper_render_engine->render($styles, 'styles/inline.html');
1506
- $inlineStyles = preg_replace('/(\n*)/', '', $inlineStyles);
1507
-
1508
- // build regexp for this class
1509
- $classes['#<([^ /]+) ((?:(?!>|style).)*)(?:style="([^"]*)")?((?:(?!>|style).)*)class="([^"]*)'.$class.'([^"]*)"((?:(?!>|style).)*)(?:style="([^"]*)")?((?:(?!>|style).)*)>#Ui'] = '<$1 $2$4$7 class="$5'.$class.'$6" style="$3$8'.$inlineStyles.'" $9>';
1510
-
1511
- unset($classes[$class]);
1512
- }
1513
-
1514
- $styledBlock = preg_replace(array_keys($classes), $classes, $block);
1515
- // Check if the preg_replace worked. Otherwise we simply return the original block
1516
- if(strlen(trim($styledBlock)) > 0) {
1517
- $block = $styledBlock;
1518
- }
1519
- }
1520
-
1521
- return $block;
1522
- }
1523
-
1524
- function splitSpacing($styles) {
1525
- foreach($styles as $property => $value) {
1526
- if($property === 'margin' or $property === 'padding') {
1527
- // extract multi-values
1528
- $values = explode(' ', $value);
1529
-
1530
- // split values depending on values count
1531
- switch(count($values)) {
1532
- case 1:
1533
- $styles[$property.'-top'] = $values[0];
1534
- $styles[$property.'-right'] = $values[0];
1535
- $styles[$property.'-bottom'] = $values[0];
1536
- $styles[$property.'-left'] = $values[0];
1537
- break;
1538
- case 2:
1539
- $styles[$property.'-top'] = $values[0];
1540
- $styles[$property.'-right'] = $values[1];
1541
- $styles[$property.'-bottom'] = $values[0];
1542
- $styles[$property.'-left'] = $values[1];
1543
- break;
1544
- case 4:
1545
- $styles[$property.'-top'] = $values[0];
1546
- $styles[$property.'-right'] = $values[1];
1547
- $styles[$property.'-bottom'] = $values[2];
1548
- $styles[$property.'-left'] = $values[3];
1549
- break;
1550
- }
1551
-
1552
- // unset original value
1553
- unset($styles[$property]);
1554
- }
1555
- }
1556
- return $styles;
1557
- }
1558
-
1559
- function formatColor($color) {
1560
- if(strlen(trim($color)) === 0 or $color === 'transparent') {
1561
- return 'transparent';
1562
- } else {
1563
- return '#'.$color;
1564
- }
1565
- }
1566
-
1567
- function convertTitles($html) {
1568
- $patterns = array(
1569
- '/<h[1|2|3](.*?)>/',
1570
- '/<\/h[1|2|3]>/',
1571
- );
1572
-
1573
- $replacements = array(
1574
- '<p$1>',
1575
- '</p>'
1576
- );
1577
-
1578
- return preg_replace($patterns, $replacements, $html);
1579
- }
1580
-
1581
- // apply
1582
- function applyTitleClasses($html) {
1583
-
1584
- // set class for links in titles
1585
- $html = preg_replace_callback('#(<h([1|2|3]) ?((?:(?!>|class).)*)(?:class="([^"]*)")?((?:(?!>|class).)*)>(.*)<\/h[1|2|3]>)#Ui',
1586
- create_function('$matches',
1587
- '$output = $matches[0];'.
1588
- '$title_class = \'wysija_title_\'.(int)$matches[2];'.
1589
- '$link_class = $title_class.\'_link\';'.
1590
- '$strong_class = $title_class.\'_strong\';'.
1591
- '$italic_class = $title_class.\'_italic\';'.
1592
- '$output = str_replace(\'<a\', \'<a class="\'.$link_class.\'"\', $output);'.
1593
- '$output = str_replace(\'<strong\', \'<strong class="\'.$strong_class.\'"\', $output);'.
1594
- '$output = str_replace(\'<em\', \'<em class="\'.$italic_class.\'"\', $output);'.
1595
- '$output = str_replace(\'<h\'.(int)$matches[2], \'<h\'.(int)$matches[2].\' class="\'.$title_class.\'"\', $output);'.
1596
- 'return $output;'
1597
- ),
1598
- $html
1599
- );
1600
-
1601
- return $html;
1602
- }
1603
-
1604
- // converts lists (ul, ol, li) into paragraphs for email compatibility
1605
- function convertLists($html) {
1606
- $patterns = array(
1607
- '/<ul.*?>/',
1608
- '/<ol.*?>/',
1609
- '/<\/ul>/',
1610
- '/<\/ol>/',
1611
- '/<li ?((?:(?!>|class).)*)(?:class="([^"]*)")?((?:(?!>|class).)*)>/',
1612
- '/<\/li>/'
1613
- );
1614
-
1615
- $replacements = array(
1616
- '',
1617
- '',
1618
- '',
1619
- '',
1620
- '<p class="wysija_list_item $2">&bull;&nbsp;',
1621
- '</p>'
1622
- );
1623
-
1624
- return preg_replace($patterns, $replacements, $html);
1625
-
1626
- }
1627
  }
4
  * @class Wysija Engine Helper (PHP4 version)
5
  */
6
  class WYSIJA_help_wj_engine extends WYSIJA_object {
7
+ // debug mode
8
+ var $_debug = false;
9
+
10
+ // contains email data
11
+ var $_email_data = null;
12
+
13
+ // rendering context (editor, email)
14
+ var $_context = 'editor';
15
+
16
+ // toggles for vib & unsub
17
+ var $_hide_viewbrowser = false;
18
+ var $_hide_unsubscribe = false;
19
+
20
+ // data holders
21
+ var $_data = null;
22
+ var $_styles = null;
23
+
24
+ // styles: defaults
25
+ var $VIEWBROWSER_SIZES = array(7, 8, 9, 10, 11, 12, 13, 14);
26
+ var $TEXT_SIZES = array(8, 9, 10, 11, 12, 13, 14, 16, 18, 24, 36, 48, 72);
27
+ var $TITLE_SIZES = array(16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 40, 44, 48, 54, 60, 66, 72);
28
+ var $FONTS = array("Arial", "Arial Black", "Comic Sans MS", "Courier New", "Georgia", "Impact", "Tahoma", "Times New Roman", "Trebuchet MS", "Verdana");
29
+
30
+ /* Constructor */
31
+ function WYSIJA_help_wj_engine() { }
32
+
33
+ /* i18n methods */
34
+ function getTranslations() {
35
+ return array(
36
+ 'dropHeaderNotice' => __('Drop your logo in this header.',WYSIJA),
37
+ 'dropFooterNotice' => __('Drop your footer image here.',WYSIJA),
38
+ 'dropBannerNotice' => __('If you leave this area empty, it will not display once you send your email',WYSIJA),
39
+ 'clickToEditText' => __('Click here to add a title or text.', WYSIJA),
40
+ 'alignmentLeft' => __('Align left',WYSIJA),
41
+ 'alignmentCenter' => __('Align center',WYSIJA),
42
+ 'alignmentRight' => __('Align right',WYSIJA),
43
+ 'addImageLink' => __('Add link / Alternative text',WYSIJA),
44
+ 'removeImageLink' => __('Remove link',WYSIJA),
45
+ 'removeImage' => __('Remove image',WYSIJA),
46
+ 'remove' => __('Remove', WYSIJA),
47
+ 'editText' => __( 'Edit text',WYSIJA),
48
+ 'removeText' => __('Remove text',WYSIJA),
49
+ 'textLabel' => __('Titles & text',WYSIJA),
50
+ 'dividerLabel' => __('Horizontal line',WYSIJA),
51
+ 'customDividerLabel' => __('Custom horizontal line',WYSIJA),
52
+ 'postLabel' => __('WordPress post',WYSIJA),
53
+ 'styleBodyLabel' => __('Text',WYSIJA),
54
+ 'styleViewbrowserLabel' => __('"View in browser"', WYSIJA),
55
+ 'styleH1Label' => __('Heading 1',WYSIJA),
56
+ 'styleH2Label' => __('Heading 2',WYSIJA),
57
+ 'styleH3Label' => __('Heading 3',WYSIJA),
58
+ 'styleLinksLabel' => __('Links',WYSIJA),
59
+ 'styleLinksDecorationLabel' => __('underline',WYSIJA),
60
+ 'styleFooterLabel' => __('Footer text',WYSIJA),
61
+ 'styleFooterBackgroundLabel' => __('Footer background',WYSIJA),
62
+ 'styleBodyBackgroundLabel' => __('Newsletter',WYSIJA),
63
+ 'styleHtmlBackgroundLabel' => __('Background', WYSIJA),
64
+ 'styleHeaderBackgroundLabel' => __('Header background', WYSIJA),
65
+ 'styleDividerLabel' => __('Horizontal line',WYSIJA),
66
+ 'styleUnsubscribeColorLabel' => __('Unsubscribe',WYSIJA),
67
+ 'articleSelectionTitle' => __('Post Selection', WYSIJA),
68
+ 'bookmarkSelectionTitle' => __('Social Bookmark Selection', WYSIJA),
69
+ 'dividerSelectionTitle' => __('Divider Selection', WYSIJA),
70
+ 'abouttodeletetheme' => __('You are about to delete the theme : %1$s. Do you really want to do that?', WYSIJA),
71
+ 'addLinkTitle' => __('Add Link & Alternative text', WYSIJA),
72
+ 'styleTransparent' => __('Check this box if you want transparency', WYSIJA),
73
+ 'ajaxLoading' => __('Loading...', WYSIJA),
74
+ 'customFieldsLabel' => __('Insert dynamic data about your subscribers, the newsletter, today\'s date, etc...', WYSIJA),
75
+ 'autoPostSettingsTitle' => __('Selection options', WYSIJA),
76
+ 'autoPostEditSettings' => __('Edit Automatic latest content', WYSIJA),
77
+ 'autoPostImmediateNotice' => __('You can only add one widget when designing a post notification sent immediately after an article is published', WYSIJA),
78
+ 'toggleImagesTitle' => __('Preview without images', WYSIJA),
79
+ // Tags labels
80
+ 'tags_user' => __('Subscriber', WYSIJA),
81
+ 'tags_user_firstname' => __('First Name', WYSIJA),
82
+ 'tags_user_lastname' => __('Last Name', WYSIJA),
83
+ 'tags_user_email' => __('Email Address', WYSIJA),
84
+ 'tags_user_displayname' => __('WordPress user display name', WYSIJA),
85
+ 'tags_user_count' => __('Total of subscribers', WYSIJA),
86
+ 'tags_newsletter' => __('Newsletter', WYSIJA),
87
+ 'tags_newsletter_subject' => __('Newsletter Subject', WYSIJA),
88
+ 'tags_newsletter_autonl' => __('Post Notifications', WYSIJA),
89
+ 'tags_newsletter_total' => __('Total number of posts or pages', WYSIJA),
90
+ 'tags_newsletter_post_title' => __('Latest post title', WYSIJA),
91
+ 'tags_newsletter_number' => __('Issue number', WYSIJA),
92
+ 'tags_date' => __('Date', WYSIJA),
93
+ 'tags_date_d' => __('Current day of the month number', WYSIJA),
94
+ 'tags_date_dordinal' => __('Current day of the month in ordinal, ie. 2nd, 3rd, etc.', WYSIJA),
95
+ 'tags_date_dtext' => __('Full name of current day', WYSIJA),
96
+ 'tags_date_m' => __('Current month number', WYSIJA),
97
+ 'tags_date_mtext' => __('Full name of current month', WYSIJA),
98
+ 'tags_date_y' => __('Year', WYSIJA),
99
+ 'tags_global' => __('Links', WYSIJA),
100
+ 'tags_global_unsubscribe' => __('Unsubscribe link', WYSIJA),
101
+ 'tags_global_manage' => __('Edit subscription page link', WYSIJA),
102
+ 'tags_global_browser' => __('View in browser link', WYSIJA),
103
+ 'custom_fields_title' => __('Custom Fields', WYSIJA),
104
+ 'custom_fields_list' => WJ_Field::get_all_names(),
105
+ // Themes specific labels
106
+ 'theme_setting_default' => __('Saving default style...', WYSIJA),
107
+ 'theme_saved_default' => __('Default style saved.', WYSIJA),
108
+ 'theme_save_as_default' => __('Set as default style.', WYSIJA)
109
+ );
110
+ }
111
+
112
+ /* Data methods */
113
+ function getData($type = null) {
114
+ if($type !== null) {
115
+ if(array_key_exists($type, $this->_data)) {
116
+ return $this->_data[$type];
117
+ } else {
118
+ // return default value
119
+ $defaults = $this->getDefaultData();
120
+ return $defaults[$type];
121
+ }
122
+ }
123
+ return $this->_data;
124
+ }
125
+
126
+ function setData($value = null, $decode = false) {
127
+ if(!$value) {
128
+ $this->_data = $this->getDefaultData();
129
+ } else {
130
+ $this->_data = $value;
131
+ if($decode) {
132
+ $this->_data = $this->getDecoded('data');
133
+ }
134
+ }
135
+ }
136
+
137
+ function getEmailData($key = null) {
138
+ if($key === null) {
139
+ return $this->_email_data;
140
+ } else {
141
+ if(array_key_exists($key, $this->_email_data)) {
142
+ return $this->_email_data[$key];
143
+ }
144
+ }
145
+ return null;
146
+ }
147
+
148
+ function setEmailData($value = null) {
149
+ if($value !== null) {
150
+ $this->_email_data = $value;
151
+ }
152
+ }
153
+
154
+ function getDefaultData() {
155
+ $dividersHelper = WYSIJA::get('dividers', 'helper');
156
+ return array(
157
+ 'header' => array(
158
+ 'alignment' => 'center',
159
+ 'type' => 'header',
160
+ 'static' => '1',
161
+ 'text' => null,
162
+ 'image' => array(
163
+ 'src' => null,
164
+ 'width' => 600,
165
+ 'height' => 86,
166
+ 'url' => null,
167
+ 'alignment' => 'center',
168
+ 'static' => '1'
169
+ )
170
+ ),
171
+ 'body' => array(),
172
+ 'footer' => array(
173
+ 'alignment' => 'center',
174
+ 'type' => 'footer',
175
+ 'static' => '1',
176
+ 'text' => null,
177
+ 'image' => array(
178
+ 'src' => null,
179
+ 'width' => 600,
180
+ 'height' => 86,
181
+ 'url' => null,
182
+ 'alignment' => 'center',
183
+ 'static' => '1'
184
+ )
185
+ ),
186
+ 'widgets' => array(
187
+ 'divider' => array_merge($dividersHelper->getDefault(), array('type' => 'divider'))
188
+ )
189
+ );
190
+ }
191
+
192
+ /* Styles methods */
193
+ function getStyles($keys = null) {
194
+ if($keys === null) return $this->_styles;
195
+
196
+ if(!is_array($keys)) {
197
+ $keys = array($keys);
198
+ }
199
+ $output = array();
200
+ for($i=0; $i<count($keys);$i++) {
201
+ if(isset($this->_styles[$keys[$i]])) {
202
+ $output = array_merge($output, $this->_styles[$keys[$i]]);
203
+ }
204
+ }
205
+ return $output;
206
+ }
207
+
208
+ function getStyle($key, $subkey) {
209
+ $styles = $this->getStyles($key);
210
+ return $styles[$subkey];
211
+ }
212
+
213
+ function setStyles($value = null, $decode = false) {
214
+ if(!$value) {
215
+ $this->_styles = $this->getDefaultStyles();
216
+ } else {
217
+ $this->_styles = $value;
218
+ if($decode) {
219
+ $this->_styles = $this->getDecoded('styles');
220
+ }
221
+ }
222
+ }
223
+
224
+ function getDefaultStyles() {
225
+
226
+ $defaults = array(
227
+ 'html' => array(
228
+ 'background' => 'FFFFFF'
229
+ ),
230
+ 'header' => array(
231
+ 'background' => 'FFFFFF'
232
+ ),
233
+ 'body' => array(
234
+ 'color' => '000000',
235
+ 'family' => 'Arial',
236
+ 'size' => $this->TEXT_SIZES[5],
237
+ 'background' => 'FFFFFF'
238
+ ),
239
+ 'footer' => array(
240
+ 'color' => '000000',
241
+ 'family' => 'Arial',
242
+ 'size' => $this->TEXT_SIZES[5],
243
+ 'background' => 'cccccc'
244
+ ),
245
+ 'h1' => array(
246
+ 'color' => '000000',
247
+ 'family' => 'Arial',
248
+ 'size' => $this->TITLE_SIZES[6]
249
+ ),
250
+ 'h2' => array(
251
+ 'color' => '424242',
252
+ 'family' => 'Arial',
253
+ 'size' => $this->TITLE_SIZES[5]
254
+ ),
255
+ 'h3' => array(
256
+ 'color' => '424242',
257
+ 'family' => 'Arial',
258
+ 'size' => $this->TITLE_SIZES[4]
259
+ ),
260
+ 'a' => array(
261
+ 'color' => '4a91b0',
262
+ 'underline' => false
263
+ ),
264
+ 'unsubscribe' => array(
265
+ 'color' => '000000'
266
+ ),
267
+ 'viewbrowser' => array(
268
+ 'color' => '000000',
269
+ 'family' => 'Arial',
270
+ 'size' => $this->VIEWBROWSER_SIZES[4]
271
+ )
272
+ );
273
+
274
+ // get default selected theme
275
+ $model_config = WYSIJA::get('config', 'model');
276
+ $default_theme = $model_config->getValue('newsletter_default_theme', 'default');
277
+
278
+ if($default_theme === 'default') {
279
+ return $defaults;
280
+ } else {
281
+ $helper_themes = WYSIJA::get('themes', 'helper');
282
+ $stylesheet = $helper_themes->getStylesheet($default_theme);
283
+
284
+ $styles = array();
285
+ // look for each tags
286
+ foreach($defaults as $tag => $values) {
287
+ // look for css rules
288
+ preg_match('/\.?'.$tag.'\s?{(.+)}/Ui', $stylesheet, $matches);
289
+ if(isset($matches[1])) {
290
+ // extract styles
291
+ $styles[$tag] = $this->extractStyles($matches[1]);
292
+ } else {
293
+ // fallback to default
294
+ $styles[$tag] = $defaults[$tag];
295
+ }
296
+ }
297
+
298
+ return $styles;
299
+ }
300
+ }
301
+
302
+ function getApplicationData() {
303
+ $app = array();
304
+
305
+ $app['domain'] = WJ_Utils::get_domain();
306
+
307
+ return $app;
308
+ }
309
+
310
+ /* Editor methods */
311
+ function renderEditor() {
312
+ $this->setContext('editor');
313
+
314
+ if($this->isDataValid() === false) {
315
+ throw new Exception('data is not valid');
316
+ } else {
317
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
318
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
319
+
320
+ // get company addressfrom settings
321
+ $config=WYSIJA::get("config","model");
322
+
323
+ $data = array(
324
+ 'header' => $this->renderEditorHeader(),
325
+ 'body' => $this->renderEditorBody(),
326
+ 'footer' => $this->renderEditorFooter(),
327
+ 'unsubscribe' => $config->emailFooterLinks(true),
328
+ 'company_address' => nl2br($config->getValue('company_address')),
329
+ 'is_debug' => $this->isDebug(),
330
+ 'i18n' => $this->getTranslations()
331
+ );
332
+
333
+ $viewbrowser = $config->viewInBrowserLink(true);
334
+ if($viewbrowser) {
335
+ $data['viewbrowser'] = $viewbrowser;
336
+ }
337
+
338
+ return $helper_render_engine->render($data, 'templates/editor/editor_template.html');
339
+ }
340
+ }
341
+
342
+ function renderEditorHeader($data = null) {
343
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
344
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
345
+ $helper_render_engine->setStripSpecialchars(true);
346
+
347
+ if($data !== null) {
348
+ $block = $data;
349
+ } else {
350
+ $block = $this->getData('header');
351
+ }
352
+
353
+ $data = array_merge($block, array('i18n' => $this->getTranslations()));
354
+ return $helper_render_engine->render($data, 'templates/editor/header_template.html');
355
+ }
356
+
357
+ function renderEditorBody() {
358
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
359
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
360
+
361
+ $blocks = $this->getData('body');
362
+ if(empty($blocks)) return '';
363
+
364
+ $body = '';
365
+ foreach($blocks as $key => $block) {
366
+ // generate block template
367
+ $data = array_merge($block, array('i18n' => $this->getTranslations()));
368
+ $body .= $helper_render_engine->render($data, 'templates/editor/block_template.html');
369
+ }
370
+
371
+ return $body;
372
+ }
373
+
374
+ function renderEditorFooter($data = null)
375
+ {
376
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
377
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
378
+
379
+ if($data !== null) {
380
+ $block = $data;
381
+ } else {
382
+ $block = $this->getData('footer');
383
+ }
384
+
385
+ $data = array_merge($block, array('i18n' => $this->getTranslations()));
386
+
387
+ return $helper_render_engine->render($data, 'templates/editor/footer_template.html');
388
+ }
389
+
390
+ function renderEditorBlock($block = array()) {
391
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
392
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
393
+ $helper_render_engine->setStripSpecialchars(true);
394
+
395
+ $block['i18n'] = $this->getTranslations();
396
+
397
+ return $helper_render_engine->render($block, 'templates/editor/block_'.$block['type'].'.html');
398
+ }
399
+
400
+ /* render auto post */
401
+ function renderEditorAutoPost($posts = array(), $params = array()) {
402
+ $output = '';
403
+ if(isset($params['post_ids'])) {
404
+ $output .= '<input type="hidden" name="post_ids" value="'.$params['post_ids'].'" />';
405
+ }
406
+
407
+ // check if there are posts to display
408
+ if(empty($posts)) {
409
+ // if not, display a message stating that the latest content has been sent
410
+ $block = array(
411
+ 'no-block' => true,
412
+ 'type' => 'content',
413
+ 'alignment' => 'center',
414
+ 'background_color' => $params['bgcolor1'],
415
+ 'image' => null,
416
+ 'text' => array('value' => base64_encode(__('Latest content already sent.', WYSIJA)))
417
+ );
418
+ $output .= $this->renderEditorBlock($block);
419
+ } else {
420
+ // otherwise, render all posts into blocks
421
+ $output .= $this->renderPostsToBlocks($posts, $params, 'autopost');
422
+ }
423
+
424
+ return $output;
425
+ }
426
+
427
+ function renderEmailAutoPost($posts = array(), $params = array()) {
428
+ if(empty($posts)) {
429
+ return '';
430
+ } else {
431
+ return $this->renderPostsToBlocks($posts, $params, 'autopost');
432
+ }
433
+ }
434
+
435
+ function renderEmailBlock($block = array()) {
436
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
437
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
438
+ $helper_render_engine->setStripSpecialchars(true);
439
+
440
+ // set block background color
441
+ $background_color = null;
442
+ if(isset($block['background_color'])) {
443
+ $background_color = $block['background_color'];
444
+ }
445
+
446
+ return $this->applyInlineStyles(
447
+ 'body',
448
+ $helper_render_engine->render($block, 'templates/email_v3/block_'.$block['type'].'.html'),
449
+ array('background_color' => $background_color)
450
+ );
451
+ }
452
+
453
+ function renderPostsToBlocks($posts = array(), $params = array(), $mode = 'post') {
454
+ $html = '';
455
+ $context = $this->getContext();
456
+
457
+ $helper_articles = WYSIJA::get('articles', 'helper');
458
+
459
+ if($params['title_tag'] === 'list') {
460
+ $list = '<ul class="align-'.$params['title_alignment'].'">';
461
+ }
462
+
463
+ // make sure empty bgcolors are set to transparent
464
+ if(!isset($params['bgcolor1']) || (isset($params['bgcolor1']) && strlen($params['bgcolor1']) === 0)) {
465
+ $params['bgcolor1'] = '';
466
+ }
467
+ if(!isset($params['bgcolor2']) || (isset($params['bgcolor2']) && strlen($params['bgcolor2']) === 0)) {
468
+ $params['bgcolor2'] = '';
469
+ }
470
+
471
+ // BEGIN - posts
472
+ for($i = 0, $count = count($posts); $i < $count; $i++) {
473
+ $post = $posts[$i];
474
+ $is_odd = (bool)($i % 2);
475
+ $is_last = (bool)($i === ($count - 1));
476
+
477
+ // set default background color to transparent
478
+ $background_color = '';
479
+
480
+ // set background color for each post
481
+ if($is_odd === false) $background_color = $params['bgcolor1'];
482
+ if($is_odd === true) $background_color = $params['bgcolor2'];
483
+
484
+ if($params['image_alignment'] === 'alternate') {
485
+ $image_alignment = ($is_odd === false) ? 'left' : 'right';
486
+ } else if($params['image_alignment'] === 'none') {
487
+ $image_alignment = 'left';
488
+ $post['post_image'] = null;
489
+ } else {
490
+ $image_alignment = $params['image_alignment'];
491
+ }
492
+
493
+ // build basic block data
494
+ $block = array(
495
+ 'position' => $i,
496
+ 'type' => 'content',
497
+ 'alignment' => $image_alignment,
498
+ 'background_color' => $background_color,
499
+ 'image' => null,
500
+ 'text' => null
501
+ );
502
+
503
+ // in case of autopost, we need to remove the "block" container because each block will be rendered within the autopost block
504
+ if($mode === 'autopost') {
505
+ $block['no-block'] = true;
506
+ }
507
+
508
+ // get title
509
+ $title = $helper_articles->getPostTitle($post, $params);
510
+
511
+ // if post content is title, force title position inside
512
+ if($params['post_content'] === 'title') {
513
+ $params['title_position'] = 'inside';
514
+ }
515
+
516
+ // only display titles as a list
517
+ if($params['title_tag'] === 'list') {
518
+ $list .= $title;
519
+ continue;
520
+ }
521
+
522
+ // if the title is outside, generate its own block
523
+ if($params['title_position'] === 'outside') {
524
+ // generate title
525
+ $title_block = array_merge($block, array(
526
+ 'alignment' => 'left',
527
+ 'text' => array(
528
+ 'value' => base64_encode($title)
529
+ )
530
+ ));
531
+
532
+ if($context === 'editor') {
533
+ $html .= $this->renderEditorBlock($title_block);
534
+ } else if($context === 'email') {
535
+ $html .= $this->renderEmailBlock($title_block);
536
+ }
537
+ }
538
+
539
+ // generate content
540
+ $content_block = array_merge($block, $helper_articles->convertPostToBlock($post, array_merge($params, array('image_alignment' => $image_alignment))));
541
+
542
+ if($context === 'editor') {
543
+ $html .= $this->renderEditorBlock($content_block);
544
+ } else if($context === 'email') {
545
+ $html .= $this->renderEmailBlock($content_block);
546
+ }
547
+
548
+ // display divider if required
549
+ if(isset($params['divider']) && ($params['divider'] !== null && $is_last === false)) {
550
+ // display divider only if there is one and if it's not the last post
551
+ $divider_block = array_merge(
552
+ array(
553
+ 'type' => 'divider',
554
+ 'no-block' => ($mode === 'autopost')
555
+ ),
556
+ $params['divider']
557
+ );
558
+
559
+ if($context === 'editor') {
560
+ $html .= $this->renderEditorBlock($divider_block);
561
+ } else if($context === 'email') {
562
+ $html .= $this->renderEmailBlock($divider_block);
563
+ }
564
+ }
565
+ }
566
+ // END - Posts
567
+
568
+ if($params['title_tag'] === 'list') {
569
+ $list .= '</ul>';
570
+ $list_block = array_merge($block, array(
571
+ 'alignment' => 'center',
572
+ 'type' => 'content',
573
+ 'text' => array(
574
+ 'value' => base64_encode($list)
575
+ )
576
+ ));
577
+ $html .= $this->renderEditorBlock($list_block);
578
+ }
579
+
580
+ return $html;
581
+ }
582
+
583
+ /* render draggable images list */
584
+ function renderImages($data = array()) {
585
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
586
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
587
+
588
+ return $helper_render_engine->render(array('images' => $data), 'templates/toolbar/images.html');
589
+ }
590
+
591
+ /* render themes list */
592
+ function renderThemes() {
593
+ $themes = array();
594
+ $hThemes = WYSIJA::get('themes', 'helper');
595
+
596
+ $installed = $hThemes->getInstalled();
597
+
598
+ // get default selected theme
599
+ $model_config = WYSIJA::get('config', 'model');
600
+ $default_theme = $model_config->getValue('newsletter_default_theme', 'default');
601
+
602
+ if(empty($installed)) {
603
+ return '';
604
+ } else {
605
+ foreach($installed as $theme) {
606
+ $theme_info = $hThemes->getInformation($theme);
607
+ $theme_info['is_selected'] = (bool)($default_theme === $theme);
608
+ $themes[] = $theme_info;
609
+ }
610
+ }
611
+
612
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
613
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
614
+
615
+ return $helper_render_engine->render(array('themes' => $themes, 'i18n' => $this->getTranslations()), 'templates/toolbar/themes.html');
616
+ }
617
+
618
+ function renderThemeStyles($theme = 'default') {
619
+ $this->setContext('editor');
620
+
621
+ $hThemes = WYSIJA::get('themes', 'helper');
622
+ $stylesheet = $hThemes->getStylesheet($theme);
623
+
624
+ if($stylesheet === NULL) {
625
+ // load default settings
626
+ $this->setStyles(null);
627
+ } else {
628
+ // a stylesheet has been found, let's extract styles
629
+ $styles = array();
630
+ $defaults = $this->getDefaultStyles();
631
+ // look for each tags
632
+ foreach($defaults as $tag => $values) {
633
+ // look for css rules
634
+ preg_match('/\.?'.$tag.'\s?{(.+)}/Ui', $stylesheet, $matches);
635
+ if(isset($matches[1])) {
636
+ // extract styles
637
+ $styles[$tag] = $this->extractStyles($matches[1]);
638
+ } else {
639
+ // fallback to default
640
+ $styles[$tag] = $defaults[$tag];
641
+ }
642
+ }
643
+ $this->setStyles($styles);
644
+ }
645
+
646
+ return array(
647
+ 'css' => $this->renderStyles(),
648
+ 'form' => $this->renderStylesBar()
649
+ );
650
+ }
651
+
652
+ function extractStyles($raw) {
653
+ $rules = explode(';', $raw);
654
+ $output = array();
655
+ foreach($rules as $rule) {
656
+ $sub_property = false;
657
+ $combo = explode(':', $rule);
658
+ if(count($combo) === 2) {
659
+ list($property, $value) = $combo;
660
+ // remove leading and trailing space
661
+ $property = trim($property);
662
+ $value = trim($value);
663
+ } else {
664
+ continue;
665
+ }
666
+
667
+ switch($property) {
668
+ case 'background':
669
+ case 'background-color':
670
+ $property = 'background';
671
+ case 'color':
672
+ // remove # from color
673
+ $value = str_replace('#', '', $value);
674
+ // check if its a 3 chars color
675
+ if(strlen($value) === 3) {
676
+ $value = sprintf('%s%s%s%s%s%s', substr($value, 0, 1), substr($value, 0, 1), substr($value, 1, 1), substr($value, 1, 1), substr($value, 2, 1), substr($value, 2, 1));
677
+ }
678
+ break;
679
+ case 'font-family':
680
+ $property = 'family';
681
+ $fonts = explode(',', $value);
682
+ $value = array_shift($fonts);
683
+ break;
684
+ case 'font-size':
685
+ $property = 'size';
686
+ case 'height':
687
+ $value = (int)$value;
688
+ break;
689
+ case 'text-decoration':
690
+ $property = 'underline';
691
+ $value = ($value === 'none') ? '-1' : '1';
692
+ break;
693
+ case 'border-color':
694
+ // remove # from color
695
+ $value = str_replace('#', '', $value);
696
+ // check if its a 3 chars color
697
+ if(strlen($value) === 3) {
698
+ $value = sprintf('%s%s%s%s%s%s', substr($value, 0, 1), substr($value, 0, 1), substr($value, 1, 1), substr($value, 1, 1), substr($value, 2, 1), substr($value, 2, 1));
699
+ }
700
+ list($property, $sub_property) = explode('-', $property);
701
+ break;
702
+ case 'border-size':
703
+ $value = (int)$value;
704
+ list($property, $sub_property) = explode('-', $property);
705
+ break;
706
+ case 'border-style':
707
+ list($property, $sub_property) = explode('-', $property);
708
+ break;
709
+ }
710
+
711
+ if($sub_property !== FALSE) {
712
+ $output[$property][$sub_property] = $value;
713
+ } else {
714
+ $output[$property] = $value;
715
+ }
716
+ }
717
+ return $output;
718
+ }
719
+
720
+ function renderTheme($theme = 'default') {
721
+ $output = array(
722
+ 'header' => null,
723
+ 'footer' => null,
724
+ 'divider' => null
725
+ );
726
+
727
+ $hThemes = WYSIJA::get('themes', 'helper');
728
+ $data = $hThemes->getData($theme);
729
+
730
+ if($data['header'] !== NULL) {
731
+ $output['header'] = $this->renderEditorHeader($data['header']);
732
+ }
733
+
734
+ if($data['footer'] !== NULL) {
735
+ $output['footer'] = $this->renderEditorFooter($data['footer']);
736
+ }
737
+
738
+ if($data['divider'] !== NULL) {
739
+ $output['divider'] = $this->renderEditorBlock(array_merge(array('no-block' => true), $data['divider']));
740
+ $output['divider_options'] = $data['divider'];
741
+ }
742
+
743
+ return $output;
744
+ }
745
+
746
+ /* render styles bar */
747
+ function renderStylesBar() {
748
+ $this->setContext('editor');
749
+
750
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
751
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
752
+ $helper_render_engine->setStripSpecialchars(true);
753
+
754
+ $data = $this->getStyles();
755
+ $data['i18n'] = $this->getTranslations();
756
+ $data['TEXT_SIZES'] = $this->TEXT_SIZES;
757
+ $data['VIEWBROWSER_SIZES'] = $this->VIEWBROWSER_SIZES;
758
+ $data['TITLE_SIZES'] = $this->TITLE_SIZES;
759
+ $data['FONTS'] = $this->FONTS;
760
+
761
+ return $helper_render_engine->render($data, 'templates/toolbar/styles.html');
762
+ }
763
+
764
+ function formatStyles($styles = array()) {
765
+ if(empty($styles)) return;
766
+
767
+ $data = array();
768
+ foreach($styles as $style => $value) {
769
+ $stylesArray = explode('-', $style);
770
+ if(count($stylesArray) === 2) {
771
+ $data[$stylesArray[0]][$stylesArray[1]] = $value;
772
+ } else if(count($stylesArray) === 3) {
773
+ // handle transparent colors
774
+ if($stylesArray[2] === 'transparent') {
775
+ $data[$stylesArray[0]][$stylesArray[1]] = $stylesArray[2];
776
+ } else {
777
+ $data[$stylesArray[0]][$stylesArray[1]][$stylesArray[2]] = $value;
778
+ }
779
+ }
780
+ }
781
+
782
+ return $data;
783
+ }
784
+
785
+ function getContext() {
786
+ return $this->_context;
787
+ }
788
+
789
+ function setContext($value = null) {
790
+ if($value !== null) $this->_context = $value;
791
+ }
792
+
793
+ function isDebug() {
794
+ return ($this->_debug === true);
795
+ }
796
+
797
+ function getEncoded($type = 'data') {
798
+ return base64_encode(serialize($this->{'get'.ucfirst($type)}()));
799
+ }
800
+
801
+ function getDecoded($type = 'data') {
802
+ return unserialize(base64_decode($this->{'get'.ucfirst($type)}()));
803
+ }
804
+
805
+ /* methods */
806
+ function isDataValid() {
807
+ return ($this->getData() !== null);
808
+ }
809
+
810
+ /* Styles methods */
811
+ function renderStyles() {
812
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
813
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
814
+ $helper_render_engine->setStripSpecialchars(true);
815
+ $helper_render_engine->setInline(true);
816
+
817
+ $data = $this->getStyles();
818
+ $data['context'] = $this->getContext();
819
+
820
+ // right to left language property
821
+ if(function_exists('is_rtl')) {
822
+ $data['is_rtl'] = is_rtl();
823
+ } else {
824
+ $data['is_rtl'] = false;
825
+ }
826
+
827
+ switch($data['context']) {
828
+ case 'editor':
829
+ $helper_render_engine->setStripSpecialchars(false);
830
+ $data['viewbrowser_container'] = '#wysija_viewbrowser';
831
+ $data['wysija_container'] = '#wysija_wrapper';
832
+ $data['header_container'] = '#wysija_header';
833
+ $data['body_container'] = '#wysija_body';
834
+ $data['text_container'] = '.editable';
835
+ $data['footer_container'] = '#wysija_footer';
836
+ $data['placeholder_container'] = '#wysija_block_placeholder';
837
+ $data['unsubscribe_container'] = '#wysija_unsubscribe';
838
+ return $helper_render_engine->render($data, 'styles/css-'.$data['context'].'.html');
839
+ break;
840
+
841
+ case 'email':
842
+ $helper_render_engine->setStripSpecialchars(true);
843
+ $data['viewbrowser_container'] = '#wysija_viewbrowser';
844
+ $data['wysija_container'] = '#wysija_wrapper';
845
+ $data['header_container'] = '#wysija_header_content';
846
+ $data['body_container'] = '#wysija_body_content';
847
+ $data['footer_container'] = '#wysija_footer_content';
848
+ $data['text_container'] = '.wysija-text-container';
849
+ $data['unsubscribe_container'] = '#wysija_unsubscribe';
850
+
851
+ return $helper_render_engine->render($data, 'templates/email_v3/css.html');
852
+ break;
853
+ }
854
+ }
855
+
856
+ /* Email methods */
857
+ function renderNotification($email = NULL) {
858
+ $this->_hide_viewbrowser = true;
859
+ $this->_hide_unsubscribe = true;
860
+ return $this->renderEmail($email);
861
+ }
862
+
863
+ function renderEmail($email = NULL) {
864
+
865
+ // fixes issue with pcre functions
866
+ @ini_set('pcre.backtrack_limit', 1000000);
867
+
868
+ $this->setContext('email');
869
+
870
+ if($this->isDataValid() === false) {
871
+ throw new Exception('data is not valid');
872
+ } else {
873
+ // set email data for later use
874
+ $this->setEmailData($email);
875
+
876
+ // render header
877
+ $data = array(
878
+ 'viewbrowser' => $this->renderEmailViewBrowser(),
879
+ 'header' => $this->renderEmailHeader(),
880
+ 'body' => $this->renderEmailBody(),
881
+ 'footer' => $this->renderEmailFooter(),
882
+ 'unsubscribe' => $this->renderEmailUnsubscribe(),
883
+ 'css' => $this->renderStyles(),
884
+ 'styles' => $this->getStyles(),
885
+ 'hide_viewbrowser' => $this->_hide_viewbrowser,
886
+ 'hide_unsubscribe' => $this->_hide_unsubscribe
887
+ );
888
+
889
+ //right to left language property
890
+ if(function_exists('is_rtl')) {
891
+ $data['is_rtl'] = is_rtl();
892
+ } else {
893
+ $data['is_rtl'] = false;
894
+ }
895
+
896
+ // set email subject if specified
897
+ $data['subject'] = $this->getEmailData('subject');
898
+
899
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
900
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
901
+ $helper_render_engine->setStripSpecialchars(true);
902
+ $helper_render_engine->setInline(true);
903
+
904
+ try {
905
+ $template = $helper_render_engine->render($data, 'templates/email_v3/email_template.html');
906
+ return $template;
907
+ } catch(Exception $e) {
908
+ return '';
909
+ }
910
+ }
911
+ }
912
+
913
+ function renderEmailViewBrowser() {
914
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
915
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
916
+ $helper_render_engine->setStripSpecialchars(true);
917
+
918
+ $config=WYSIJA::get('config','model');
919
+ $data = $config->viewInBrowserLink();
920
+ if(!isset($data['link'])) {
921
+ return '';
922
+ } else {
923
+ // generate block template
924
+ $viewbrowser = $helper_render_engine->render($data, 'templates/email_v3/viewbrowser_template.html');
925
+
926
+ // apply inline styles
927
+ $viewbrowser = $this->applyInlineStyles('viewbrowser', $viewbrowser);
928
+
929
+ return $viewbrowser;
930
+ }
931
+ }
932
+
933
+ function renderEmailUnsubscribe() {
934
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
935
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
936
+ $helper_render_engine->setStripSpecialchars(true);
937
+
938
+ $config = WYSIJA::get('config','model');
939
+
940
+ $data = array(
941
+ 'unsubscribe' => $config->emailFooterLinks(),
942
+ 'company_address' => nl2br($config->getValue('company_address'))
943
+ );
944
+
945
+ // generate block template
946
+ $unsubscribe = $helper_render_engine->render($data, 'templates/email_v3/unsubscribe_template.html');
947
+
948
+ // apply inline styles
949
+ $unsubscribe = $this->applyInlineStyles('unsubscribe', $unsubscribe);
950
+
951
+ return $unsubscribe;
952
+ }
953
+
954
+ function renderEmailHeader() {
955
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
956
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
957
+ $helper_render_engine->setStripSpecialchars(true);
958
+
959
+ $data = $this->getData('header');
960
+ $data['styles'] = array('header' => $this->getStyles('header'));
961
+
962
+ // check for emptyness
963
+ if($data['text'] === NULL and $data['image']['static'] === TRUE) {
964
+ return NULL;
965
+ }
966
+
967
+ // set header content width
968
+ $data['block_width'] = 600;
969
+
970
+ // generate block template
971
+ $header = $helper_render_engine->render($data, 'templates/email_v3/header_template.html');
972
+
973
+ // apply inline styles
974
+ $header = $this->applyInlineStyles('header', $header);
975
+
976
+ return $header;
977
+ }
978
+
979
+ function encodeParameters($params = array()) {
980
+ // encode string parameters
981
+ $keys_to_encode = array('author_label', 'category_label', 'readmore');
982
+ foreach($keys_to_encode as $key) {
983
+ if(isset($params[$key]) && strlen(trim($params[$key])) > 0) {
984
+ $params[$key] = base64_encode(stripslashes($params[$key]));
985
+ }
986
+ }
987
+ return $params;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
988
  }
989
 
990
  function decodeParameters($params = array()) {
991
+ // decode string parameters
992
+ $keys_to_decode = array('author_label', 'category_label', 'readmore');
993
+ foreach($keys_to_decode as $key) {
994
+ if(isset($params[$key]) && strlen(trim($params[$key])) > 0) {
995
+ $params[$key] = base64_decode($params[$key]);
996
+ }
997
+ }
998
+ return $params;
999
  }
1000
 
1001
+ function renderEmailBody() {
1002
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
1003
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
1004
+ $helper_render_engine->setStripSpecialchars(true);
1005
+
1006
+ $blocks = $this->getData('body');
1007
+ $styles = array('body' => $this->getStyles('body'));
1008
+
1009
+ // default newsletter type
1010
+ $newsletter_type = 'default';
1011
+
1012
+ // check if we need to interpret shortcodes
1013
+ $model_config = WYSIJA::get('config', 'model');
1014
+ $interpret_shortcode = (bool)$model_config->getValue('interp_shortcode');
1015
+
1016
+ $body = '';
1017
+
1018
+ // check if we are dealing with an auto newsletter
1019
+ $email = $this->getEmailData();
1020
+ if(isset($email['params']['autonl']) && !empty($email['params']['autonl'])) {
1021
+ // set newsletter type to automattic newsletter
1022
+ $newsletter_type = 'automatic';
1023
+ // reset category_ids
1024
+ $include_category_ids = array();
1025
+ $exclude_category_ids = array();
1026
+
1027
+ // posts data
1028
+ $first_subject = null;
1029
+ $post_count = 0;
1030
+ $post_ids = array();
1031
+
1032
+ }
1033
+
1034
+ foreach($blocks as $key => $block) {
1035
+ // reset block HTML so as to avoid duplicates
1036
+ $blockHTML = '';
1037
+
1038
+ // specific background color
1039
+ $block_background_color = null;
1040
+
1041
+ // get background color if specified
1042
+ if(isset($block['background_color']) && strlen($block['background_color']) === 6) {
1043
+ $block_background_color = $block['background_color'];
1044
+ }
1045
+
1046
+ // block width
1047
+ $block['block_width'] = 600;
1048
+
1049
+ if($block['type'] === 'auto-post') {
1050
+ // special case for auto post, we need to fetch posts, taking previously sent posts into account
1051
+
1052
+ // get email data
1053
+ //$email = $this->getEmailData();
1054
+
1055
+ // get block params
1056
+ $blockParams = $block['params'];
1057
+
1058
+ // format parameters
1059
+ $params = array();
1060
+
1061
+ $category_ids = array();
1062
+ $category_condition = 'include';
1063
+
1064
+ foreach($blockParams as $pairs) {
1065
+ // store category_ids in email for better performance on immediate sending of WP Posts.
1066
+ if($pairs['key'] === 'category_ids') {
1067
+ $pair_value = trim($pairs['value']);
1068
+ if(!empty($pair_value)) {
1069
+ $category_ids = explode(',', trim($pairs['value']));
1070
+ }
1071
+ }
1072
+ // store category condition (include / exclude) for same above reason.
1073
+ if($pairs['key'] === 'category_condition') {
1074
+ $category_condition = (in_array(trim($pairs['value']), array('include', 'exclude'))) ? trim($pairs['value']) : 'include';
1075
+ }
1076
+ $params[$pairs['key']] = $pairs['value'];
1077
+ }
1078
+
1079
+ // make sure we store category_ids
1080
+ if(!empty($category_ids)) {
1081
+ if($category_condition === 'include') {
1082
+ $include_category_ids = array_unique(array_merge($include_category_ids, $category_ids));
1083
+ }
1084
+ if($category_condition === 'exclude') {
1085
+ $exclude_category_ids = array_unique(array_merge($exclude_category_ids, $category_ids));
1086
+ }
1087
+ }
1088
+
1089
+ // make sure empty bgcolors are set to transparent
1090
+ if(isset($params['bgcolor1']) && strlen($params['bgcolor1']) === 0) {
1091
+ $params['bgcolor1'] = 'transparent';
1092
+ }
1093
+ if(isset($params['bgcolor2']) && strlen($params['bgcolor2']) === 0) {
1094
+ $params['bgcolor2'] = 'transparent';
1095
+ }
1096
+
1097
+ // make sure the default params are set
1098
+ if(array_key_exists('autonl', $email['params']) === false) {
1099
+ $email['params']['autonl'] = array();
1100
+ }
1101
+ if(array_key_exists('articles', $email['params']['autonl']) === false) {
1102
+ $email['params']['autonl']['articles'] = array(
1103
+ 'ids' => array(),
1104
+ 'count' => 0,
1105
+ 'first_subject' => ''
1106
+ );
1107
+ }
1108
+
1109
+ // exclude already sent post ids from selection
1110
+ if(!empty($email['params']['autonl']['articles']['ids'])) {
1111
+ $params['exclude'] = $email['params']['autonl']['articles']['ids'];
1112
+ }
1113
+
1114
+ //we set the post_date to filter articles only older than that one
1115
+ if(isset($email['params']['autonl']['firstSend'])){
1116
+ $params['post_date'] = $email['params']['autonl']['firstSend'];
1117
+ }
1118
+
1119
+ // if immediate let it know to the get post
1120
+ if(isset($email['params']['autonl']['articles']['immediatepostid'])){
1121
+ $params['include'] = $email['params']['autonl']['articles']['immediatepostid'];
1122
+ $params['post_limit'] = 1;
1123
+ }else{
1124
+ //we set the post_date to filter articles only older than the last time we sent articles
1125
+ if(isset($email['params']['autonl']['lastSend'])){
1126
+ $params['post_date'] = $email['params']['autonl']['lastSend'];
1127
+ }else{
1128
+ //get the latest child newsletter sent_at value
1129
+ $mEmail=WYSIJA::get('email','model');
1130
+ $mEmail->reset();
1131
+ $mEmail->orderBy('email_id','DESC');
1132
+ $lastEmailSent=$mEmail->getOne(false,array('campaign_id'=>$email['campaign_id'],'type'=>'1'));
1133
+
1134
+ if(!empty($lastEmailSent)) $params['post_date'] = $lastEmailSent['sent_at'];
1135
+ }
1136
+ }
1137
+
1138
+ // decode specific keys
1139
+ $params = $this->decodeParameters($params);
1140
+
1141
+ // include/exclude category_ids
1142
+ $params['include_category_ids'] = $include_category_ids;
1143
+ $params['exclude_category_ids'] = $exclude_category_ids;
1144
+
1145
+ // define which fields are required from the posts
1146
+ $params['post_fields'] = array('post_title', 'post_content', 'post_excerpt', 'post_author');
1147
+
1148
+ // check for already inserted posts
1149
+ if(!empty($post_ids)) {
1150
+ $params['exclude'] = $post_ids;
1151
+ }
1152
+
1153
+ // get posts for this block
1154
+ $model_wp_posts = WYSIJA::get('wp_posts','model');
1155
+ $posts = $model_wp_posts->get_posts($params);
1156
+
1157
+ // cleanup post and get image
1158
+ //$post_ids = array();
1159
+ //$post_count = 0;
1160
+
1161
+ // check if we have posts to display
1162
+ if(!empty($posts)) {
1163
+ // get divider if necessary
1164
+ if(isset($params['show_divider']) && $params['show_divider'] === 'yes') {
1165
+ if(isset($email['params']['divider'])) {
1166
+ // either from the email params
1167
+ $params['divider'] = $email['params']['divider'];
1168
+ } else {
1169
+ // get default divider otherwise
1170
+ $helper_dividers = WYSIJA::get('dividers', 'helper');
1171
+ $params['divider'] = $helper_dividers->getDefault();
1172
+ }
1173
+ }
1174
+
1175
+ $helper_articles = WYSIJA::get('articles', 'helper');
1176
+
1177
+ foreach($posts as $key => $post) {
1178
+ // assign first post title to autonl parameters (this is used to display the [newsletter:post_title] shortcode in the subject)
1179
+ if($first_subject === null && strlen(trim($posts[$key]['post_title'])) > 0) {
1180
+ $first_subject = trim($posts[$key]['post_title']);
1181
+ }
1182
+
1183
+ // check if shortcodes should be interpreted (value comes from WP options)
1184
+ if($interpret_shortcode === true) {
1185
+ // interpret shortcodes
1186
+ $posts[$key]['post_content'] = apply_filters('the_content', $post['post_content']);
1187
+ }
1188
+ if($params['image_alignment'] !== 'none') {
1189
+ // get thumbnail
1190
+ $posts[$key]['post_image'] = $helper_articles->getImage($post);
1191
+ }
1192
+
1193
+ $post_ids[] = (int)$post['ID'];
1194
+ $post_count++;
1195
+ }
1196
+ // render html from post data and params
1197
+ $blockHTML = $this->renderEmailAutoPost($posts, $params);
1198
+ }
1199
+
1200
+ // update email post ids sent
1201
+ //$email['params']['autonl']['articles']['ids'] = array_unique(array_merge($email['params']['autonl']['articles']['ids'], $post_ids));
1202
+
1203
+ $this->setEmailData($email);
1204
+ } else {
1205
+ // set styles
1206
+ $block['styles'] = $styles;
1207
+ // generate block template
1208
+ $blockHTML = $helper_render_engine->render($block, 'templates/email_v3/block_template.html');
1209
+
1210
+ if($block['type'] !== 'raw') {
1211
+ // apply inline styles
1212
+ $blockHTML = $this->applyInlineStyles('body', $blockHTML, array('background_color' => $block_background_color));
1213
+ }
1214
+ }
1215
+
1216
+ // append generated html to body
1217
+ if($blockHTML !== '') {
1218
+ // render each block
1219
+ $body .= $blockHTML;
1220
+ }
1221
+ }
1222
+
1223
+ if($newsletter_type === 'automatic') {
1224
+ $email = $this->getEmailData();
1225
+
1226
+ // store category ids
1227
+ $email['params']['autonl']['include_category_ids'] = $include_category_ids;
1228
+ $email['params']['autonl']['exclude_category_ids'] = $exclude_category_ids;
1229
+
1230
+ $email['params']['autonl']['articles']['count'] = $post_count;
1231
+ $email['params']['autonl']['articles']['first_subject'] = $first_subject;
1232
+ $email['params']['autonl']['articles']['ids'] = array_unique(array_merge($email['params']['autonl']['articles']['ids'], $post_ids));
1233
+
1234
+ $this->setEmailData($email);
1235
+ }
1236
+
1237
+ return $body;
1238
+ }
1239
+
1240
+ function renderEmailFooter() {
1241
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
1242
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
1243
+ $helper_render_engine->setStripSpecialchars(true);
1244
+
1245
+ $data = $this->getData('footer');
1246
+ $data['styles'] = array('footer' => $this->getStyles('footer'));
1247
+
1248
+ // check for emptyness
1249
+ if($data['text'] === NULL and $data['image']['static'] === TRUE) {
1250
+ return NULL;
1251
+ }
1252
+
1253
+ // set footer content width
1254
+ $data['block_width'] = 600;
1255
+
1256
+ // generate block template
1257
+ $footer = $helper_render_engine->render($data, 'templates/email_v3/footer_template.html');
1258
+
1259
+ // apply inline styles
1260
+ $footer = $this->applyInlineStyles('footer', $footer);
1261
+
1262
+ return $footer;
1263
+ }
1264
+
1265
+ /**
1266
+ * area : header, body, footer, unsubscribe, viewbrowser
1267
+ * block : raw html
1268
+ */
1269
+ function applyInlineStyles($area, $block, $extra = array()) {
1270
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
1271
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
1272
+ $helper_render_engine->setInline(true);
1273
+
1274
+ $tags = array();
1275
+ $classes = array();
1276
+
1277
+ switch($area) {
1278
+ case 'header':
1279
+ case 'footer':
1280
+ $classes = array(
1281
+ 'wysija-image-container alone-left' => array('margin' => '0', 'padding' => '0'),
1282
+ 'wysija-image-container alone-center' => array('margin' => '0 auto 0 auto', 'padding' => '0', 'text-align' => 'center'),
1283
+ 'wysija-image-container alone-right' => array('margin' => '0', 'padding' => '0')
1284
+ );
1285
+ break;
1286
+
1287
+ case 'body':
1288
+ // set class for links in titles
1289
+ $block = preg_replace_callback('#(<h([1|2|3])[^>]*>(.*)<\/h[1|2|3]>)#Ui',
1290
+ create_function('$matches', '$class = \'h\'.(int)$matches[2].\'-link\'; return str_replace(\'<a\', \'<a class="\'.$class.\'"\', $matches[0]);'),
1291
+ $block);
1292
+
1293
+ $tags = array(
1294
+ 'h1' => array_merge($this->getStyles('h1'), array('word-wrap' => true, 'padding' => '0', 'margin' => '0 0 10px 0', 'font-weight' => 'normal', 'line-height' => '1.3em')),
1295
+ 'h2' => array_merge($this->getStyles('h2'), array('word-wrap' => true, 'padding' => '0', 'margin' => '0 0 10px 0', 'font-weight' => 'normal', 'line-height' => '1.2em')),
1296
+ 'h3' => array_merge($this->getStyles('h3'), array('word-wrap' => true, 'padding' => '0', 'margin' => '0 0 10px 0', 'font-weight' => 'normal', 'line-height' => '1.1em')),
1297
+ 'p' => array_merge($this->getStyles('body'), array('word-wrap' => true, 'padding' => '3px 0 0 0', 'margin' => '0 0 1em 0', 'line-height' => '1.5em', 'vertical-align' => 'top')),
1298
+ 'a' => array_merge($this->getStyles('body'), $this->getStyles('a')),
1299
+ 'ul' => array('line-height' => '1.5em', 'margin' => '0 0 1em 0', 'padding' => '0'),
1300
+ 'ol' => array('line-height' => '1.5em', 'margin' => '0 0 1em 0', 'padding' => '0'),
1301
+ 'li' => array_merge($this->getStyles('body'), array('font-weight' => 'normal', 'list-type' => 'none', 'list-style-type' => 'disc', 'margin' => '0 0 0.7em 30px', 'padding' => '0'))
1302
+ );
1303
+
1304
+ $classes = array(
1305
+ 'wysija-image-container alone-left' => array('margin' => '0', 'padding' => '0'),
1306
+ 'wysija-image-container alone-center' => array('margin' => '1em auto 1em auto', 'padding' => '0', 'text-align' => 'center'),
1307
+ 'wysija-image-container alone-right' => array('margin' => '0', 'padding' => '0'),
1308
+ 'wysija-image-left' => array('vertical-align' => 'top'),
1309
+ 'wysija-image-center' => array('margin' => '0 auto 0 auto', 'vertical-align' => 'top'),
1310
+ 'wysija-image-right' => array('vertical-align' => 'top'),
1311
+ 'wysija-image-container align-left' => array('float' => 'left', 'margin' => '0', 'padding' => '0'),
1312
+ 'wysija-image-container align-center' => array('margin' => '0 auto 0 auto', 'text-align' => 'center', 'padding' => '0'),
1313
+ 'wysija-image-container align-right' => array('float' => 'right', 'margin' => '0', 'padding' => '0'),
1314
+ 'wysija-divider-container' => array('margin' => '0 auto 0 auto', 'padding' => '0', 'text-align' => 'center'),
1315
+ 'h1-link' => array_merge($this->getStyles('h1'), $this->getStyles('a')),
1316
+ 'h2-link' => array_merge($this->getStyles('h2'), $this->getStyles('a')),
1317
+ 'h3-link' => array_merge($this->getStyles('h3'), $this->getStyles('a')),
1318
+ 'align-left' => array('text-align' => 'left'),
1319
+ 'align-center' => array('text-align' => 'center'),
1320
+ 'align-right' => array('text-align' => 'right'),
1321
+ 'align-justify' => array('text-align' => 'justify')
1322
+ );
1323
+
1324
+ // when an extra background_color is specified, apply it to paragraphs & links
1325
+ if(array_key_exists('background_color', $extra) and $extra['background_color'] !== null) {
1326
+ $tags['p']['background'] = $extra['background_color'];
1327
+ $tags['a']['background'] = $extra['background_color'];
1328
+ $tags['ul']['background'] = $extra['background_color'];
1329
+ $tags['li']['background'] = $extra['background_color'];
1330
+ // fixes issue on Outlook.com Mobile where h2 have a white background
1331
+ $tags['h2']['background'] = $extra['background_color'];
1332
+ $tags['p']['background'] = $extra['background_color'];
1333
+ } else {
1334
+ // default newsletter background
1335
+ // fixes issue on Outlook.com Mobile where h2 have a white background
1336
+ $tags['h2']['background'] = $this->getStyle('body', 'background');
1337
+ }
1338
+ break;
1339
+
1340
+ case 'unsubscribe':
1341
+ $tags = array(
1342
+ 'a' => $this->getStyles('unsubscribe')
1343
+ );
1344
+ break;
1345
+ case 'viewbrowser':
1346
+ $tags = array(
1347
+ 'a' => $this->getStyles('viewbrowser')
1348
+ );
1349
+ break;
1350
+ }
1351
+
1352
+ if(empty($tags) === FALSE) {
1353
+
1354
+ foreach($tags as $tag => $styles) {
1355
+ $styles = $this->splitSpacing($styles);
1356
+ $inlineStyles = $helper_render_engine->render(array_merge($styles, array('tag' => $tag)), 'styles/inline.html');
1357
+ $inlineStyles = preg_replace('/(\n*)/', '', $inlineStyles);
1358
+ $tags['#< *'.$tag.'((?:(?!style).)*)>#Ui'] = '<'.$tag.' style="'.$inlineStyles.'"$1>';
1359
+ unset($tags[$tag]);
1360
+ }
1361
+
1362
+ $block = preg_replace(array_keys($tags), $tags, $block);
1363
+ }
1364
+
1365
+ if(empty($classes) === FALSE) {
1366
+ foreach($classes as $class => $styles) {
1367
+ // split spacing styles
1368
+ $styles = $this->splitSpacing($styles);
1369
+ $inlineStyles = $helper_render_engine->render($styles, 'styles/inline.html');
1370
+ $inlineStyles = preg_replace('/(\n*)/', '', $inlineStyles);
1371
+
1372
+ if(in_array($class, array('h1-link', 'h2-link', 'h3-link'))) {
1373
+ $classes['#<([^ /]+) ((?:(?!>|style).)*)(?:style="([^"]*)")?((?:(?!>|style).)*)class="[^"]*'.$class.'[^"]*"((?:(?!>|style).)*)(?:style="([^"]*)")?((?:(?!>|style).)*)>#Ui'] = '<$1 $2$4$5$7 style="'.$inlineStyles.'">';
1374
+ } else {
1375
+ $classes['#<([^ /]+) ((?:(?!>|style).)*)(?:style="([^"]*)")?((?:(?!>|style).)*)class="[^"]*'.$class.'[^"]*"((?:(?!>|style).)*)(?:style="([^"]*)")?((?:(?!>|style).)*)>#Ui'] = '<$1 $2$4$5$7 style="$3$6'.$inlineStyles.'">';
1376
+ }
1377
+ unset($classes[$class]);
1378
+ }
1379
+
1380
+ $styledBlock = preg_replace(array_keys($classes), $classes, $block);
1381
+ // Check if the preg_replace worked. Otherwise we simply return the original block
1382
+ if(strlen(trim($styledBlock)) > 0) {
1383
+ $block = $styledBlock;
1384
+ }
1385
+ }
1386
+
1387
+ // body
1388
+ if($area === 'body' && strlen($block) > 0) {
1389
+ // Outlook fixes
1390
+ // paragraph
1391
+ /*$block = preg_replace('#<\/p>#Ui', "<!--[if gte mso 9]></p><![endif]--></p>", $block);
1392
+ $block = preg_replace('#<p(.*)>#Ui', "\n<p$1><!--[if gte mso 9]></p><p class=\"wysija-fix-paragraph\"><![endif]-->", $block);
1393
+ // h2 titles
1394
+ $block = preg_replace('#<\/h2>#Ui', "<!--[if gte mso 9]></h2><![endif]--></h2>", $block);
1395
+ $block = preg_replace('#<h2(.*)>#Ui', "<h2$1><!--[if gte mso 9]></h2><h2 class=\"wysija-fix-h2\"><![endif]-->", $block);
1396
+ // h3 titles
1397
+ $block = preg_replace('#<\/h3>#Ui', "<!--[if gte mso 9]></h3><![endif]--></h3>", $block);
1398
+ $block = preg_replace('#<h3(.*)>#Ui', "<h3$1><!--[if gte mso 9]></h3><h3 class=\"wysija-fix-h3\"><![endif]-->", $block);
1399
+
1400
+ // lists
1401
+ $block = preg_replace('#<ol(.*)>#Ui', "\n<ul$1>", $block);
1402
+ $block = preg_replace('#<ul(.*)>#Ui', "\n<ul$1>", $block);
1403
+ $block = preg_replace('#<li(.*)>#Ui', "\n<li$1>", $block);
1404
+
1405
+ $pFixStyles = $this->splitSpacing(array_merge($this->getStyles('body'), array('padding' => '3px 0 0 0', 'margin' => '0 0 1.3em 0', 'line-height' => '1em', 'vertical-align' => 'top')));
1406
+ $h2FixStyles = $this->splitSpacing(array_merge($this->getStyles('h2'), array('padding' => '0', 'margin' => '0 0 10px 0', 'font-weight' => 'normal', 'line-height' => '1em')));
1407
+ $h3FixStyles = $this->splitSpacing(array_merge($this->getStyles('h3'), array('padding' => '0', 'margin' => '0 0 10px 0', 'font-weight' => 'normal', 'line-height' => '1em')));
1408
+
1409
+ // apply block background color to elements if specified
1410
+ if(array_key_exists('background_color', $extra) and $extra['background_color'] !== null) {
1411
+ $pFixStyles['background'] = $extra['background_color'];
1412
+ $h2FixStyles['background'] = $extra['background_color'];
1413
+ $h3FixStyles['background'] = $extra['background_color'];
1414
+ }
1415
+
1416
+ $block = str_replace('class="wysija-fix-paragraph"', 'style="'.$helper_render_engine->render($pFixStyles, 'styles/inline.html').'"', $block);
1417
+ $block = str_replace('class="wysija-fix-h2"', 'style="'.$helper_render_engine->render($h2FixStyles, 'styles/inline.html').'"', $block);
1418
+ $block = str_replace('class="wysija-fix-h3"', 'style="'.$helper_render_engine->render($h3FixStyles, 'styles/inline.html').'"', $block);*/
1419
+ }
1420
+
1421
+ return $block;
1422
+ }
1423
+
1424
+ function splitSpacing($styles) {
1425
+ foreach($styles as $property => $value) {
1426
+ if($property === 'margin' or $property === 'padding') {
1427
+ // extract multi-values
1428
+ $values = explode(' ', $value);
1429
+
1430
+ // split values depending on values count
1431
+ switch(count($values)) {
1432
+ case 1:
1433
+ $styles[$property.'-top'] = $values[0];
1434
+ $styles[$property.'-right'] = $values[0];
1435
+ $styles[$property.'-bottom'] = $values[0];
1436
+ $styles[$property.'-left'] = $values[0];
1437
+ break;
1438
+ case 2:
1439
+ $styles[$property.'-top'] = $values[0];
1440
+ $styles[$property.'-right'] = $values[1];
1441
+ $styles[$property.'-bottom'] = $values[0];
1442
+ $styles[$property.'-left'] = $values[1];
1443
+ break;
1444
+ case 4:
1445
+ $styles[$property.'-top'] = $values[0];
1446
+ $styles[$property.'-right'] = $values[1];
1447
+ $styles[$property.'-bottom'] = $values[2];
1448
+ $styles[$property.'-left'] = $values[3];
1449
+ break;
1450
+ }
1451
+
1452
+ // unset original value
1453
+ unset($styles[$property]);
1454
+ }
1455
+ }
1456
+ return $styles;
1457
+ }
1458
+
1459
+ function formatColor($color) {
1460
+ if(strlen(trim($color)) === 0 or $color === 'transparent') {
1461
+ return 'transparent';
1462
+ } else {
1463
+ return '#'.$color;
1464
+ }
1465
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1466
  }
helpers/wp_tools.php CHANGED
@@ -2,326 +2,339 @@
2
  defined('WYSIJA') or die('Restricted access');
3
  class WYSIJA_help_wp_tools extends WYSIJA_object{
4
 
5
- function WYSIJA_help_wp_tools(){
6
-
7
- }
8
-
9
- /**
10
- * add wysija's default capabilities to the admin and super admin roles
11
- */
12
- function set_default_rolecaps(){
13
- //add role capabilities
14
- //get the "administrator" role object
15
- $rolesadmin=array('administrator','super_admin');
16
-
17
- foreach($rolesadmin as $roladm){
18
- $role = get_role($roladm);
19
- if(!$role) continue;
20
- //add wysija's capabilities to it so that other widgets can reuse it
21
- $arr=array('wysija_newsletters','wysija_subscribers','wysija_config','wysija_theme_tab','wysija_style_tab', 'wysija_stats_dashboard');
22
-
23
- foreach($arr as $arrkey){
24
- if(!$role->has_cap($arrkey)) $role->add_cap( $arrkey );
25
- }
26
- }
27
- }
28
-
29
- /**
30
- * get an array of WordPress roles with a numbered index
31
- * @global type $wp_roles
32
- * @return array
33
- */
34
- function wp_get_roles() {
35
- //Careful WordPress global
36
- global $wp_roles;
37
- $all_roles = $wp_roles->roles;
38
- $editable_roles = apply_filters('editable_roles', $all_roles);
39
-
40
- $rolearray=array();
41
- $sum=6;
42
- foreach($editable_roles as $keyrol => $roledetails){
43
- switch($keyrol){
44
- case 'super_admin':
45
- $index=1;
46
- break;
47
- case 'administrator':
48
- $index=2;
49
- break;
50
- case 'editor':
51
- $index=3;
52
- break;
53
- case 'author':
54
- $index=4;
55
- break;
56
- case 'contributor':
57
- $index=5;
58
- break;
59
- case 'subscriber':
60
- $index=6;
61
- break;
62
- default:
63
- $sum++;
64
- $index=$sum;
65
- }
66
- $rolearray[$index]=array('key'=>$keyrol,'name'=>$roledetails['name']);
67
- }
68
- ksort($rolearray);
69
- return $rolearray;
70
- }
71
-
72
- /**
73
- * get an array of WordPress roles with a special capability of that role as index
74
- * @global type $wp_roles
75
- * @return array
76
- */
77
- function wp_get_editable_roles() {
78
- //Careful WordPress global
79
- global $wp_roles;
80
-
81
- $all_roles = $wp_roles->roles;
82
- $editable_roles = apply_filters('editable_roles', $all_roles);
83
-
84
- $possible_values=array();
85
- foreach ( $all_roles as $role => $details ) {
86
- $name = translate_user_role($details['name'] );
87
- switch($role){
88
- case 'administrator':
89
- $keyrole='switch_themes';
90
- break;
91
- case 'editor':
92
- $keyrole='moderate_comments';
93
- break;
94
- case 'author':
95
- $keyrole='upload_files';
96
- break;
97
- case 'contributor':
98
- $keyrole='edit_posts';
99
- break;
100
- case 'subscriber':
101
- $keyrole='read';
102
- break;
103
- default:
104
- $keyrole=$role;
105
- }
106
- $possible_values[$keyrole]=$name;
107
- //$possible_values[key($details['capabilities'])]=$name;
108
- }
109
-
110
- return $possible_values;
111
- }
112
-
113
- /**
114
- * get roles by name ? Not so sure why use that function
115
- * @global type $wp_roles
116
- * @return array
117
- */
118
- function wp_get_all_roles() {
119
- //Careful WordPress global
120
- global $wp_roles;
121
- $all_roles = $wp_roles->get_names();
122
- return $all_roles;
123
- }
124
-
125
- /**
126
- * check whether there is a caching plugin active on this site, we were using that function at some point, it can be useful
127
- * @global type $cache_enabled
128
- * @global type $super_cache_enabled
129
- * @return boolean
130
- */
131
- function is_caching_active(){
132
- $checkPlugins=array(
133
- 'wp-super-cache/wp-cache.php' ,
134
- 'w3-total-cache/w3-total-cache.php',
135
- 'quick-cache/quick-cache.php',
136
- 'hyper-cache/plugin.php'
137
- );
138
-
139
- foreach($checkPlugins as $pluginFileName){
140
- if(WYSIJA::is_plugin_active($pluginFileName)){
141
- switch($pluginFileName){
142
- case 'wp-super-cache/wp-cache.php':
143
- global $cache_enabled, $super_cache_enabled;
144
- if(!(WP_CACHE && $cache_enabled && $super_cache_enabled)) continue(2);
145
- break;
146
- case 'w3-total-cache/w3-total-cache.php':
147
- $config = & w3_instance("W3_Config");
148
- if(!(WP_CACHE && $config->get_boolean("pgcache.enabled"))) continue(2);
149
-
150
- break;
151
- case 'quick-cache/quick-cache.php':
152
- if(!(WP_CACHE && $GLOBALS["WS_PLUGIN__"]["qcache"]["o"]["enabled"])) continue(2);
153
- break;
154
- case 'hyper-cache/plugin.php':
155
- if(!(WP_CACHE)) continue(2);
156
- break;
157
- default:
158
- continue(2);
159
- }
160
- return true;
161
- }
162
- }
163
- return false;
164
- }
165
-
166
- /**
167
- * extends the get_permalink of WordPress since at the beginning we had a lot of problems with people who didn't have pretty urls activated etc..
168
- * @param int $pageid
169
- * @param array $params pass an array of parameters to the url
170
- * @param boolean $simple leading to the home not sure in which case we need that again
171
- * @return string
172
- */
173
- function get_permalink($pageid,$params=array(),$simple=false){
174
- $post = get_post($pageid);
175
-
176
- $url=get_permalink($post);
177
-
178
- if(!$url){
179
- //we need to recreate the subscription page
180
- $values=array();
181
- $helperInstall=WYSIJA::get('install','helper');
182
- $helperInstall->createPage($values);
183
-
184
- $modelConf=WYSIJA::get('config','model');
185
- $modelConf->save($values);
186
- $post = get_post($values['confirm_email_link']);
187
- $url=get_permalink($post);
188
- }
189
-
190
- $paramsquery=parse_url($url);
191
-
192
- if($params!==false) $params[$post->post_type]=$post->post_name;
193
- //make a simple url leading to the home
194
- if($simple){
195
- $url=site_url();
196
- // make sure we have a trailing slash at the end
197
- if($url{strlen($url) - 1} !== '/') $url .= '/';
198
- }
199
-
200
- if(isset($paramsquery['query'])){
201
- $myparams=explode('&',$paramsquery['query']);
202
- //get the param from the url obtain in permalink and transfer it to our url
203
- foreach($myparams as $paramvalu){
204
- $splitkeyval=explode('=',$paramvalu);
205
- $params[$splitkeyval[0]]=$splitkeyval[1];
206
- }
207
- }
208
-
209
- // make sure we include the port if it's specified
210
- if(isset($paramsquery['port']) && strlen(trim($paramsquery['port'])) > 0) {
211
- $port = ':'.(int)$paramsquery['port'];
212
- } else {
213
- $port = '';
214
- }
215
-
216
- // build url
217
- $url = sprintf('%s://%s%s%s', $paramsquery['scheme'], $paramsquery['host'], $port, $paramsquery['path']);
218
-
219
- if($params) {
220
- if(strpos($url, '?') !== false) $charStart='&';
221
- else $charStart='?';
222
- $url.=$charStart;
223
- $paramsinline=array();
224
- foreach($params as $k => $v){
225
- if(is_array($v)) $v = http_build_query(array($k => $v));
226
- $paramsinline[]=$k.'='.$v;
227
- }
228
- $url.=implode('&',$paramsinline);
229
- }
230
-
231
- // Transform relative URLs in Absolute URLs (Protect from external URL transforming plugins)
232
- $parsed_url = parse_url($url);
233
- if (empty($parsed_url['scheme'])) {
234
- $url = get_bloginfo('url') . $url;
235
- }
236
-
237
- return $url;
238
- }
239
-
240
- /**
241
- * return a list of post types
242
- * @return mixed
243
- */
244
- function get_post_types($return_type = 'objects') {
245
- $args=array(
246
- 'public' => true,
247
- '_builtin' => false,
248
- 'show_in_menu'=>true,
249
- 'show_ui'=>true,
250
- );
251
- return get_post_types($args, $return_type);
252
- }
253
-
254
- /**
255
- * return a list of post types
256
- * @return mixed
257
- */
258
- function get_post_statuses(){
259
- return array_merge(get_post_statuses(), array('future'=>__('Scheduled',WYSIJA)));
260
- }
261
-
262
- /**
263
- * get a multidimensionnal array that returns the categories per CPT
264
- */
265
- function get_categories() {
266
-
267
- // For now we wont need the post types as we only "post"
268
- $post_types = get_post_types( array(), 'names' );
269
-
270
- // Grab all taxonomies
271
- $taxonomies = get_object_taxonomies( $post_types, 'object' );
272
-
273
- // Get all terms from the taxonomies
274
- $terms = get_terms(
275
- array_keys( $taxonomies ),
276
- array(
277
- 'order_by' => 'name',
278
- 'show_count' => false,
279
- 'hide_empty' => false,
280
- )
281
- );
282
-
283
- // backwards compatibility later lets use `term_id`
284
- foreach ( $terms as $key => $term ){
285
- $term->id = $term->term_id;
286
- $terms[$key] = (array) $term;
287
- }
288
-
289
- // Create a response with the needed structure
290
- $response = array();
291
-
292
- // If the Post Type has categories associated it will have the terms
293
- foreach ( $post_types as $post_type ){
294
- foreach( $terms as $term ) {
295
- if ( ! in_array( $post_type, $taxonomies[ $term['taxonomy'] ]->object_type ) ){
296
- continue;
297
- }
298
-
299
- $term['name'] = esc_attr( $taxonomies[ $term['taxonomy'] ]->labels->singular_name . ": " . $term['name'] );
300
-
301
- $response[ $post_type ][] = $term;
302
- }
303
-
304
- if ( isset( $response[ $post_type ] ) && is_array( $response[ $post_type ] ) ) {
305
- usort( $response[ $post_type ], array( $this, 'sort_by_name' ) );
306
- }
307
- }
308
-
309
- return $response;
310
- }
311
-
312
- function get_post_category_ids( $post = null ) {
313
- if ( ! is_object( $post ) || ! is_a( $post, 'WP_Post' ) ) {
314
- return array();
315
- }
316
-
317
- return wp_get_post_terms( $post->ID, get_object_taxonomies( $post->post_type ), array( 'fields' => 'ids' ) );
318
- }
319
-
320
- function get_post_categories( $post = null ) {
321
- if ( ! is_array( $post ) ) {
322
- return array();
323
- }
324
-
325
- return wp_get_post_terms( $post['ID'], get_object_taxonomies( $post['post_type'] ), array( 'fields' => 'names' ) );
326
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
327
  }
2
  defined('WYSIJA') or die('Restricted access');
3
  class WYSIJA_help_wp_tools extends WYSIJA_object{
4
 
5
+ function WYSIJA_help_wp_tools(){
6
+
7
+ }
8
+
9
+ /**
10
+ * add wysija's default capabilities to the admin and super admin roles
11
+ */
12
+ function set_default_rolecaps(){
13
+ //add role capabilities
14
+ //get the "administrator" role object
15
+ $rolesadmin=array('administrator','super_admin');
16
+
17
+ foreach($rolesadmin as $roladm){
18
+ $role = get_role($roladm);
19
+ if(!$role) continue;
20
+ //add wysija's capabilities to it so that other widgets can reuse it
21
+ $arr=array('wysija_newsletters','wysija_subscribers','wysija_config','wysija_theme_tab','wysija_style_tab', 'wysija_stats_dashboard');
22
+
23
+ foreach($arr as $arrkey){
24
+ if(!$role->has_cap($arrkey)) $role->add_cap( $arrkey );
25
+ }
26
+ }
27
+ }
28
+
29
+ /**
30
+ * get an array of WordPress roles with a numbered index
31
+ * @global type $wp_roles
32
+ * @return array
33
+ */
34
+ function wp_get_roles() {
35
+ //Careful WordPress global
36
+ global $wp_roles;
37
+ $all_roles = $wp_roles->roles;
38
+ $editable_roles = apply_filters('editable_roles', $all_roles);
39
+
40
+ $rolearray=array();
41
+ $sum=6;
42
+ foreach($editable_roles as $keyrol => $roledetails){
43
+ switch($keyrol){
44
+ case 'super_admin':
45
+ $index=1;
46
+ break;
47
+ case 'administrator':
48
+ $index=2;
49
+ break;
50
+ case 'editor':
51
+ $index=3;
52
+ break;
53
+ case 'author':
54
+ $index=4;
55
+ break;
56
+ case 'contributor':
57
+ $index=5;
58
+ break;
59
+ case 'subscriber':
60
+ $index=6;
61
+ break;
62
+ default:
63
+ $sum++;
64
+ $index=$sum;
65
+ }
66
+ $rolearray[$index]=array('key'=>$keyrol,'name'=>$roledetails['name']);
67
+ }
68
+ ksort($rolearray);
69
+ return $rolearray;
70
+ }
71
+
72
+ /**
73
+ * get an array of WordPress roles with a special capability of that role as index
74
+ * @global type $wp_roles
75
+ * @return array
76
+ */
77
+ function wp_get_editable_roles() {
78
+ //Careful WordPress global
79
+ global $wp_roles;
80
+
81
+ $all_roles = $wp_roles->roles;
82
+ $editable_roles = apply_filters('editable_roles', $all_roles);
83
+
84
+ $possible_values=array();
85
+ foreach ( $all_roles as $role => $details ) {
86
+ $name = translate_user_role($details['name'] );
87
+ switch($role){
88
+ case 'administrator':
89
+ $keyrole='switch_themes';
90
+ break;
91
+ case 'editor':
92
+ $keyrole='moderate_comments';
93
+ break;
94
+ case 'author':
95
+ $keyrole='upload_files';
96
+ break;
97
+ case 'contributor':
98
+ $keyrole='edit_posts';
99
+ break;
100
+ case 'subscriber':
101
+ $keyrole='read';
102
+ break;
103
+ default:
104
+ $keyrole=$role;
105
+ }
106
+ $possible_values[$keyrole]=$name;
107
+ //$possible_values[key($details['capabilities'])]=$name;
108
+ }
109
+
110
+ return $possible_values;
111
+ }
112
+
113
+ /**
114
+ * get roles by name ? Not so sure why use that function
115
+ * @global type $wp_roles
116
+ * @return array
117
+ */
118
+ function wp_get_all_roles() {
119
+ //Careful WordPress global
120
+ global $wp_roles;
121
+ $all_roles = $wp_roles->get_names();
122
+ return $all_roles;
123
+ }
124
+
125
+ /**
126
+ * check whether there is a caching plugin active on this site, we were using that function at some point, it can be useful
127
+ * @global type $cache_enabled
128
+ * @global type $super_cache_enabled
129
+ * @return boolean
130
+ */
131
+ function is_caching_active(){
132
+ $checkPlugins=array(
133
+ 'wp-super-cache/wp-cache.php' ,
134
+ 'w3-total-cache/w3-total-cache.php',
135
+ 'quick-cache/quick-cache.php',
136
+ 'hyper-cache/plugin.php'
137
+ );
138
+
139
+ foreach($checkPlugins as $pluginFileName){
140
+ if(WYSIJA::is_plugin_active($pluginFileName)){
141
+ switch($pluginFileName){
142
+ case 'wp-super-cache/wp-cache.php':
143
+ global $cache_enabled, $super_cache_enabled;
144
+ if(!(WP_CACHE && $cache_enabled && $super_cache_enabled)) continue(2);
145
+ break;
146
+ case 'w3-total-cache/w3-total-cache.php':
147
+ $config = & w3_instance("W3_Config");
148
+ if(!(WP_CACHE && $config->get_boolean("pgcache.enabled"))) continue(2);
149
+
150
+ break;
151
+ case 'quick-cache/quick-cache.php':
152
+ if(!(WP_CACHE && $GLOBALS["WS_PLUGIN__"]["qcache"]["o"]["enabled"])) continue(2);
153
+ break;
154
+ case 'hyper-cache/plugin.php':
155
+ if(!(WP_CACHE)) continue(2);
156
+ break;
157
+ default:
158
+ continue(2);
159
+ }
160
+ return true;
161
+ }
162
+ }
163
+ return false;
164
+ }
165
+
166
+ /**
167
+ * extends the get_permalink of WordPress since at the beginning we had a lot of problems with people who didn't have pretty urls activated etc..
168
+ * @param int $pageid
169
+ * @param array $params pass an array of parameters to the url
170
+ * @param boolean $simple leading to the home not sure in which case we need that again
171
+ * @return string
172
+ */
173
+ function get_permalink($pageid,$params=array(),$simple=false){
174
+ $post = get_post($pageid);
175
+
176
+ $url=get_permalink($post);
177
+
178
+ if(!$url){
179
+ //we need to recreate the subscription page
180
+ $values=array();
181
+ $helperInstall=WYSIJA::get('install','helper');
182
+ $helperInstall->createPage($values);
183
+
184
+ $modelConf=WYSIJA::get('config','model');
185
+ $modelConf->save($values);
186
+ $post = get_post($values['confirm_email_link']);
187
+ $url=get_permalink($post);
188
+ }
189
+
190
+ $paramsquery=parse_url($url);
191
+
192
+ if($params!==false) $params[$post->post_type]=$post->post_name;
193
+ //make a simple url leading to the home
194
+ if($simple){
195
+ $url=site_url();
196
+ // make sure we have a trailing slash at the end
197
+ if($url{strlen($url) - 1} !== '/') $url .= '/';
198
+ }
199
+
200
+ if(isset($paramsquery['query'])){
201
+ $myparams=explode('&',$paramsquery['query']);
202
+ //get the param from the url obtain in permalink and transfer it to our url
203
+ foreach($myparams as $paramvalu){
204
+ $splitkeyval=explode('=',$paramvalu);
205
+ $params[$splitkeyval[0]]=$splitkeyval[1];
206
+ }
207
+ }
208
+
209
+ // make sure we include the port if it's specified
210
+ if(isset($paramsquery['port']) && strlen(trim($paramsquery['port'])) > 0) {
211
+ $port = ':'.(int)$paramsquery['port'];
212
+ } else {
213
+ $port = '';
214
+ }
215
+
216
+ // build url
217
+ $url = sprintf('%s://%s%s%s', $paramsquery['scheme'], $paramsquery['host'], $port, $paramsquery['path']);
218
+
219
+ if($params) {
220
+ if(strpos($url, '?') !== false) $charStart='&';
221
+ else $charStart='?';
222
+ $url.=$charStart;
223
+ $paramsinline=array();
224
+ foreach($params as $k => $v){
225
+ if(is_array($v)) $v = http_build_query(array($k => $v));
226
+ $paramsinline[]=$k.'='.$v;
227
+ }
228
+ $url.=implode('&',$paramsinline);
229
+ }
230
+
231
+ // Transform relative URLs in Absolute URLs (Protect from external URL transforming plugins)
232
+ $parsed_url = parse_url($url);
233
+ if (empty($parsed_url['scheme'])) {
234
+ $url = get_bloginfo('url') . $url;
235
+ }
236
+
237
+ return $url;
238
+ }
239
+
240
+ /**
241
+ * return a list of post types
242
+ * @return mixed
243
+ */
244
+ function get_post_types($return_type = 'objects') {
245
+ $args=array(
246
+ 'public' => true,
247
+ '_builtin' => false,
248
+ 'show_in_menu'=>true,
249
+ 'show_ui'=>true,
250
+ );
251
+ return get_post_types($args, $return_type);
252
+ }
253
+
254
+ /**
255
+ * return a list of post types
256
+ * @return mixed
257
+ */
258
+ function get_post_statuses(){
259
+ return array_merge(get_post_statuses(), array('future'=>__('Scheduled',WYSIJA)));
260
+ }
261
+
262
+ /**
263
+ * get a multidimensionnal array that returns the categories per CPT
264
+ */
265
+ function get_categories($custom_post_type = null) {
266
+ if($custom_post_type === null) {
267
+ $post_types = array_merge(array('post', 'page'), array_keys($this->get_post_types('names')));
268
+ } else {
269
+ $post_types = array($post_type);
270
+ }
271
+
272
+ $cpt_categories = array();
273
+ $cpt_taxonomies = array();
274
+
275
+ foreach($post_types as $post_type) {
276
+ // get taxonomies for each post type
277
+ if($post_type === 'post') {
278
+ $cpt_taxonomies = array('category');
279
+ } else {
280
+ $cpt_taxonomies = get_object_taxonomies($post_type);
281
+ }
282
+
283
+ if(!empty($cpt_taxonomies)) {
284
+ foreach($cpt_taxonomies as $taxonomy) {
285
+
286
+ $post_type_categories = array();
287
+ $args = array(
288
+ 'orderby' => 'name',
289
+ 'show_count' => 0,
290
+ 'pad_counts' => 0,
291
+ 'hierarchical' => 1,
292
+ 'taxonomy' => $taxonomy,
293
+ 'title_li' => '',
294
+ 'hide_empty' => 0
295
+ );
296
+
297
+ $post_type_categories = get_categories($args);
298
+
299
+ if(!empty($post_type_categories)) {
300
+ foreach($post_type_categories as $post_type_category) {
301
+ $cpt_categories[$post_type][$post_type_category->cat_ID] = array('id' => $post_type_category->cat_ID, 'name' => $post_type_category->name);
302
+ }
303
+ }
304
+ }
305
+ $cpt_categories[$post_type] = array_values($cpt_categories[$post_type]);
306
+ }
307
+ }
308
+
309
+ if($custom_post_type === null) {
310
+ return $cpt_categories;
311
+ } else {
312
+ return $cpt_categories[$post_type];
313
+ }
314
+ }
315
+
316
+ function get_post_category_ids($post = null) {
317
+
318
+ $cpt_categories = array();
319
+ $cpt_taxonomies = array();
320
+
321
+ // get taxonomies for each post type
322
+ $post_type = 'post';
323
+ $cpt_taxonomies = get_object_taxonomies($post->post_type);
324
+
325
+ if(!empty($cpt_taxonomies)) {
326
+ foreach($cpt_taxonomies as $taxonomy) {
327
+ $post_type_categories = wp_get_post_terms($post->ID, $taxonomy);
328
+
329
+ if(!empty($post_type_categories)) {
330
+ foreach($post_type_categories as $post_type_category) {
331
+ $cpt_categories[] = $post_type_category->term_id;
332
+ }
333
+ }
334
+ }
335
+ $cpt_categories = array_unique($cpt_categories);
336
+ }
337
+
338
+ return $cpt_categories;
339
+ }
340
  }
img/controls/image-placeholder.png DELETED
Binary file
img/select2/select2-spinner.gif DELETED
Binary file
img/select2/select2.png DELETED
Binary file
img/select2/select2x2.png DELETED
Binary file
index.php CHANGED
@@ -3,8 +3,8 @@
3
  Plugin Name: MailPoet Newsletters
4
  Plugin URI: http://www.mailpoet.com/
5
  Description: Create and send newsletters. Import and manage your lists. Add subscription forms in widgets, articles and pages. MailPoet (formerly Wysija) is a freemium plugin updated regularly with new features.
6
- Version: 2.6.8
7
- Author: MailPoet
8
  Author URI: http://www.mailpoet.com/
9
  License: GPLv2 or later
10
  Text Domain: wysija-newsletters
@@ -28,4 +28,4 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
  /*require vital parts*/
30
 
31
- require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR.'base.php');
3
  Plugin Name: MailPoet Newsletters
4
  Plugin URI: http://www.mailpoet.com/
5
  Description: Create and send newsletters. Import and manage your lists. Add subscription forms in widgets, articles and pages. MailPoet (formerly Wysija) is a freemium plugin updated regularly with new features.
6
+ Version: 2.6
7
+ Author: Wysija
8
  Author URI: http://www.mailpoet.com/
9
  License: GPLv2 or later
10
  Text Domain: wysija-newsletters
28
  */
29
  /*require vital parts*/
30
 
31
+ require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR.'base.php');
js/admin-campaigns-articles.js CHANGED
@@ -1 +1 @@
1
- var query_offset=0,wysappend=0,totalReached=!1,searchRunning=!1,slider=null,colorpicker=null;jQuery(function(e){function t(){e(".submit-box").addClass("counting");var t=parseInt(e(".search_results .checkbox:checked").length,10);0===t?a():c(t+" "+wysijatrans.post_selected)}function a(){e(".submit-box").removeClass("counting"),r()}function i(){e(".post_category").attr("disabled","disabled").hide();var t=e("#post_type").val();e("#post_category_"+t).length>0&&e("#post_category_"+t).removeAttr("disabled").show()}function n(){return query_offset=0,wysappend=0,l(),!1}function s(){if(null===slider){var t=32,a=564,i=Math.min(Math.max(t,parseInt(e("#slider_info span").html())),a);slider=new Control.Slider("slider_handle","image_width_slider",{range:$R(t,a),slideValue:i,axis:"horizontal",onSlide:function(t){var a=parseInt(t,10);e("#slider_info").find("span").html(a),e("#image_width").val(a)},onChange:function(t){var a=parseInt(t,10);e("#slider_info").find("span").html(a),e("#image_width").val(a)}}),slider.setValue(i)}}function l(){var t="";wysappend||e("#results").html(t),wysijaAJAX.task="get_articles",wysijaAJAX.data=e("#articles-form").serializeArray(),wysijaAJAX.query_offset=query_offset,o(wysijatrans.loading_results),wysijaAJAX._wpnonce=e("#wysijax").val(),jQuery.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:f,error:m,dataType:"json"})}function o(t){a(),e(".submit-box").addClass("loading"),c(t)}function c(t){void 0!==t&&e("#loading-message").html(t)}function r(){e("#loading-message").html("")}function d(){e(".submit-box").removeClass("loading"),r(),t()}function u(){e("#title_position_block")["title"===e('input[name="post_content"]:checked').val()?"hide":"show"](),e("#title_tag_list")["title"===e('input[name="post_content"]:checked').val()?"show":"hide"](),e("#advanced:visible").length>0&&(e("#title_tag_list:hidden").length>0&&"list"===e('input[name="title_tag"]:checked').val()&&e('input[name="title_tag"][value="h2"]').attr("checked","checked"),"list"===e('input[name="title_tag"]:checked').val()?h(["image","author","category","readmore","divider","bgcolor"]):p(["image","author","category","readmore","divider","bgcolor"]))}function h(t){e.each(t,function(t,a){e("#"+a+"-block").hide()})}function p(t){e.each(t,function(t,a){e("#"+a+"-block").show()})}function _(){null===colorpicker&&(colorpicker=!0,e("input.color").modcoder_excolor({hue_bar:1,border_color:"#969696",anim_speed:"fast",round_corners:!1,shadow_size:2,shadow_color:"#f0f0f0",background_color:"#ececec",backlight:!1,label_color:"#333333",effect:"fade",show_input:!1,z_index:2e4,callback_on_open:function(){e("html, body").animate({scrollTop:e("#modcoder_colorpicker_wrapper:visible").offset().top},200)}}))}function g(){e("#image_block")[e('input[name="title_tag"][value="list"]:checked').length>0?"hide":"show"]()}function w(){var t=e('input[name="image_alignment"]:checked').val(),a=!0,i=32,n=325;"center"===t?n=564:"none"===t&&(a=!1),a===!0?(e("#image_width_block").show(),s(),slider.range=$R(i,n),slider.setValue(slider.value)):e("#image_width_block").hide()}function f(t){var a="",i=null;t.result.result?(a='<ul class="search_results">',e.each(t.result.posts,function(e,t){i={src:null,alt:"",title:""},null!==t.post_image&&(i.src=t.post_image.src,i.alt=t.post_image.alt,i.title=t.post_title);var n=query_offset+e;a+='<li id="post-'+n+'" class="clearfix">',a+='<div class="checkbox_container">',a+='<input id="post-checkbox-'+n+'" data-post-id="'+n+'" type="checkbox" class="checkbox" value="'+t.ID+'" name="post_selection" />',a+="</div>",null!==i.src?(a+='<div class="thumbnail"><img width="60" title="'+i.title+'" src="'+i.src+'" alt="'+i.alt+'" /></div>',a+='<label class="with_thumbnail" for="post-checkbox-'+n+'">'+t.post_title+"</label>"):a+='<label for="post-checkbox-'+n+'">'+t.post_title+"</label>",a+='<span class="cpt-type">'+t.post_type+" - <small>"+t.post_status+"</small></span>",a+="</li>"}),a+="</ul>"):a=t.result.append?"":'<p class="message"><strong>'+t.result.msg+"</strong></p>",t.result.append?""!==a&&e("#results").append("<hr />"+a):e("#results").html(a),wysappend=0,searchRunning=!1,totalReached=parseInt(t.result.total)===e("ul.search_results li").length?!0:!1,d()}function m(){searchRunning=!1,wysappend=0}function y(){0!==e("#advanced:hidden").length&&searchRunning!==!0&&(searchRunning=!0,query_offset+=10,wysappend=1,l())}e("#toggle-advanced").toggle(function(){return e(this).html(wysijatrans.hide_advanced),e("#advanced").show(),e("#basic").hide(),s(),u(),w(),g(),_(),e(this).blur(),!1},function(){return e(this).html(wysijatrans.show_advanced),e("#basic").show(),e("#advanced").hide(),e(this).blur(),!1}),e("#back-selection").click(function(){return e("#toggle-advanced").trigger("click"),!1}),e("#insert-selection").click(function(){var t=[],a=e('#results input[name="post_selection"]:checked'),i=[],n=["readmore","author_label","category_label"];return 0===a.length?!1:(e.each(a,function(a,i){t.push(e(i).val())}),e("#articles-form").serializeArray().each(function(e){n.include(e.name)&&(e.value=window.parent.Wysija.encodeHtmlValue(e.value)),i.push(e)}),wysijaAJAX.task="insert_articles",wysijaAJAX.post_ids=t.join(","),wysijaAJAX.data=i,wysijaAJAX._wpnonce=e("#wysijax").val(),wysijaAJAX.divider={src:window.parent.$$('.wysija_item[wysija_type="divider"]')[0].readAttribute("wysija_src"),width:window.parent.$$('.wysija_item[wysija_type="divider"]')[0].readAttribute("wysija_width"),height:window.parent.$$('.wysija_item[wysija_type="divider"]')[0].readAttribute("wysija_height")},o(wysijatrans.inserting_selection),jQuery.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:function(e){window.parent.WysijaPopup.success(e.result.posts),d()},error:m,dataType:"json"}),!1)}),e(document).on("click",".search_results .checkbox",function(){e(this).is(":checked")===!0?e("#post-"+e(this).data("post-id")).addClass("selected"):e("#post-"+e(this).data("post-id")).removeClass("selected"),t()}),e(document).on("change","#post_type",function(){i(),n()}),e(".post_category").change(function(){n()}),e("#post_status").change(function(){n()}),e(document).on("click","#search-submit",function(){return l(),!1}),e('input[name="image_alignment"]').click(function(){w()}),e('input[name="post_content"]').click(function(){u(),g(),w()}),e('input[name="title_tag"]').click(function(){u(),g(),w()}),e(function(){i(),l()}),e(window).scroll(function(){totalReached===!1&&e("#results li").length>=10&&!wysappend&&e(window).scrollTop()===e(document).height()-e(window).height()&&y()})});
1
+ var query_offset=0,wysappend=0,totalReached=!1,searchRunning=!1,slider=null,colorpicker=null;jQuery(function(e){function t(){e(".submit-box").addClass("counting");var t=parseInt(e(".search_results .checkbox:checked").length,10);0===t?a():c(t+" "+wysijatrans.post_selected)}function a(){e(".submit-box").removeClass("counting"),r()}function i(){s(),e(".post_category").hide(),e(".post_category").attr("disabled","disabled"),e("#post_category_"+e("#post_type").val()).fadeIn();var t="#post_category_"+e("#post_type").val();e(t).show(),e(t).removeAttr("disabled")}function s(){return query_offset=0,wysappend=0,l(),!1}function n(){if(null===slider){var t=32,a=564,i=Math.min(Math.max(t,parseInt(e("#slider_info span").html())),a);slider=new Control.Slider("slider_handle","image_width_slider",{range:$R(t,a),slideValue:i,axis:"horizontal",onSlide:function(t){var a=parseInt(t,10);e("#slider_info").find("span").html(a),e("#image_width").val(a)},onChange:function(t){var a=parseInt(t,10);e("#slider_info").find("span").html(a),e("#image_width").val(a)}}),slider.setValue(i)}}function l(){var t="";wysappend||e("#results").html(t),wysijaAJAX.task="get_articles",wysijaAJAX.data=e("#articles-form").serializeArray(),wysijaAJAX.query_offset=query_offset,o(wysijatrans.loading_results),wysijaAJAX._wpnonce=e("#wysijax").val(),jQuery.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:f,error:m,dataType:"json"})}function o(t){a(),e(".submit-box").addClass("loading"),c(t)}function c(t){void 0!==t&&e("#loading-message").html(t)}function r(){e("#loading-message").html("")}function d(){e(".submit-box").removeClass("loading"),r(),t()}function u(){e("#title_position_block")["title"===e('input[name="post_content"]:checked').val()?"hide":"show"](),e("#title_tag_list")["title"===e('input[name="post_content"]:checked').val()?"show":"hide"](),e("#advanced:visible").length>0&&(e("#title_tag_list:hidden").length>0&&"list"===e('input[name="title_tag"]:checked').val()&&e('input[name="title_tag"][value="h2"]').attr("checked","checked"),"list"===e('input[name="title_tag"]:checked').val()?h(["image","author","category","readmore","divider","bgcolor"]):p(["image","author","category","readmore","divider","bgcolor"]))}function h(t){e.each(t,function(t,a){e("#"+a+"-block").hide()})}function p(t){e.each(t,function(t,a){e("#"+a+"-block").show()})}function _(){null===colorpicker&&(colorpicker=!0,e("input.color").modcoder_excolor({hue_bar:1,border_color:"#969696",anim_speed:"fast",round_corners:!1,shadow_size:2,shadow_color:"#f0f0f0",background_color:"#ececec",backlight:!1,label_color:"#333333",effect:"fade",show_input:!1,z_index:2e4,callback_on_open:function(){e("html, body").animate({scrollTop:e("#modcoder_colorpicker_wrapper:visible").offset().top},200)}}))}function g(){e("#image_block")[e('input[name="title_tag"][value="list"]:checked').length>0?"hide":"show"]()}function w(){var t=e('input[name="image_alignment"]:checked').val(),a=!0,i=32,s=325;"center"===t?s=564:"none"===t&&(a=!1),a===!0?(e("#image_width_block").show(),n(),slider.range=$R(i,s),slider.setValue(slider.value)):e("#image_width_block").hide()}function f(t){var a="",i=null;t.result.result?(a='<ul class="search_results">',e.each(t.result.posts,function(e,t){i={src:null,alt:"",title:""},null!==t.post_image&&(i.src=t.post_image.src,i.alt=t.post_image.alt,i.title=t.post_title);var s=query_offset+e;a+='<li id="post-'+s+'" class="clearfix">',a+='<div class="checkbox_container">',a+='<input id="post-checkbox-'+s+'" data-post-id="'+s+'" type="checkbox" class="checkbox" value="'+t.ID+'" name="post_selection" />',a+="</div>",null!==i.src?(a+='<div class="thumbnail"><img width="60" title="'+i.title+'" src="'+i.src+'" alt="'+i.alt+'" /></div>',a+='<label class="with_thumbnail" for="post-checkbox-'+s+'">'+t.post_title+"</label>"):a+='<label for="post-checkbox-'+s+'">'+t.post_title+"</label>",a+='<span class="cpt-type">'+t.post_type+" - <small>"+t.post_status+"</small></span>",a+="</li>"}),a+="</ul>"):a=t.result.append?"":'<p class="message"><strong>'+t.result.msg+"</strong></p>",t.result.append?""!==a&&e("#results").append("<hr />"+a):e("#results").html(a),wysappend=0,searchRunning=!1,totalReached=parseInt(t.result.total)===e("ul.search_results li").length?!0:!1,d()}function m(){searchRunning=!1,wysappend=0}function y(){0!==e("#advanced:hidden").length&&searchRunning!==!0&&(searchRunning=!0,query_offset+=10,wysappend=1,l())}i(),e("#toggle-advanced").toggle(function(){return e(this).html(wysijatrans.hide_advanced),e("#advanced").show(),e("#basic").hide(),n(),u(),w(),g(),_(),e(this).blur(),!1},function(){return e(this).html(wysijatrans.show_advanced),e("#basic").show(),e("#advanced").hide(),e(this).blur(),!1}),e("#back-selection").click(function(){return e("#toggle-advanced").trigger("click"),!1}),e("#insert-selection").click(function(){var t=[],a=e('#results input[name="post_selection"]:checked'),i=[],s=["readmore","author_label","category_label"];return 0===a.length?!1:(e.each(a,function(a,i){t.push(e(i).val())}),e("#articles-form").serializeArray().each(function(e){s.include(e.name)&&(e.value=window.parent.Wysija.encodeHtmlValue(e.value)),i.push(e)}),wysijaAJAX.task="insert_articles",wysijaAJAX.post_ids=t.join(","),wysijaAJAX.data=i,wysijaAJAX._wpnonce=e("#wysijax").val(),wysijaAJAX.divider={src:window.parent.$$('.wysija_item[wysija_type="divider"]')[0].readAttribute("wysija_src"),width:window.parent.$$('.wysija_item[wysija_type="divider"]')[0].readAttribute("wysija_width"),height:window.parent.$$('.wysija_item[wysija_type="divider"]')[0].readAttribute("wysija_height")},o(wysijatrans.inserting_selection),jQuery.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:function(e){window.parent.WysijaPopup.success(e.result.posts),d()},error:m,dataType:"json"}),!1)}),e(document).on("click",".search_results .checkbox",function(){e(this).is(":checked")===!0?e("#post-"+e(this).data("post-id")).addClass("selected"):e("#post-"+e(this).data("post-id")).removeClass("selected"),t()}),e("#post_type").change(i),e(".post_category").change(function(){s()}),e("#post_status").change(function(){s()}),e(document).on("click","#search-submit",function(){return l(),!1}),e('input[name="image_alignment"]').click(function(){w()}),e('input[name="post_content"]').click(function(){u(),g(),w()}),e('input[name="title_tag"]').click(function(){u(),g(),w()}),e(function(){l()}),e(window).scroll(function(){totalReached===!1&&e("#results li").length>=10&&!wysappend&&e(window).scrollTop()===e(document).height()-e(window).height()&&y()})});
js/admin-campaigns-autopost.js CHANGED
@@ -1 +1 @@
1
- var colorpicker=null;jQuery(function(e){function t(){e("#title_position_block")["title"===e('input[name="post_content"]:checked').val()?"hide":"show"](),e("#title_tag_list")["title"===e('input[name="post_content"]:checked').val()?"show":"hide"](),e("#advanced:visible").length>0&&(e("#title_tag_list:hidden").length>0&&"list"===e('input[name="title_tag"]:checked').val()&&e('input[name="title_tag"][value="h2"]').attr("checked","checked"),"list"===e('input[name="title_tag"]:checked').val()?a(["image","author","category","readmore","divider","bgcolor"]):i(["image","author","category","readmore","divider","bgcolor"]))}function a(t){e.each(t,function(t,a){e("#"+a+"-block").hide()})}function i(t){e.each(t,function(t,a){e("#"+a+"-block").show()})}function n(){e("#image_block")[e('input[name="title_tag"][value="list"]:checked').length>0?"hide":"show"]()}function o(t){t===!0&&e(".category_ids").val("").trigger("change");var a=e("#post_type").val();e(".category_ids").select2({width:"400px",multiple:!0,data:{results:[]},initSelection:function(e,t){t(e.data("selected"))},allowClear:!0,ajax:{url:ajaxurl,data:function(e,t){return{action:"wysija_ajax",controller:"campaigns",task:"search_terms",search:e,page_limit:10,page:t,post_type:a}},results:function(t){var a=t.result;return e.each(a.results,function(e,t){t.text=_.template("<%= tax %>: <%= term %>")({tax:a.taxonomies[t.taxonomy].labels.singular_name,term:t.name}),t.id=t.term_id}),a}}}).trigger("change").on({change:function(t){var a=e(this).data("selected");t.added?a.push(t.added):a=_.without(a,t.removed),e(this).data("selected",a).attr("data-selected",JSON.stringify(a))}})}function l(){var t=e('input[name="image_alignment"]:checked').val(),a=!0,i=32,n=325;"center"===t?n=564:"none"===t&&(a=!1),a===!0?(e("#image_width_block").show(),c(),slider.range=$R(i,n),slider.setValue(slider.value)):e("#image_width_block").hide()}function c(){var t=32,a=564,i=Math.min(Math.max(t,parseInt(e("#slider_info span").html())),a);slider=new Control.Slider("slider_handle","image_width_slider",{range:$R(t,a),slideValue:i,axis:"horizontal",onSlide:function(t){var a=parseInt(t,10);e("#slider_info").find("span").html(a),e("#image_width").val(a)},onChange:function(t){var a=parseInt(t,10);e("#slider_info").find("span").html(a),e("#image_width").val(a)}}),slider.setValue(i)}function r(){null===colorpicker&&(colorpicker=!0,e("input.color").modcoder_excolor({hue_bar:1,border_color:"#969696",anim_speed:"fast",round_corners:!1,shadow_size:2,shadow_color:"#f0f0f0",background_color:"#ececec",backlight:!1,label_color:"#333333",effect:"fade",show_input:!1,z_index:2e4,callback_on_open:function(){e("html, body").animate({scrollTop:e("#modcoder_colorpicker_wrapper:visible").offset().top},200)}}))}e("#toggle-advanced").toggle(function(){return e(this).html(wysijatrans.hide_advanced),e("#advanced").show(),c(),t(),l(),n(),r(),e(this).blur(),window.parent.WysijaPopup.setDimensions(),!1},function(){return e(this).html(wysijatrans.show_advanced),e("#advanced").hide(),e(this).blur(),window.parent.WysijaPopup.setDimensions(),!1}),e("#autopost-submit").click(function(){var t=[],a=["readmore","author_label","category_label"];return e("#autopost-form").serializeArray().each(function(e){a.include(e.name)&&(e.value=window.parent.Wysija.encodeHtmlValue(e.value)),t.push(e)}),wysijaAJAX.task="generate_auto_post",wysijaAJAX.wysijaData=t,jQuery.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:function(e){void 0!==e.result&&""!==e.result?window.parent.WysijaPopup.success(e.result):window.parent.WysijaPopup.cancel()}}),!1}),e('input[name="image_alignment"]').click(function(){l()}),e('input[name="post_content"]').click(function(){t(),n(),l()}),e('input[name="title_tag"]').click(function(){t(),n(),l()}),e("#post_type").change(function(){return o(!0),!1}),e(function(){c(),t(),l(),n(),o()})});
1
+ var colorpicker=null;jQuery(function(e){function t(){e("#title_position_block")["title"===e('input[name="post_content"]:checked').val()?"hide":"show"](),e("#title_tag_list")["title"===e('input[name="post_content"]:checked').val()?"show":"hide"](),e("#advanced:visible").length>0&&(e("#title_tag_list:hidden").length>0&&"list"===e('input[name="title_tag"]:checked').val()&&e('input[name="title_tag"][value="h2"]').attr("checked","checked"),"list"===e('input[name="title_tag"]:checked').val()?i(["image","author","category","readmore","divider","bgcolor"]):a(["image","author","category","readmore","divider","bgcolor"]))}function i(t){e.each(t,function(t,i){e("#"+i+"-block").hide()})}function a(t){e.each(t,function(t,i){e("#"+i+"-block").show()})}function n(){e("#image_block")[e('input[name="title_tag"][value="list"]:checked').length>0?"hide":"show"]()}function o(t){e(".category_select").hide(),t===!0&&e(".category_ids").prop("selectedIndex",-1).trigger("chosen:updated");var i=e("#post_type").val();e('.category_select[data-post-type="'+i+'"]').length>0?(e('.category_select[data-post-type="'+i+'"]').show(),e("#categories_filters").show()):e("#categories_filters").hide()}function c(){var t=e('input[name="image_alignment"]:checked').val(),i=!0,a=32,n=325;"center"===t?n=564:"none"===t&&(i=!1),i===!0?(e("#image_width_block").show(),l(),slider.range=$R(a,n),slider.setValue(slider.value)):e("#image_width_block").hide()}function l(){var t=32,i=564,a=Math.min(Math.max(t,parseInt(e("#slider_info span").html())),i);slider=new Control.Slider("slider_handle","image_width_slider",{range:$R(t,i),slideValue:a,axis:"horizontal",onSlide:function(t){var i=parseInt(t,10);e("#slider_info").find("span").html(i),e("#image_width").val(i)},onChange:function(t){var i=parseInt(t,10);e("#slider_info").find("span").html(i),e("#image_width").val(i)}}),slider.setValue(a)}function r(){null===colorpicker&&(colorpicker=!0,e("input.color").modcoder_excolor({hue_bar:1,border_color:"#969696",anim_speed:"fast",round_corners:!1,shadow_size:2,shadow_color:"#f0f0f0",background_color:"#ececec",backlight:!1,label_color:"#333333",effect:"fade",show_input:!1,z_index:2e4,callback_on_open:function(){e("html, body").animate({scrollTop:e("#modcoder_colorpicker_wrapper:visible").offset().top},200)}}))}e("#toggle-advanced").toggle(function(){return e(this).html(wysijatrans.hide_advanced),e("#advanced").show(),l(),t(),c(),n(),r(),e(this).blur(),window.parent.WysijaPopup.setDimensions(),!1},function(){return e(this).html(wysijatrans.show_advanced),e("#advanced").hide(),e(this).blur(),window.parent.WysijaPopup.setDimensions(),!1}),e("#autopost-submit").click(function(){var t=[],i=["readmore","author_label","category_label"];return e("#autopost-form").serializeArray().each(function(e){i.include(e.name)&&(e.value=window.parent.Wysija.encodeHtmlValue(e.value)),t.push(e)}),wysijaAJAX.task="generate_auto_post",wysijaAJAX.wysijaData=t,jQuery.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:function(e){void 0!==e.result&&""!==e.result?window.parent.WysijaPopup.success(e.result):window.parent.WysijaPopup.cancel()}}),!1}),e('input[name="image_alignment"]').click(function(){c()}),e('input[name="post_content"]').click(function(){t(),n(),c()}),e('input[name="title_tag"]').click(function(){t(),n(),c()}),e("#post_type").change(function(){return o(!0),!1}),e(function(){e(".category_ids").chosen({width:"400px"}),l(),t(),c(),n(),o()})});
js/admin-campaigns-editDetails.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(e){function t(){wysijaAJAX.popTitle=wysijatrans.previewemail,wysijaAJAX.dataType="json",wysijaAJAX.task="send_preview",jQuery("#campaignstep3").length>0&&(wysijaAJAX.data=jQuery("#campaignstep3").serializeArray(),wysijaAJAX.id=jQuery("#email_id").val()),wysijaAJAX.receiver=jQuery("#preview-receiver").val(),jQuery.WYSIJA_SEND()}function i(){return"function"==typeof saveWYSIJA?saveWYSIJA(function(){t()}):t(),!1}function a(){var t={};return e(".checkbox.checklists").each(function(){e(this).attr("checked")&&(t[e(this).attr("id")]={total:parseInt(e("#"+e(this).attr("id")+"count").val()),title:e(this).attr("alt")})}),t}function s(){var t=a(),i=0,s="";for(var r in t)i+=parseInt(t[r].total),s+=t[r].title+", ";if(s=s.substr(0,s.length-2),void 0!=wysijatrans.alertsend&&!e("#scheduleit").attr("checked")){var n=wysijatrans.alertsend;return n=n.replace("[#]",i),n=n.replace("[#nms]",s),confirm(n)?!0:!1}return void 0!=wysijatrans.ignoreprevious&&e("#ignore_subscribers").attr("checked")?confirm(wysijatrans.ignoreprevious)?!0:!1:!0}function r(){return e("#wysija-send-spamtest").hasClass("disabled")?!1:(WysijaPopup.showLoading(),WysijaPopup.showOverlay(),saveWYSIJA(function(){n()}),void 0)}function n(){wysijaAJAX.popTitle=wysijatrans.previewemail,wysijaAJAX.dataType="json",wysijaAJAX.task="send_spamtest",e.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:function(t){if(WysijaPopup.hideLoading(),t.result.result){e("#wysija-spam-results").attr("href",t.result.urlredirect).fadeIn("slow");var i=parseInt(e("#counttriesleft").html())-1;e("#counttriesleft").html(i),0>=i&&e("#wysija-send-spamtest").addClass("disabled"),WysijaPopup.hideOverlay()}else t.result.notriesleft&&alert(t.result.notriesleft),WysijaPopup.hideOverlay()},error:function(e){alert("Request error not JSON:"+e.responseText),delete wysijaAJAXcallback.onSuccess},dataType:wysijaAJAX.dataType})}e(".action-send-spam-test").click(function(){return tb_show(wysijatrans.processqueue,e(this).attr("href")+"&KeepThis=true&TB_iframe=true&height=618&width=1000",null),tb_showIframe(),!1}),e("#wj-send-preview").click(i),e("#submit-send").click(s),e(document).ready(function(){function t(t){e("#scheduleit").attr("checked")?(e(".schedule-row").show(),e("#submit-send").val(wysijatrans.schedule)):(e(".schedule-row").hide(),e("#submit-send").val(t))}if("function"!=typeof saveWYSIJA){e("#datepicker-day").datepicker({minDate:0,showOn:"focus",dateFormat:"yy-mm-dd"});var i=e("#submit-send").val();t(i),e("#scheduleit").change(function(){t(i)})}}),e("#wysija-send-spamtest").click(r),e("#link-back-step2").click(function(){return e("#hid-redir").attr("value","savelastback"),e("#campaignstep3").submit(),!1})}),window.mailpoet="object"==typeof window.mailpoet?window.mailpoet:{$:{}},function(e,t){"use strict";var i=t.mailpoet,a=i.fn={};a.isGoodFromAddress=function(e){var i=e.split("@")[1];return"undefined"==typeof i||""===i?!1:i.toLowerCase()!==t.location.host.toLowerCase()?!1:!0},a.isGmailAddress=function(e){var t=e.split("@")[1];return"undefined"==typeof t||""===t?!1:"gmail.com"!==t.toLowerCase()?!1:!0}}(jQuery,window),function(e,t){"use strict";var i=t.mailpoet;e(t).load(function(){"object"==typeof e.fn.tooltip&&(i.$.from_email=e("#from_email"),i.$.from_email.tooltip({animation:!0,placement:"bottom",trigger:"manual",html:!0,title:function(){return i.$.from_email.data("message")}}).on({"verifyEmail.mailpoet":function(){if(i.fn.isGoodFromAddress(i.$.from_email.val()))return i.$.from_email.data("message","").tooltip("hide");if("true"===wysijatrans.emailCheck.isGmail)return i.$.from_email.data("message","").tooltip("hide");var e="";return e=i.fn.isGmailAddress(i.$.from_email.val())?wysijatrans.emailCheck.gmailText:wysijatrans.emailCheck.text,i.$.from_email.is(":visible")?i.$.from_email.data("message",e).tooltip("show"):i.$.from_email.tooltip("hide")},keyup:function(){i.$.from_email.trigger("verifyEmail.mailpoet")}}).trigger("verifyEmail.mailpoet"))})}(jQuery,window);
1
+ jQuery(function(e){function t(){wysijaAJAX.popTitle=wysijatrans.previewemail,wysijaAJAX.dataType="json",wysijaAJAX.task="send_preview",jQuery("#campaignstep3").length>0&&(wysijaAJAX.data=jQuery("#campaignstep3").serializeArray(),wysijaAJAX.id=jQuery("#email_id").val()),wysijaAJAX.receiver=jQuery("#preview-receiver").val(),jQuery.WYSIJA_SEND()}function a(){return"function"==typeof saveWYSIJA?saveWYSIJA(function(){t()}):t(),!1}function i(){var t={};return e(".checkbox.checklists").each(function(){e(this).attr("checked")&&(t[e(this).attr("id")]={total:parseInt(e("#"+e(this).attr("id")+"count").val()),title:e(this).attr("alt")})}),t}function s(){var t=i(),a=0,s="";for(var r in t)a+=parseInt(t[r].total),s+=t[r].title+", ";if(s=s.substr(0,s.length-2),void 0!=wysijatrans.alertsend&&!e("#scheduleit").attr("checked")){var n=wysijatrans.alertsend;return n=n.replace("[#]",a),n=n.replace("[#nms]",s),confirm(n)?!0:!1}return void 0!=wysijatrans.ignoreprevious&&e("#ignore_subscribers").attr("checked")?confirm(wysijatrans.ignoreprevious)?!0:!1:!0}function r(){return e("#wysija-send-spamtest").hasClass("disabled")?!1:(WysijaPopup.showLoading(),WysijaPopup.showOverlay(),saveWYSIJA(function(){n()}),void 0)}function n(){wysijaAJAX.popTitle=wysijatrans.previewemail,wysijaAJAX.dataType="json",wysijaAJAX.task="send_spamtest",e.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:function(t){if(WysijaPopup.hideLoading(),t.result.result){e("#wysija-spam-results").attr("href",t.result.urlredirect).fadeIn("slow");var a=parseInt(e("#counttriesleft").html())-1;e("#counttriesleft").html(a),0>=a&&e("#wysija-send-spamtest").addClass("disabled"),WysijaPopup.hideOverlay()}else t.result.notriesleft&&alert(t.result.notriesleft),WysijaPopup.hideOverlay()},error:function(e){alert("Request error not JSON:"+e.responseText),delete wysijaAJAXcallback.onSuccess},dataType:wysijaAJAX.dataType})}function o(){var t=e("#from_email");t.qtip({content:wysijatrans.emailCheck.text,position:{my:"top center",at:"bottom center"},target:t,show:{ready:!0,event:"keyup"},hide:"keyup",events:{show:function(e,a){var i=t.val().toLowerCase().split("@")[1];"true"===wysijatrans.emailCheck.isGmail&&e.preventDefault(),"gmail.com"===i&&a.elements.content.html(wysijatrans.emailCheck.gmailText),i===wysijatrans.emailCheck.domain&&e.preventDefault()},hide:function(a){e("#from_email:visible").length>0&&t.val().toLowerCase().split("@")[1]!==wysijatrans.emailCheck.domain&&a.preventDefault()}}})}e(".action-send-spam-test").click(function(){return tb_show(wysijatrans.processqueue,e(this).attr("href")+"&KeepThis=true&TB_iframe=true&height=618&width=1000",null),tb_showIframe(),!1}),e("#wj-send-preview").click(a),e("#submit-send").click(s),e(document).ready(function(){function t(t){e("#scheduleit").attr("checked")?(e(".schedule-row").show(),e("