Compare commits

...

698 Commits

Author SHA1 Message Date
5293589eea Release 3.0.0-beta.35.0.0 2017-06-13 17:05:50 +03:00
07f4c0bc1e Merge pull request #923 from mailpoet/fast_svn_publish
Use a faster SVN workflow in release publishing automation [MAILPOET-913]
2017-06-13 07:50:47 -04:00
7d9a072545 Merge pull request #928 from mailpoet/wp_mail_switch
Replaces SwiftMailer's mail() method with WP's PHPMailer [MAILPOET-926]
2017-06-13 14:10:07 +03:00
67ffcb5485 Clean up the SVN dir before checking out for faster operation [MAILPOET-913] 2017-06-13 12:22:32 +03:00
02098a3cf0 Merge pull request #888 from mailpoet/mp2tomp3migration
MP2 to MP3 migration [MAILPOET-946]
2017-06-12 19:41:46 +03:00
eab8065154 Remove the promise of migrating newsletters and statistics.
We will not be offering these options!
2017-06-12 17:36:04 +03:00
fb8ecef1c3 Merge pull request #932 from mailpoet/revert-931-minimum_php_version_fix
Revert "Updates minimum required "release version" from 3 to 30 [MAILPOET-944]"
2017-06-12 10:27:09 -04:00
14955e5022 Revert "Updates minimum required "release version" from 3 to 30"
This reverts commit e83c0ff0bd.
2017-06-12 10:20:01 -04:00
e83c0ff0bd Updates minimum required "release version" from 3 to 30 2017-06-12 14:52:44 +01:00
09db1aac22 Merge pull request #929 from mailpoet/mp_api_fix
Fixes confirmation emails not sent when adding subscriber in MP API [MAILPOET-942]
2017-06-12 14:22:05 +03:00
5fa1eb643a Remove tests that may fail because of the original database content 2017-06-12 13:13:17 +02:00
898913a517 Change: the users belonging to the wp_users segment must be imported as subscribed to the wp_users segment 2017-06-12 13:13:17 +02:00
3a4b364bcd Modify unit tests following previous changes 2017-06-12 13:13:16 +02:00
d373d10f6c Fixed: Segments with a null description were not imported 2017-06-12 13:13:15 +02:00
c07e1eff3c New: Redirect the user to the migration page if the import has started but is not finished to prevent him from using MailPoet with incomplete data. So he can resume the import where it left off. 2017-06-12 13:13:15 +02:00
f5e985baa4 Change: Move the progress bar JSON file to the wp-content/uploads/mailpoet directory and remove "mailpoet" from its filename 2017-06-12 13:13:14 +02:00
2c93a105cc Fixed: Migration script suggests displays "Upgrade completed!" text and allows the user to click the "Go to MailPoet" button while the migration is still being performed. 2017-06-12 13:13:14 +02:00
cbf0a7684f Fixed: If there are WP users that haven't been added as MP2 WP subscribers, they won't be present as MP3 subscribers after migration either. 2017-06-12 13:13:13 +02:00
2632feba31 Fixed: On Migration page, clicking on "Start upgrade No thanks, I'll skip and start from scratch." redirects to the same migration page. 2017-06-12 13:13:12 +02:00
c96bc755c7 Fixed: the progress bar goes over 100% and displays "NaN%" if the MP2 tables are empty. 2017-06-12 13:13:12 +02:00
bbad772d7a PHP Notice: Use of undefined constant IMPORT_TIMEOUT_IN_SECONDS 2017-06-12 13:13:11 +02:00
520a3c43be Changes for API 2017-06-12 13:13:10 +02:00
eb70df1466 The "Start upgrade" button can now resume the import. 2017-06-12 13:13:09 +02:00
5977b8b4bc Translations 2017-06-12 13:13:09 +02:00
2bb7d95e37 Remove the "Start upgrade" button when the upgrade is completed
Add the "Upgrade completed" message
Add the "Go to MailPoet" button
2017-06-12 13:13:08 +02:00
c64959dce0 Fixed: Segments number can be wrong 2017-06-12 13:13:08 +02:00
ead0792b32 Rename getDataToMigrate() to getDataToMigrateAndResetProgressBar() 2017-06-12 13:13:07 +02:00
7bd52d456c Make the Migration page accessible through admin.php?page=mailpoet-migration 2017-06-12 13:13:06 +02:00
8517896660 Rename imported_data_mapping table to mapping_to_external_entities 2017-06-12 13:13:06 +02:00
c78933f7c4 Numerous fixes following the code review:
H1 title should be "Welcome to MailPoet version 3!", as per wireframes
remove logo in top right of the page
remove the classes feature-section one-col to the parent
new styles for #logger
progress bar: ensure that the color and size for the font are the same as our current progress bar.
display the progress bar at 100% when the import of subscribers and lists is complete
move loadSQL() function in tests/_support/Helper/Database.php
remove CSS browser prefixes
use AMD module definition to embed the JavaScript
remove extra whitespace in JavaScript file
remove the redundant functions descriptions
rename objectPlugin to mailpoet_mp2_migrator
replace private $chunks_size by the constant CHUNK_SIZE
add the constant IMPORT_TIMEOUT_IN_SECONDS
replace Helpers::mysqlDate() by $datetime->formatTime(time(), \MailPoet\WP\DateTime::DEFAULT_DATE_TIME_FORMAT)
make the log messages translatable
fix PHPDoc
replace Env::$plugin_name by 'mailpoet' in the translation functions
use $snake_case for variable names, use lowercaseCamelCase for method names, use CamelCase for class names
define MP2 table names as constants
add spaces around ternary operators
use the models for MP3 entities, instead of counting via raw SQL queries
use \ORM::for_table('some_table')::count()
2017-06-12 13:13:05 +02:00
707d5efec1 Modify H1 title
Remove logo
Modify progress label font size
Modify progress bar style
2017-06-12 13:13:04 +02:00
acfb3aefba Use snake_case 2017-06-12 13:13:04 +02:00
cb6f4046a2 Removes utf8 decoding that breaks import 2017-06-12 13:13:03 +02:00
667aa91581 Adds character encoding 2017-06-12 13:13:02 +02:00
b7f7dc6728 Add unit tests for the MP2Migrator class
Add the method "invokeMethod" in the MailPoetTest class to be able to test private and protected methods
Move the "rowsCount" method in the Helpers class for reusability
Add the method "loadSQL" in the Helpers class
Store the mapping between MP2 user ID and MP3 subscriber ID
2017-06-12 13:13:02 +02:00
ad1e8feb23 QA fixes 2017-06-12 13:13:01 +02:00
486b382c88 Use API versioning 2017-06-12 13:13:00 +02:00
472be3b071 Import the MP2 users lists
Import the MP2 users
Add the table "imported_data_mapping"
Add the function Helpers::mysql_date
2017-06-12 13:13:00 +02:00
37a9fd9e1b Use Setting::getValue() and Setting::setValue() instead of get_option() and update_option() 2017-06-12 13:12:59 +02:00
c984ac7a66 New: Display the number of data to migrate
Several fixes following the code review:
- For styles we use Stylus. (http://stylus-lang.com/)
  In Stylus styles curly brackets and terminating semicolons are unnecessary. Indentation is sufficient to denote blocks of styles
  You can also use variables to avoid duplication (e.g. mentioning the same color multiple times)
  Vendor prefixes are not necessary. We use the Nib mixin for Stylus to handle those (http://tj.github.io/nib/)
  => DONE

- `admin.js` bundle is included on all admin pages, so we need to ensure that migration fires only on the migration page and nowhere else.
  You can even create a separate bundle only for migration files, as they won't be necessary on other admin pages.
  => DONE

- MP2MigratorAPI => MP2Migrator endpoint would be just as fine
  => DONE

- For storing migration files, you can use the `Env::$temp_path` path
  => DONE

- `proposeMigration()` the method name disagrees with the comment.
  Comment suggests it tests if migration can be or should be performed
  Method name suggests that it proposes doing the migration (to the user?) - not very clear
  => DONE: the new name is isMigrationNeeded()

  And not only does it test, it may also update the `mailpoet_migration_complete` option, which is confusing and is an unexpected side-effect.
  => DONE

  The migration class itself `MP2Migrator` shouldn't even care about _GET, _REQUEST or _POST arguments. It should only work with what is passed to it.
  => DONE

- In views, please make sure all human-friendly texts use WP's gettext functions for translations (e.g. __('text'))
=> DONE
2017-06-12 13:12:58 +02:00
a1ea56f505 Coding standard fixes 2017-06-12 13:12:58 +02:00
dd7f959731 Migration from Mailpoet 2 to Mailpoet 3 : phase 0
Interface
2017-06-12 13:12:57 +02:00
09f4f2e78a Fix a unit test [MAILPOET-942] 2017-06-12 11:38:01 +03:00
502250a1a3 Merge pull request #930 from mailpoet/import_update
Adjusts WP's email validation regex to JS's syntax [MAILPOET-943]
2017-06-12 11:10:38 +03:00
48e37f6797 Adjusts WP's email validation regex syntax to JS 2017-06-11 12:31:54 -04:00
420058a86d Optimizes tests
Adds new tests
2017-06-11 12:18:14 -04:00
6c777ca074 Reloads subscriber or else status and other fields populated at save
time are not returned
Schedules welcome notifications only for subscribers with "subscribed"
status
Extracts confirmation email sending/welcome notification scheduling into
separate functions for easy testing
2017-06-11 12:16:34 -04:00
a481debb77 Adds "html" body to the mailing method test message 2017-06-09 09:53:07 -04:00
c91f8ccc7a Replaces SwiftMailer's mail() method with WP's PHPMailer 2017-06-09 09:52:22 -04:00
6a2b5e28c2 Merge pull request #927 from mailpoet/fix-alc-buttons-settings
Fix ALC buttons settings when updating all buttons [MAILPOET-896]
2017-06-09 09:35:36 +03:00
bc51b6efc8 Add replaceAllButtonStyles test to button
[MAILPOET-896]
2017-06-09 07:24:26 +01:00
152edda03f Add unit test
[MAILPOET-896]
2017-06-08 16:58:30 +01:00
5029b73027 Merge pull request #924 from mailpoet/model_validator_fix
Fixes reference to $this in anonymous function on PHP 5.3 [MAILPOET-934]
2017-06-08 17:13:04 +03:00
35c25d3337 Updates length to support IPv4 mapped IPv6 addresses 2017-06-08 13:45:50 +01:00
ae25e95d51 Updates length of columns with IP addresses to 39 2017-06-08 13:45:50 +01:00
5b8d0c63a1 Fix a changelog link [MAILPOET-935] 2017-06-08 10:47:30 +01:00
94fb8c6096 Merge pull request #918 from mailpoet/beacon_update_with_premium_version
UTF-8 encodes beacon data
2017-06-08 12:38:18 +03:00
93ef1d0197 Fix ALC buttons settings when updating all buttons
[MAILPOET-896]
2017-06-08 10:19:24 +01:00
501d00b0cc Merge pull request #919 from mailpoet/fix-composer-cp-mac
Remove -d option from composer.json script
2017-06-08 12:15:18 +03:00
9af3dc1f9d Fixes reference to $this in anonymous function on PHP 5.3 2017-06-07 11:52:46 -04:00
3705ed7da0 Use a faster SVN workflow in release publishing automation [MAILPOET-913] 2017-06-07 17:46:10 +03:00
5b99e66d8d Merge pull request #922 from mailpoet/fix-tests-problems
Fix tests problems
2017-06-07 10:34:20 -04:00
cbedd5ff40 Bump up release version to 3.0.0-beta.34.0.0 2017-06-07 16:14:47 +03:00
bfcd6f10fc Merge pull request #921 from mailpoet/premium_launch
Add Premium features for the launch, Free-side
2017-06-07 14:54:21 +03:00
79362e9955 Update 'buy Premium only' link URL on the Premium page 2017-06-07 14:42:55 +03:00
fcf272b44a Fix lint error 2017-06-07 11:49:07 +01:00
b80683a9a1 Fix unit tests for PHPUnit v6
Codeception from version 2.3 up comes with PHPUnit v6 which changed
__construct behaviour. Our tests have to call parent __constructor in
order to work. The error was:
[PHPUnit\Framework\Exception] array_merge(): Argument #1 is not an array
2017-06-07 11:32:33 +01:00
5349f3a59a Use ssl while checking url
My internet provider tried to be helpfull and offeres content on
invalid urls. That is only behaviour for http:// scheme and not
for https:// scheme so I need to enforce ssl so that invalid url
fails even in my house.
2017-06-07 11:30:31 +01:00
95072a9ac5 Restore empty license key warnings [MAILPOET-933] 2017-06-07 12:39:45 +03:00
8c372b0909 Update support video, add a border to videos [MAILPOET-885] 2017-06-07 12:39:45 +03:00
580dd38b3a Rename methods for consistency and better readability [PREMIUM-9] 2017-06-07 12:39:44 +03:00
47d4e98aae Integrate installer with the Release API [PREMIUM-9] 2017-06-07 12:39:43 +03:00
7ebb7bac17 Add Premium installation/activation UI [PREMIUM-9] 2017-06-07 12:39:43 +03:00
6cbce2fc97 Replace Premium gif assets with mp4 videos [MAILPOET-885] 2017-06-07 12:39:41 +03:00
e8a950f32c Add Premium page images to plugin repository assets [MAILPOET-885] 2017-06-07 12:39:12 +03:00
4f722ecd8a Add hooks for actions row for standard and notification history newsletter types [PREMIUM-13] 2017-06-07 12:30:50 +03:00
478359f9ff Add minor improvements to stats [PREMIUM-13] 2017-06-07 12:30:48 +03:00
a1720a5cf1 Use videos instead of gifs on the Premium page [MAILPOET-885] 2017-06-07 12:30:47 +03:00
3f0ef3ded7 Replace Premium gif assets with mp4 videos [MAILPOET-885] 2017-06-07 12:30:47 +03:00
dcb25c1a6b Swap welcome emails and support images [MAILPOET-885] 2017-06-07 12:30:45 +03:00
c5dd575324 Add Premium page images to plugin repository assets [MAILPOET-885] 2017-06-07 12:30:45 +03:00
6eca26a4e2 Add UTM params to Premium page links [MAILPOET-885] 2017-06-07 12:30:43 +03:00
e10fa065bd Add Premium page [MAILPOET-885] 2017-06-07 12:30:42 +03:00
49673fabbd Does not display logo when MSS is active or preview is enabled
Adds additional unit tests and optimizes existing
2017-06-07 12:30:42 +03:00
1c1a210542 Adds MailPoet logo to newsletters in the free version 2017-06-07 12:30:41 +03:00
30277d92cd Updates action button 2017-06-07 12:30:41 +03:00
fb940065ea Fix a source value for Premium key in the worker [MAILPOET-890] 2017-06-07 12:30:40 +03:00
afa06342a5 Update link for the Premium page 2017-06-07 12:30:40 +03:00
03d2ff5f26 Make use of returned promises for parallel requests loading modal [MAILPOET-890] 2017-06-07 12:30:40 +03:00
ec71dff40d Change strings on the 2000 limit page for Premium [MAILPOET-888] 2017-06-07 12:30:39 +03:00
58faf64a5c Add a Premium page link to bounced subscribers listing [MAILPOET-887] 2017-06-07 12:30:39 +03:00
65ff14a81d Adds hook to modify newsletter actions 2017-06-07 12:30:38 +03:00
f7efe44f09 Fix ServicesChecker behavior, make MSS check stricter [MAILPOET-890] 2017-06-07 12:30:38 +03:00
cf22e81ae1 Updates exposed components 2017-06-07 12:30:37 +03:00
7aa0f21d11 Rework 'Send with...' tab UI, make a single license key field [MAILPOET-890] 2017-06-07 12:30:37 +03:00
2e31e3d37c Exposes components required for welcome notifications 2017-06-07 12:30:36 +03:00
3e988b7a56 Removes welcome notification creation component and routes
Updates welcome notification template
2017-06-07 12:30:36 +03:00
ce3eb06924 Prevents welcome emails from being created
Adds filter to modify available email types
2017-06-07 12:30:35 +03:00
a37ff8d398 Limits utf8 encoding to php_uname function only (Windows may use an
encoding other than ISO-8859-1 in non-English locales)
2017-06-06 18:16:04 -04:00
d0bdb1a47b Adds XML polyfill for utf8_encode/decode functions 2017-06-06 15:06:39 -04:00
855f2a55d4 Remove -d option from composer.json script
This flag is not present on mac and it makes this script
fail on MacOS.
2017-06-06 15:49:51 +01:00
fc7ec9bded UTF-8 encodes beacon data 2017-06-06 10:10:07 -04:00
028de860a2 Merge pull request #913 from mailpoet/sending_queue_update_on_newsletter_status_change
Prevents processing of sending queues when newsletter is paused [MAILPOET-900]
2017-06-06 15:00:21 +03:00
5af91d028d Merge pull request #916 from mailpoet/unsubscribe_fix
Fixes incorrect dependency that breaks unsubscribe link [MAILPOET-931]
2017-06-06 13:12:16 +03:00
a4bcf870bb Merge pull request #915 from mailpoet/beacon_update_with_premium_version
Adds premium version information to HS beacon [MAILPOET-930]
2017-06-06 09:49:09 +03:00
e06f2f5f0b References the correct class and removes unused dependency 2017-06-05 15:20:14 -04:00
c101645d93 Adds premium version information to HS beacon 2017-06-05 14:59:30 -04:00
b8904c2d51 Merge pull request #914 from mailpoet/subscriber_email_validation_logic_update
Uses WP's function to validate subscriber email address [MAILPOET-925]
2017-06-05 19:25:53 +03:00
099db4e1c8 Removes unused variable
Fixes typo in error message
2017-06-05 11:59:13 -04:00
cdf36ccb20 Trashes/restores/deletes (+ same bulk actions) children newsletters and
associations as per discussion on Slack:
https://mailpoet.slack.com/archives/C02MTKAJL/p1496427873491785
2017-06-05 11:36:04 -04:00
79b6ab1d15 Finishes incomplete test 2017-06-05 10:30:45 -04:00
95114774da Merge pull request #912 from mailpoet/sending_queue_and_post_notification_history_listing_update
Sending queue and post notification history listing update [MAILPOET-928]
2017-06-05 14:53:22 +03:00
7f566fb672 Adds client-side check for invalid characters in email addresses
Adds server-side validation of email addresses using WP's is_email()
2017-06-04 18:48:11 -04:00
d27968a215 Uses WP's is_email() to validate email addresses in Subscriber model 2017-06-04 18:19:37 -04:00
344990d59e Only processes queues when newsletter exists and is active/sending 2017-06-02 12:03:34 -04:00
ea831ef160 Prevents processing scheduled sending queues for inactive newsletters 2017-06-01 19:50:25 -04:00
8314b05fce Displays "not yet sent" as a sent date when post notification has not
yet been sent/being sent
2017-06-01 14:58:25 -04:00
fd33cc7068 Uses parent newsletter's subject when queue's rendered subject is not
available
2017-06-01 14:26:50 -04:00
92e4cc6a24 Sorts sending queue according to their creation date (oldest to newest) 2017-06-01 13:21:03 -04:00
dd4bebb570 Bumps up release version to Beta 33.1 and updates changelog 2017-05-30 14:27:29 -04:00
99aed2cb01 Merge pull request #908 from mailpoet/utf8_fix
Apply charset and collation only if they are specified [MAILPOET-924]
2017-05-30 14:25:33 -04:00
92616063ec Fix unit test for generating DB source name 2017-05-30 21:18:45 +03:00
c56b56f4aa Apply charset and collation only if they are specified 2017-05-30 21:05:01 +03:00
33d6533c64 Bumps up release version to Beta 33 and updates changelog 2017-05-30 09:30:12 -04:00
55d7a0dd01 Merge pull request #907 from mailpoet/welcome_email_scheduler_update
Schedules welcome notifications after subscription is confirmed [MAILPOET-907]
2017-05-30 14:02:48 +03:00
8b2ac99eda Merge pull request #903 from mailpoet/beacon_update
Adds server OS, web server information and cron ping response to HS beacon [MAILPOET-918]
2017-05-30 12:15:46 +03:00
dba21c68fd Schedules welcome notification upon subscription when subscription
confirmation is disabled
Schedules welcome notification upon subscription confirmation
Checks when 'REMOTE_ADDR' is not set
Adds unit tests
2017-05-29 22:04:47 -04:00
5b40652737 Merge pull request #906 from mailpoet/form_widget_rendering
Wrap form widget title as configured by the sidebar [MAILPOET-910]
2017-05-29 19:44:11 -04:00
7f0396747d Adds cron ping URL instead of ping response
Checks for existence of SERVER_SOFTWARE variable
2017-05-29 19:29:56 -04:00
e9dfff8e66 Wrap form widget title as configured by the sidebar 2017-05-29 18:12:51 +03:00
040c4da6c3 Merge pull request #904 from mailpoet/php_version_requirement_update
Requires PHP 5.3.3 in line with composer.json requirements [MAILPOET-921]
2017-05-29 13:15:13 +03:00
80a237504d Requires PHP 5.3.3 in line with composer.json requirements 2017-05-26 11:34:31 -04:00
4e2e09ea24 Adds server OS, web server information and cron ping response to HS
beacon
2017-05-25 15:55:33 -04:00
87b9fbdc16 Merge pull request #900 from mailpoet/utf8
Synchronize MailPoet DB connection charset with WordPress [MAILPOET-748]
2017-05-24 16:09:58 +03:00
a071a14eec Update only those queries, for which conversion will yield correct char
lengths
2017-05-24 15:45:12 +03:00
5ae006b10f Update plugin version [MAILPOET-748] 2017-05-24 15:45:12 +03:00
9d21ebd26e Fix a comment. UTF8MB4 is a superset of UTF8 2017-05-24 15:45:12 +03:00
fcff6de3c3 Skip conversion for charset utf8 -> utf8mb4 2017-05-24 15:45:12 +03:00
3d2168856d Fix unit tests for Env charsets and collations 2017-05-24 15:45:12 +03:00
a6eb1b06da Add connection charset sync with WP and convert existing data to it 2017-05-24 15:45:12 +03:00
21d0c3518e Merge pull request #901 from mailpoet/transifix
Bundle translations completed by 75%, remove PO files in build [MAILPOET-916]
2017-05-23 18:40:46 +03:00
3532a3c8e9 Bundle translations completed by 75%, remove PO files in build [MAILPOET-916] 2017-05-23 18:34:00 +03:00
79cba4cace Release 3.0.0-beta.32 2017-05-23 13:27:19 +03:00
a5dee8da12 Merge pull request #897 from mailpoet/third_party_subscription_methods
Enables subscriber email to be passed when subscribing to list(s) [MAILPOET-809]
2017-05-22 14:25:00 +03:00
3783384ea6 Add a test to ensure subscribers can be identified by their email
address via MPAPI
2017-05-22 13:49:01 +03:00
766c0dfcfc Enables subscriber email to be passed when subscribing to list(s)
List subscription methods return array with subscriber data
2017-05-19 09:51:29 -04:00
83e9de8e95 Merge pull request #887 from mailpoet/third_party_subscription_methods
Adds API methods for third-party plugins [MAILPOET-809]
2017-05-17 14:03:19 +03:00
0a512f6349 Uses the first matching namespace endpoint 2017-05-16 23:17:25 -04:00
a4c1095db7 Moves custom field extraction logic from CustomField model to Subscriber
model where it's used
2017-05-16 20:58:44 -04:00
87a6c7100e Uses real object's ID 2017-05-16 20:58:43 -04:00
fc51d5f98c Sends confirmation email and schedules welcome notification by default
Fixes a typo in text string
2017-05-16 20:58:43 -04:00
a1b3aaf1f8 Adds method to create subscriber 2017-05-16 20:58:43 -04:00
3a1bf88c22 Extracts some logic into resuable methods 2017-05-16 20:58:43 -04:00
bd39c34f03 Adds unit tests 2017-05-16 20:56:56 -04:00
73121c2ca5 Adds method to return all segments minus WP Users segment(s) 2017-05-16 20:56:56 -04:00
5e23fa4295 Adds method to subscribe to single or multiple lists 2017-05-16 20:56:56 -04:00
5e34bbf9d5 Adds method to return subscriber fields 2017-05-16 20:56:56 -04:00
cedd94550f Adds unit test for API entry point 2017-05-16 20:56:55 -04:00
8b13889c7a Adds one entry point for both JSON and MP APIs
Removes endpoints folder and moves versions to the root
JSON API folder
2017-05-16 20:56:55 -04:00
3c7ac5488a Adds MP API facade 2017-05-16 20:56:54 -04:00
398d7d3d80 Moves current API under JSON namespace 2017-05-16 20:56:54 -04:00
b727ba423e Fix a typo in readme.txt 2017-05-16 18:08:58 +03:00
45b9550293 Thank people in changelog 2017-05-16 17:56:25 +03:00
d2e520e2fd Add new translations info to the readme.txt 2017-05-16 17:39:30 +03:00
b9c3ae97cd Bump up release version to 3.0.0-beta.31 2017-05-16 17:23:58 +03:00
b90c0b173b Merge pull request #892 from mailpoet/premium_key_warnings_fix
Temporarily hide invalid key warnings when the license key isn't specified [MAILPOET-911]
2017-05-16 12:56:26 +03:00
f498f4df0c Merge pull request #894 from mailpoet/progress_bar_style
Change sending progress bar style [MAILPOET-753]
2017-05-15 22:20:00 -04:00
2f10f89fc5 Change sending progress bar style [MAILPOET-753] 2017-05-15 21:25:40 +03:00
a49f9d9c80 Merge pull request #893 from mailpoet/newsletter_hash_generation_fix
Fixes newsletter link hash generation logic [MAILPOET-912]
2017-05-15 20:45:54 +03:00
e71e23bbb5 Temporarily hide invalid key warnings when the license key isn't specified [MAILPOET-911] 2017-05-15 20:16:29 +03:00
adc86ef247 Increases hash length and random string size 2017-05-15 13:07:18 -04:00
765b2bad21 Merge pull request #891 from mailpoet/form_list_select_fix
Fix non-text form fields not being sent to server [MAILPOET-909]
2017-05-15 09:15:44 -04:00
2354cac719 Updates unit test 2017-05-15 08:55:32 -04:00
7f509f66ff Changes newsletter link hash generation function 2017-05-15 08:36:43 -04:00
d8ff251c71 Fix WP user first/last name being cleared after subscription management form submit 2017-05-15 10:22:47 +03:00
12979cc2c0 Merge pull request #883 from mailpoet/alc_term_limit
Remove the result limit when searching for post terms in ALC and Posts [MAILPOET-902]
2017-05-14 22:47:16 -04:00
e974c06a89 Fixes subscription management form not saving data 2017-05-14 22:41:16 -04:00
f2ceff8252 Removes unused method 2017-05-14 22:02:24 -04:00
cd5f3165c7 Uses queue ID when fetching newsletter link by hash 2017-05-14 22:02:19 -04:00
6e700b0cfa Moves newsletter hash generating logic into Security helper class
Updates Links class to use Security helper's hash generating method
2017-05-14 20:15:40 -04:00
5b41fc212c Merge pull request #890 from mailpoet/helpscout
Force showing name and email fields in HelpScout Beacon [MAILPOET-908]
2017-05-13 12:52:13 +03:00
2b7a5452b8 Fix non-text form fields not being sent to server [MAILPOET-909] 2017-05-11 18:12:57 +03:00
cfed133fb6 Limit the number of terms returned to 50 and force ordering by name 2017-05-11 13:00:42 +03:00
0beff9a090 Bump up the limit when searching for post terms in ALC and Posts 2017-05-11 12:45:15 +03:00
d6e707fb85 Force showing name and email fields in HelpScout Beacon [MAILPOET-908] 2017-05-11 12:22:07 +03:00
a3e8d47199 Bump up release version to 3.0.0-beta.30 2017-05-09 16:57:29 -04:00
cab3f3a96e Merge pull request #884 from mailpoet/premium_key_check
Add Premium key validation [PREMIUM-4]
2017-05-09 16:30:43 +03:00
5f0d4abe7f Temporarily hide Premium tab in settings [PREMIUM-4] 2017-05-09 16:01:42 +03:00
ff5f87eeca Rename processQueueLogic() method to processQueueStrategy() [PREMIUM-4] 2017-05-09 15:42:37 +03:00
e85b969e11 Rename initApi() to init() in workers [PREMIUM-4] 2017-05-09 09:12:20 +03:00
2eb98905b6 Encapsulate date formatting within the DateTime class [PREMIUM-4] 2017-05-09 08:54:12 +03:00
ac1274c6fd Merge pull request #889 from mailpoet/tinymce_lists_fix
Bring back list buttons to the TinyMCE toolbar [MAILPOET-906]
2017-05-08 14:14:52 -04:00
94f91afce1 Bring back list buttons to TinyMCE toolbar [MAILPOET-906] 2017-05-08 21:01:18 +03:00
73d5fb8cff Merge pull request #886 from mailpoet/strings_fix
Fixes form editor notification not displaying added/updated/removed custom field [MAILPOET-905]
2017-05-08 13:24:59 +03:00
90b2b46db4 Make key check method names consistent [PREMIUM-4] 2017-05-08 13:16:05 +03:00
f2bf61240a Extract a state building method from key check results processing [PREMIUM-4] 2017-05-08 08:01:51 +03:00
3f151fd235 Extract simple workers common code into a base class [PREMIUM-4] 2017-05-08 07:38:56 +03:00
7598363cae Fixes notification message not displaying dynamic value due to JS
encoding
2017-05-05 18:38:49 -04:00
4b1f216cd3 Use WP's date format instead of a hard-coded one [PREMIUM-4] 2017-05-05 18:57:15 +03:00
3d5f13a2b8 Fix code style [PREMIUM-4] 2017-05-05 18:41:19 +03:00
98eab956e9 Rename checkAPIKey to checkMSSKey (MailPoet Sending Service) [PREMIUM-4] 2017-05-05 18:12:48 +03:00
a7260cba3d Make the Premium key check stricter, split a unit test into more granular ones [PREMIUM-4] 2017-05-05 18:09:00 +03:00
787e022382 Rename license key constants and vars, optimize error generation [PREMIUM-4] 2017-05-05 18:04:52 +03:00
d8e1c76155 Remove a leftover hook from Free after the key field removal from Premium [PREMIUM-4] 2017-05-05 17:18:56 +03:00
3cb08e3c09 Rename MSS check methods to better distinguish them from Premium ones [PREMIUM-4] 2017-05-04 09:36:38 +03:00
0474985866 Add unit tests [PREMIUM-4] 2017-05-04 09:25:34 +03:00
8d15ef6d06 Refine license key check UI [PREMIUM-4] 2017-05-04 09:15:21 +03:00
0fbc7fb7eb Add Premium key validation [PREMIUM-4] 2017-05-03 12:20:13 +03:00
1379bdbbeb Bump up release version to 3.0.0-beta.29 2017-05-02 18:10:20 +03:00
64d3e659a4 Merge pull request #879 from mailpoet/newsletter_model_update
Newsletter model update [MAILPOET-830]
2017-05-02 16:19:20 +03:00
19458546a0 Updates unit tests 2017-05-02 08:41:51 -04:00
bba7460423 Merge pull request #882 from mailpoet/conflict_resolver_update
Resolves script conflicts in WP's admin footer [MAILPOET-901]
2017-05-02 13:37:20 +03:00
956fdd5cff Improve a deletion test to handle multiple queues, fix comments [MAILPOET-830] 2017-05-02 09:07:38 +03:00
a0289775cb Trashes/restores multiple associated queues when newsletter is
trashed/restored
2017-05-01 20:15:41 -04:00
4c785902bc Resolves script conflicts in WP's admin footer 2017-05-01 11:57:48 -04:00
e29ae4d7c9 Fixes indentation 2017-05-01 09:31:52 -04:00
1ea915017a Fixes unit test 2017-05-01 09:26:36 -04:00
6441c781a5 Moves relations to the top of the model and delete/save/restore/trash methods close to each other for easy navigation 2017-05-01 09:26:35 -04:00
589c54e205 Checks if associated queue exists before trashing/deleting/restoring it 2017-05-01 09:26:35 -04:00
e10b99eaac Deletes all sending queue and segment associations when newsletters are bulk deleted 2017-05-01 09:26:35 -04:00
0316f3ea3e Restores all sending queue associations when newsletters are bulk restored 2017-05-01 09:26:35 -04:00
166fef899f Trashes all sending queue associations when newsletters are bulk trashed 2017-05-01 09:26:35 -04:00
4e850408fc Restores sending queue association when newsletter is restored 2017-05-01 09:26:35 -04:00
6e2494831c Trashes sending queue association when newsletter is trashed 2017-05-01 09:26:35 -04:00
38a7d8f80a Deletes queue and segment associations when deleting newsletter 2017-05-01 09:26:34 -04:00
abfebc8643 Merge pull request #880 from mailpoet/subscriber_shortcode_fix
Returns shortcode's default value when subscriber's first/last name is blank [MAILPOET-899]
2017-05-01 11:28:54 +03:00
40a3487d3d Remove a redundant condition, fix a typo in a test name [MAILPOET-880] 2017-05-01 11:20:33 +03:00
a93865e594 Merge pull request #874 from mailpoet/trashed_segments_fix
Exclude trashed segments from subscriber listing filter and 'not in list' count [MAILPOET-893]
2017-04-30 20:09:23 -04:00
4e76286b44 Returns shortcode's default value when subscriber's first or last name is empty 2017-04-28 09:49:00 -04:00
fbe57e96c6 Merge pull request #878 from mailpoet/contribution_rules
Update rules/guidelines for contributing to this codebase [MAILPOET-898]
2017-04-27 11:22:10 -04:00
950bfb04d6 Update README.md with more new commands 2017-04-27 17:56:36 +03:00
6d43b7b6a9 Update rules/guidelines for contributing to this codebase 2017-04-27 17:51:50 +03:00
e1991deafd Merge pull request #876 from mailpoet/manage_subscription_shortcode_fix
Depreciates and removes certain link shortcodes [MAILPOET-895]
2017-04-27 15:51:26 +03:00
2f1b31aeb2 Adds missing anchor closing tag 2017-04-27 08:41:05 -04:00
ca29eefd7f Merge pull request #877 from mailpoet/form_placement_update
Removes HTML method from form placement [MAILPOET-897]
2017-04-27 15:40:55 +03:00
1421407a23 Merge pull request #875 from mailpoet/smtp_hooks
Adds filter to SMTP transport agent [MAILPOET-889]
2017-04-27 14:43:40 +03:00
36e4bf468d Merge pull request #871 from mailpoet/editor_marionette
Upgrade Marionette version in newsletter editor [MAILPOET-892]
2017-04-27 11:19:46 +03:00
5cd3917f4d Removes HTML method from form placement 2017-04-26 19:38:19 -04:00
586470e8f9 Updates unit tests 2017-04-26 17:58:45 -04:00
b02e9f5ab3 Depreciates and removes server-side rendering of subscription_unsubscribe,
subscription_manage and newsletter_view_in_browser
2017-04-26 17:47:52 -04:00
4a538e677d Adds filter to SMTP transport agent 2017-04-26 09:55:57 -04:00
cc2fdbe5be Merge pull request #864 from mailpoet/campaign_stats
Add detailed stats page support in Free, change stats style [PREMIUM-1] [MAILPOET-877]
2017-04-26 14:30:51 +03:00
3833688115 Exclude trashed segments from subscriber listing filter and 'not in list' count [MAILPOET-893] 2017-04-26 11:23:16 +03:00
1639741e55 Bump up release version to 3.0.0-beta.28 2017-04-25 19:00:18 +03:00
ab0d573a66 Merge pull request #873 from mailpoet/import_results_fix
Keeps track of the number of updated/created subscribers over multiple server requests [MAILPOET-894]
2017-04-25 18:26:38 +03:00
26c582b19f Keeps track of the number of updated/created subscribers over multiple
server requests
2017-04-25 11:00:52 -04:00
3bc53f9f09 Remove Premium-only styles from Free, cleanup styles [PREMIUM-1] 2017-04-25 12:46:05 +03:00
bb220baf6a Add names to constants, rename vars for clarity [MAILPOET-877] 2017-04-25 12:46:04 +03:00
121a78f42a Update an open rate improvement KB link URL [MAILPOET-877] 2017-04-25 12:46:04 +03:00
4257aa634e Don't show green box and KB link in stats for welcome emails [MAILPOET-877] 2017-04-25 12:46:03 +03:00
95ff83557f Add a green box in stats for recently sent newsletters, add help KB link [MAILPOET-877] 2017-04-25 12:46:03 +03:00
e9070de9c4 Add badges to stats in a newsletter listing, change stats style [PREMIUM-1] [MAILPOET-877] 2017-04-25 12:45:52 +03:00
72aa087411 Localize formatting to 1 decimal [PREMIUM-1] 2017-04-25 12:45:50 +03:00
fbc0a3ad8d Add detailed stats page support in Free [PREMIUM-1] 2017-04-25 12:45:49 +03:00
afedc409f5 Merge pull request #872 from mailpoet/newsletter_id_number_format_fix
Adds intval filter and fixes issue with number format applied on IDs >= 1000 [MAILPOET-891]
2017-04-25 12:27:17 +03:00
0360f16dc8 Merge pull request #865 from mailpoet/api_versioning
Adds versioning to our public API [MAILPOET-881]
2017-04-25 12:07:17 +03:00
f4800dbbae Removes namescape format enforcement 2017-04-24 20:52:01 -04:00
15ddc8454e Adds intval filter and fixes issue with number format applied on IDs
>=1000
2017-04-24 19:25:17 -04:00
f8df4de711 Merge pull request #868 from mailpoet/bounce_doc_link
Add a link to the bounce article in advanced settings [MAILPOET-868]
2017-04-24 19:11:03 -04:00
a0cb18e1a1 Merge pull request #869 from mailpoet/html_notices_fix
Wrap notices containing HTML in a paragraph, upgrade notice classes [MAILPOET-733]
2017-04-24 16:09:50 -04:00
509ec7d3d3 Fix posts block settings to not use deprecated CompositeView 2017-04-24 18:00:23 +03:00
aa2416f353 Simplify settings views to use methods defined in base settings view 2017-04-24 18:00:23 +03:00
167a605658 Switch Container block view to use methods defined by base view 2017-04-24 18:00:23 +03:00
592f11bd5f Fix App activation calls, fix block insertion animations 2017-04-24 18:00:23 +03:00
92b128039a Fix displaying placeholder message on empty containers 2017-04-24 18:00:23 +03:00
5efe611b2d Remove obsolete comments, fix ALC settings 2017-04-24 18:00:23 +03:00
477e2737b1 Fix sorting of social icons in settings 2017-04-24 18:00:23 +03:00
dc8bacc27d Fix drag&drop 2017-04-24 18:00:23 +03:00
0b8c787cda Partially migrate newsletter editor to Marionette 3.x from 2.x 2017-04-24 18:00:23 +03:00
4f5c464659 Merge pull request #866 from mailpoet/list_unsubsribe_url
List unsubsribe url [MAILPOET-797]
2017-04-24 14:58:06 +03:00
4f432645b1 Merge pull request #870 from mailpoet/welcome_page_update
Update the Welcome page [MAILPOET-884]
2017-04-24 13:23:39 +03:00
5fa7930896 Redefines how endpoint namespaces are set
Updates error response to terminate connection only on AJAX requests
Optimizes and cleans up code based on code revew comments
2017-04-20 22:34:18 -04:00
f9efd536d9 Update the Welcome page [MAILPOET-884] 2017-04-20 21:00:09 +03:00
6a65ff5e5d Removes default version
Updates all AJAX requests to include api version
Requires namespaces to have version
Clean up code
2017-04-19 23:34:40 -04:00
b549f83422 Updates form subscription class to use the main API class instead of calling directly API endpoint
Modifies forms to pass api_version
Modifies forms to pass store form-specific values (e.g., form_id, email) inside a separate data array
2017-04-19 15:38:16 -04:00
a9c80c031f Adds version support to public API 2017-04-19 15:38:16 -04:00
405bea3049 Upgrade notice classes from deprecated ones [MAILPOET-733] 2017-04-19 17:11:42 +03:00
6954acd0b3 Wrap notice messages containing HTML in a paragraph to avoid broken styles [MAILPOET-733] 2017-04-19 17:11:14 +03:00
efd15d5d18 Add a link to the bounce article in advanced settings [MAILPOET-868] 2017-04-19 10:34:30 +03:00
6566622167 Bumps up release version to 3.0.0-beta.27
Updates changelog
Updates readme.txt based changes proposed by Kim
Cleans up language in readme.txt
2017-04-18 20:05:24 -04:00
8157780b68 removing uneeded code and moving the url generation to proper class 2017-04-18 21:12:41 +02:00
975546915e Merge pull request #867 from mailpoet/requirements_checker_update
Adds requirement check for ZIP and XML PHP extensions [MAILPOET-874]
2017-04-18 10:46:42 +03:00
319d591662 Merge pull request #863 from mailpoet/editor_tinymce
TinyMCE fixes [MAILPOET-880] [MAILPOET-829] [MAILPOET-862]
2017-04-17 09:13:35 +03:00
1dd6c91529 Updates missing requirements language 2017-04-16 23:54:10 -04:00
c4f0426775 Adds checker for XML and ZIP extensions 2017-04-16 21:10:15 -04:00
53f5a122bd Merge pull request #861 from mailpoet/post_filters
Fix post filters for custom post types in ALC [MAILPOET-838]
2017-04-16 19:52:01 -04:00
a7142ed21b modified SendingQueue Tests to ensure it passes the correct unsubscribe URL to Mailer 2017-04-15 22:14:40 +00:00
771a1bfc44 Adding List-Unsubscribe to header of newsletters 2017-04-15 21:21:28 +00:00
53169bba78 Merge pull request #860 from mailpoet/import_fixes
Fixes SQL errors & next button not working on step 2 of import [MAILPOET-876] [MAILPOET-766] [MAILPOET-879] [MAILPOET-828]
2017-04-14 09:03:59 +03:00
e3b8c1836b Adds additional new and existing subscribers to the test method to
ensure that data between new subscribers does not mix
2017-04-13 15:57:04 -04:00
a4b091dc32 Extends test condition to check for all new subscriber column data 2017-04-13 10:50:36 -04:00
448c9ddaa8 Fixes custom column names not being automatically matched on step 2 of
import
2017-04-13 10:10:00 -04:00
ac574acf8e Merge branch 'import_fixes' of mailpoet:mailpoet/mailpoet into import_fixes 2017-04-13 09:41:46 -04:00
aa15b9420a Replaces redundant search with one-time lookup 2017-04-13 09:28:54 -04:00
2b7f5c321e Merge pull request #862 from mailpoet/remote_images
Fixes Image block to update image dimensions when image src changes [MAILPOET-762]
2017-04-13 13:51:47 +03:00
bee9bfcfcc Fix data being mixed up when splitting subscribers, remove excessive arguments [MAILPOET-828] 2017-04-13 11:08:20 +03:00
b7d73dcfaa Updates unit test 2017-04-12 09:49:42 -04:00
5b4fa4ea2b Fixes custom fields not being updated or causing integrity constraint
error: https://mailpoet.atlassian.net/browse/MAILPOET-828
2017-04-12 09:40:15 -04:00
12e5fe77de Perform caret positioning only on TinyMCE activation click 2017-04-12 14:37:47 +03:00
2dca10c539 Fix cursor positioning when activating TinyMCE on click [MAILPOET-880] 2017-04-12 14:07:19 +03:00
ceba5b3d0b Fix pasting from text editors and word processors [MAILPOET-829] 2017-04-12 13:17:45 +03:00
c05cf3cad4 Update TinyMCE for fixed triple-click behavior [MAILPOET-862] 2017-04-12 13:14:27 +03:00
d6f5a39829 Simplifies subscriber splitting code and adds comments 2017-04-11 22:12:50 -04:00
30d67508cb Fixes Image block to update image dimensions when image src changes 2017-04-11 19:38:57 +03:00
63b8d892f7 Update changelog entries to use asterisks for list items instead of
dashes
2017-04-11 16:05:53 +03:00
10137d8551 Bump up release version to 3.0.0-beta.26 2017-04-11 15:46:32 +03:00
9ef74e0951 Stops execution when there are no subscriber columns to update 2017-04-10 21:41:37 -04:00
89ff93958f Removes subscriber object modification logic from the splitSubscribersData() method
Uses 2 separate objects with its own data for existing and new subscribers
Extends only new subscribers' object when it is missing required fields
2017-04-10 21:41:21 -04:00
8d870e85eb Switch to get_bloginfo() from bloginfo() to prevent output 2017-04-10 19:44:32 +03:00
0cdb426712 Fix ALC filtering for custom taxonomies and post types 2017-04-10 19:23:19 +03:00
b9f7a5673f Removes lefover test code 2017-04-10 11:32:38 -04:00
7ffbf6c378 Updates code style and adds wp_user_id column to the list of columns
that should be ignore when updating existing subscribers
2017-04-09 22:05:02 -04:00
3a9c006cf9 Prevents overwriting existing subscribers' status (and other required fields) unless
the import object contains data for those fields
2017-04-09 22:04:56 -04:00
a9edb383b4 Fixes next button not appearing when list is first unselected and then
selected back
2017-04-09 21:49:24 -04:00
ec23a73edb Merge pull request #859 from mailpoet/trailing_br_rendering_fix
Fix last <br/> removal cutting off text when rendering a text block [MAILPOET-856]
2017-04-06 21:57:07 -04:00
10a164ee0c Merge pull request #858 from mailpoet/customizer_fix
Rename a 'method' field in a form widget so it doesn't break the WP interactive customizer [MAILPOET-851]
2017-04-06 21:55:24 -04:00
37fcd5699b Fix last <br/> removal cutting off text when rendering a text block [MAILPOET-856] 2017-04-06 10:07:11 +03:00
66d969cc2f Merge pull request #857 from mailpoet/settings-css-update
Removes sending method's heading line-height [MAILPOET-873]
2017-04-05 18:51:09 +03:00
9d358f74dd Rename a 'method' field in a form widget so it doesn't break the WP interactive customizer [MAILPOET-851] 2017-04-05 18:35:13 +03:00
57e00e3097 Removes sending method's heading line-height 2017-04-05 10:45:31 -04:00
53afbea6ec Bump up release version to 3.0.0-beta.25 2017-04-04 18:22:44 +03:00
2c2c0b3db4 Merge pull request #856 from mailpoet/sending_limit_enforcement_fix
Fixes sending limit not being enforced [MAILPOET-872]
2017-04-04 17:07:51 +03:00
e235ee66eb Adds regression unit test 2017-04-04 09:59:06 -04:00
0ef430567b Fixes sending limit not being enforced when email frequency limit is
changed to a lesser value OR when it is changed while sending is in
progress
2017-04-04 09:43:27 -04:00
74aef73f75 Merge pull request #855 from mailpoet/php53-fix
Fixes reference to self in anonymous function [MAILPOET-871]
2017-03-31 21:31:20 +03:00
99eb72428f Fixes reference to self in anonymous function 2017-03-31 12:51:58 -04:00
065b160155 Merge pull request #854 from mailpoet/subscriber_listing_performance
Improve performance of a subscriber listing on MySQL 5.5 and lower [MAILPOET-867]
2017-03-30 09:51:47 -04:00
6811d8e38d Improve performance of a subscriber listing on MySQL 5.5 and lower [MAILPOET-867] 2017-03-30 13:12:53 +03:00
5f75efddf1 Updates changelog and bumps version to 3.0.0-beta.24 2017-03-28 14:19:11 -04:00
822a7ac5f5 Merge pull request #852 from mailpoet/translation_string_escaping_fix
Escapes quotation marks in translation results [MAILPOET-864]
2017-03-28 19:28:57 +03:00
06e1ac9bb5 Escapes translations for output in HTML attributes 2017-03-28 12:02:29 -04:00
a3530c3367 Escapes translations for JS output 2017-03-28 11:17:00 -04:00
ec35bfb2d4 Reverts back previous code 2017-03-28 11:16:09 -04:00
ed3e46bebb Merge pull request #853 from mailpoet/tracking_code_update
Makes tracking image transparent and fixes CSS rule parsing logic [MAILPOET-827]
2017-03-28 11:36:54 +03:00
87b270482b Fixes rules with colons (e.g, background-image: url(http://....);) from
being incorrectly parsed
2017-03-26 18:45:07 -04:00
d22ba55858 Outputs transparent gif instead of red color 2017-03-26 18:45:07 -04:00
835f25cc82 Fixes unit test that fails on the last Saturday of the month 2017-03-25 02:24:38 -04:00
11944283b0 Escapes quotation marks in translation results 2017-03-24 20:38:04 -04:00
dc704a92de Merge pull request #851 from mailpoet/import_language_update
Updates example import paste data (textbox hint) [MAILPOET-863]
2017-03-24 18:01:12 +02:00
dca1e9e1a7 Merge pull request #850 from mailpoet/manage_subscription_descr
Add details to the Manage Subscription description [MAILPOET-853]
2017-03-24 17:56:27 +02:00
00781be077 Updates example import paste data 2017-03-23 13:27:48 -04:00
ac80148f5b Merge pull request #844 from mailpoet/ga_tracking
JS hooks & GA tracking support [PREMIUM-2]
2017-03-23 14:58:58 +02:00
ff36833270 Add a hook for reinstalling Premium [PREMIUM-2] 2017-03-23 15:27:15 +03:00
612c7d76a0 Add details to the Manage Subscription description [MAILPOET-853] 2017-03-22 13:19:26 +03:00
32097b4512 Test that Premium hooks are executed [PREMIUM-2] 2017-03-21 21:36:36 +03:00
d686f75222 Swap JS actions with filters for robustness & testability, get rid of URL key hashing [PREMIUM-2] 2017-03-21 13:34:47 +03:00
bcc01df0b8 Merge pull request #849 from mailpoet/transifex_upload
Upload translation files to Transifex via publish command [MAILPOET-855]
2017-03-20 19:40:19 +02:00
ee12f4d304 Move a hook to be always executed after rebasing [PREMIUM-2] 2017-03-20 16:23:16 +03:00
16c1607850 Refactor links processing: isolate core logic for easier substitution [PREMIUM-2] 2017-03-20 12:09:58 +03:00
e2864e2243 Add hooks for GA tracking feature [PREMIUM-2] 2017-03-20 12:09:58 +03:00
16dc81150d Execute mailpoet_initialized hook earlier after setup [PREMIUM-2]
This is done because Router can seize the request and prevent subsequent actions like Premium hooking from being run, so hooks didn't work in cron daemon.
2017-03-20 12:08:40 +03:00
ed4d3d52ed Add hooks for Premium translations and scripts [PREMIUM-2] 2017-03-20 12:08:40 +03:00
37a6a74b6e Extract React libraries to a separate chunk and expose them globally [PREMIUM-2] 2017-03-20 12:08:40 +03:00
136a531047 Rename newsletters 3rd step hook [PREMIUM-2] 2017-03-20 12:08:40 +03:00
bef0097f5b Add front-end WP-style hooks support for Premium [PREMIUM-2] 2017-03-20 12:08:39 +03:00
a0d2be50e8 Upload translation files to Transifex via publish command [MAILPOET-855] 2017-03-16 15:11:38 +03:00
18e2d26587 Bump up release version to 3.0.0-beta.23.2 2017-03-15 14:35:44 +02:00
810a7bf544 Merge pull request #848 from mailpoet/welcome_emails_fix
Fix Welcome email sending [MAILPOET-859]
2017-03-15 13:59:57 +02:00
1010c6f4f0 Remove a space [MAILPOET-859] 2017-03-15 13:15:34 +03:00
8dd698ec75 Fix Welcome email sending [MAILPOET-859] 2017-03-15 12:12:47 +03:00
95e66f1f29 Bump up release version to 3.0.0-beta.23.1 2017-03-14 16:13:07 +02:00
ac0460ab04 Merge pull request #847 from mailpoet/freeze_dependencies
Freeze PHP and JS dependencies to specific versions [MAILPOET-858]
2017-03-14 16:58:23 +03:00
2d059debb7 Freeze PHP and JS dependencies to specific versions 2017-03-14 15:11:35 +02:00
df0ad2df37 Update release version to 3.0.0-beta.23 2017-03-14 13:18:21 +02:00
0f7725e6af Merge pull request #842 from mailpoet/verify_subscription_status_during_sending
Prevents sending to unsubscribed subscribers [MAILPOET-824]
2017-03-14 10:49:43 +03:00
eda346c582 Fix a unit test for PHP 7.1 [MAILPOET-824] 2017-03-14 10:31:44 +03:00
94060a6443 Merge pull request #846 from mailpoet/transifex_import
Add importing of translations from Transifex [MAILPOET-849]
2017-03-13 18:45:10 +02:00
1cd7c5e876 Update README, force translations downloading, set shell script permissions [MAILPOET-849] 2017-03-13 19:34:17 +03:00
b369cadde0 Merge pull request #841 from mailpoet/post_notification_reschedule
Reschedules sending queues when scheduling options change [MAILPOET-837]
2017-03-13 17:21:03 +02:00
5321a136e7 Add importing of translations from Transifex [MAILPOET-849] 2017-03-13 17:43:56 +03:00
d4c04f29bf Merge pull request #845 from mailpoet/readme_update
Update translations section of readme.txt [MAILPOET-854]
2017-03-13 14:56:47 +02:00
20798d8957 Update translations section of readme.txt [MAILPOET-854] 2017-03-13 12:55:52 +03:00
3cde437628 Adds enforcement of global subcriber subscription status and
subscribption to segments to which newsletter is sent
2017-03-09 20:38:34 -05:00
8db7af48cd Merge pull request #843 from mailpoet/http_build_query_fix
Forces ampersand as query separator for mailers [MAILPOET-850]
2017-03-09 13:40:08 +03:00
d05d033727 Forces ampersand as query separator for mailers 2017-03-08 14:34:35 -05:00
ccba1925b1 Prevents sending to unsubscribed subscribers 2017-03-07 18:55:49 -05:00
b590586d4c Reschedules previously scheduled sending queues when post notification's
scheduling options change
2017-03-07 18:39:55 -05:00
44c742402c Bump up release verison to 3.0.0-beta.22 2017-03-07 17:49:11 +03:00
3a9db95c37 Merge pull request #840 from mailpoet/sending_batch_size_update
Reduces sending batch size [MAILPOET-847]
2017-03-07 16:53:52 +03:00
5d88938d94 Reduces sending batch size 2017-03-06 19:05:14 -05:00
67e0f1776d Merge pull request #839 from mailpoet/mailer_endpoint_update
Prevents setting current user's name to recipient of test email [MAILPOET-846]
2017-03-06 10:38:34 +03:00
5b68febb05 Removes first/last name that's based on current user from being sent to
test e-mail
2017-03-02 17:28:44 -05:00
9bf65ca798 Merge pull request #838 from mailpoet/editor_notices
Fix notices on newsletter editor page to not be absorbed into contents [MAILPOET-811]
2017-03-01 20:38:58 +03:00
d95aa40502 Fix notices on newsletter editor page to not be absorbed into contents 2017-03-01 17:26:17 +02:00
a59bf76fb4 Update version information for 3.0.0-beta.21 release 2017-02-28 14:11:03 +02:00
51fdc7f1df Merge pull request #837 from mailpoet/catch_cron_exceptions
Catches exception thrown by cron dependency and prevents a fatal error [MAILPOET-844]
2017-02-28 13:20:58 +02:00
aa51b751d0 Merge pull request #835 from mailpoet/translations
Fix translations [MAILPOET-841]
2017-02-28 14:08:44 +03:00
aff522c5cd Merge pull request #836 from mailpoet/translation_string_update
Removes unnecessary period [MAILPOET-842]
2017-02-28 12:40:06 +02:00
66d039ace3 Catches exception thrown by cron dependency and prevents a fatal error 2017-02-27 19:21:32 -05:00
ed5e6cdd8c Removes unnecessary period 2017-02-27 12:58:54 -05:00
47f5e1e7b4 Translate color picker actions in newsletter editor 2017-02-27 19:32:08 +02:00
626d6c0fa9 Fix "newsletter was updated successfully" translation 2017-02-27 19:15:29 +02:00
2b45d64695 Make numberOfItems translation singular/plural aware 2017-02-27 18:33:09 +02:00
c27446666e Translate untranslated strings 2017-02-27 18:33:09 +02:00
7f0195378c Merge pull request #833 from mailpoet/stop_daemon_with_sending_is_paused
Stops cron daemon when sending is paused due to an error [MAILPOET-839]
2017-02-27 16:49:55 +03:00
6caa3a069b Merge pull request #832 from mailpoet/mailer_output_escape_fix
Fixes double escaping of HTML entities in mailer output [MAILPOET-836]
2017-02-27 10:52:10 +03:00
baaf73b584 Merge pull request #834 from mailpoet/mailpoet_mailer_php53_fix
Fixes 'Using $this when not in object context' MailPoet mailer error on PHP 5.3 [MAILPOET-840]
2017-02-27 10:19:21 +03:00
b2a92feb50 Restore unnecessary $this replacements [MAILPOET-840] 2017-02-27 10:18:14 +03:00
c11b9677d5 Fixes 'Using $this when not in object context' error on PHP 5.3 2017-02-26 22:08:34 -05:00
0e5a26ce1f Stops cron daemon when sending is paused due to an error 2017-02-26 11:26:59 -05:00
40ec5569d0 Removes "unprocessed subscriber" message since MailPoet's mailer method
processes subscribers in batches of 50 and it makes no sense to display
them all
2017-02-25 10:32:14 -05:00
d14ecc982b Does not display unprocessed subscriber when sending a test message 2017-02-24 11:18:27 -05:00
9c27384ba3 Passes responsibility for mailer error message HTML entity escaping from
server to the client side
2017-02-24 11:06:20 -05:00
2268f0ffa6 Merge pull request #831 from mailpoet/php53_bulk_trash_and_restore_fix
Fix bulk trashing/restoring not working for newsletters/forms on PHP 5.3 [MAILPOET-835]
2017-02-24 13:22:30 +01:00
bfc04bfa87 Fix bulk trashing/restoring not working for newsletters/forms on PHP 5.3 [MAILPOET-835] 2017-02-24 15:10:38 +03:00
37ac31cdac Bumps up release version to 3.0.0-beta.20 and updates changelog 2017-02-23 19:04:55 -05:00
15096d483f Merge pull request #830 from mailpoet/newsletter_save_fix
Fixes newsletter options being wiped on Step 3 of creation process [MAILPOET-833]
2017-02-23 23:51:59 +03:00
16724affad Remove an excess count() [MAILPOET-833] 2017-02-23 23:42:28 +03:00
384d59abe0 Update Newsletters.php
Removes request interruption when options are not found
2017-02-23 15:25:34 -05:00
027414b7a2 Updates method data verification condition 2017-02-23 14:39:56 -05:00
a1cd56c419 Updates newsletter option creation logic and fixes a bug that results in
them being wiped clean
2017-02-23 14:30:53 -05:00
6ee1c23f9a Merge pull request #829 from mailpoet/post_title_shortcode_fix
Fix post_title shortcode breaking sending if the post is trashed in the process [MAILPOET-831]
2017-02-23 14:41:24 +01:00
44a223eba1 Fix post_title shortcode breaking sending if the post is trashed in the process [MAILPOET-831] 2017-02-23 16:33:18 +03:00
7c66754541 Merge pull request #828 from mailpoet/premium_hooks
Premium hooks / Additional endpoints in Free API [PREMIUM-4]
2017-02-23 15:26:30 +02:00
bb80fc0860 Add unit tests for API endpoints injection [PREMIUM-4] 2017-02-22 18:02:58 +03:00
6c7cc5de0d Implement support for additional endpoints in Free API [PREMIUM-4] 2017-02-22 11:19:35 +03:00
063cc9edc3 added do_action() helper to twig + settings/basics hook 2017-02-22 10:12:08 +03:00
76c283502e Bumps up release version to 3.0.0-beta.19 and updates changelog 2017-02-21 11:55:53 -05:00
554add0882 Merge pull request #823 from mailpoet/smtp_mailer_logger_implementation
Provides detailed SMTP error message and shows last unprocessed subscriber [MAILPOET-823]
2017-02-21 18:09:23 +03:00
689c340081 Converts special characters to HTML entities for all error messages 2017-02-21 09:55:18 -05:00
01e4ed7efc Merge pull request #827 from mailpoet/template_screenshots
Newsletter template fixes [MAILPOET-817]
2017-02-21 15:50:06 +01:00
59f408846a Make all default newsletter templates read-only 2017-02-21 16:32:03 +02:00
64606e69cf Fix Populator to update existing newsletter templates and remove duplicates 2017-02-21 15:46:28 +02:00
e8e0c1e0b3 Automatically update SVN /assets folder upon publishing a release 2017-02-21 15:46:28 +02:00
953c124ef0 Move newsletter template assets to be shared through WP plugin repo 2017-02-21 15:46:28 +02:00
2e1be55bf9 Merge pull request #826 from mailpoet/newsletter_restore_fix
Set newsletter status to draft when restoring newsletters trashed during sending [MAILPOET-816]
2017-02-21 13:54:17 +01:00
33125f2ce7 Merge pull request #820 from mailpoet/translations
Fix translations based on translators' feedback [MAILPOET-819]
2017-02-21 13:20:24 +01:00
e99d2b380c Fix a space [MAILPOET-816] 2017-02-21 13:34:33 +03:00
bcf89f0dfe Set newsletter status as draft when restoring newsletters trashed during sending [MAILPOET-816] 2017-02-21 13:13:59 +03:00
3d64a42126 Merge pull request #819 from mailpoet/bulk_delete_custom_fields
Deletes custom fields associations when bulk deleting subscribers [MAILPOET-820]
2017-02-21 11:32:11 +02:00
97eb772ab8 Enables temporarily disabled unit test 2017-02-20 13:17:06 -05:00
bc40bbb44b Convert special characters to HTML entities when displaying email
addresses
2017-02-20 13:03:08 -05:00
ed117e53d9 Adds unit test for bulk delete action 2017-02-20 12:58:26 -05:00
b74f40c7a8 Makes code more readable/cleaner 2017-02-20 09:30:14 -05:00
bf4023c0ad Restores accidentally removed tests 2017-02-20 09:07:18 -05:00
c98cdb3e57 Merge pull request #811 from mailpoet/popups_focus
Focus on popups by default [MAILPOET-724]
2017-02-20 15:36:07 +02:00
a01b094f9f Merge pull request #824 from mailpoet/import_regex_update
Updates email regex from loose HTML5 standard to stricter RFC 5322 [MAILPOET-825]
2017-02-20 16:30:01 +03:00
e75bb7ee59 Capitalize words of a title in welcome template 2017-02-20 15:22:28 +02:00
563c62855a Undo title capitalization changes, as not all languages use it 2017-02-20 14:58:53 +02:00
8a15424a62 Remove "Read more" link to obsolete KB article 2017-02-20 14:58:53 +02:00
8eb04534bc Fixed translations based on feedback from translators on Transifex 2017-02-20 14:58:53 +02:00
b3abf46604 Update outdated newsletter template translation strings 2017-02-20 14:58:53 +02:00
6f19a1593e Fix translations from GDocs based on FxB's feedback [MAILPOET-819] 2017-02-20 14:58:53 +02:00
883711698e Updates email regex from loose HTML5 standard to stricter RFC 5322
that's required by some mail transport agents
2017-02-18 10:33:45 -05:00
bdcfd77d42 Returns last unprocessed subscriber in error message 2017-02-16 23:25:05 -05:00
2cd503e0e0 Merge pull request #822 from mailpoet/php71_button_rendering
Fix button block rendering producing notices on PHP 7.1 [MAILPOET-822]
2017-02-17 05:05:38 +01:00
c9519f0b3d Adds logger to record SMTP communication
Returns a more complete error message and last unprocessed subscriber
2017-02-16 22:45:09 -05:00
0daa3057e7 Focus on all modal types by default [MAILPOET-724] 2017-02-16 21:58:41 +03:00
0ac5129e0e Merge pull request #818 from mailpoet/destroyed_newsletter
Fix newsletter corruption when going back to editor from last newsletter creation step [MAILPOET-787]
2017-02-16 18:39:01 +03:00
a3aa347fdf Fix button block rendering producing notices on PHP 7.1 [MAILPOET-822] 2017-02-16 17:53:36 +03:00
a40d1122a5 Change corrupted newsletter notice to a static (dismissable) one 2017-02-16 11:21:01 +02:00
9955b8fda1 Merge pull request #821 from mailpoet/php53_fix
Replaces references to self::$variable with Class:$variable for PHP 5.3 hosts [MAILPOET-821]
2017-02-16 11:53:34 +03:00
c994438fa8 Replace more self:: references in closures for PHP 5.3 [MAILPOET-821] 2017-02-16 11:22:26 +03:00
3085ae575a Replaces references to self::$variable with Class:$variable for PHP 5.3
hosts
2017-02-15 18:27:52 -05:00
793b8ce29e Deletes custom fields associations when bulk deleting subscribers 2017-02-15 15:40:26 -05:00
5d447cdec3 Merge pull request #817 from mailpoet/large_list_sending_fix
Fixes DB query that returns large result set when there are thousands of subscribers [MAILPOET-815]
2017-02-15 19:01:26 +02:00
e7698b0131 Optimizes DB query and result processing code 2017-02-15 10:02:13 -05:00
f86121b656 Update the error message to a clearer one 2017-02-15 15:05:30 +02:00
45c223c14b Fix newsletter corruption when going back to editor from last newsletter step 2017-02-15 15:04:07 +02:00
66990d62c2 Restore focus on previously focused element after closing a modal box [MAILPOET-724] 2017-02-15 10:09:14 +03:00
4439111a44 Focus on popups by default [MAILPOET-724] 2017-02-15 10:09:14 +03:00
440b7e4e6c Fixes DB query that returns large result set when there are thousands of
subscribers
2017-02-14 21:07:40 -05:00
b90d7894ca Bump up release version to 3.0.0-beta.18 2017-02-14 17:49:48 +03:00
a0b37eb08c Merge pull request #810 from mailpoet/list_stats_fix
Fix subscriber stats for lists ignoring subscription status and including trashed items [MAILPOET-807]
2017-02-14 14:27:59 +01:00
44b83436bc Merge pull request #809 from mailpoet/view_plans_button_utm
Add GA UTM params to 'View Email Plans' link in Settings [MAILPOET-806]
2017-02-14 13:54:55 +01:00
0d75ee0e12 Merge pull request #816 from mailpoet/utf8_renderer_fix
Fixed UTF-8 encoding in renderer on PHP 5.3 [MAILPOET-812]
2017-02-14 12:39:53 +03:00
50d77f2aff Merge pull request #814 from mailpoet/robo_upgrade
Update Robo from 0.7.2 to 1.0.5 [MAILPOET-813]
2017-02-14 11:22:56 +02:00
cb813171ce Remove html_entity_decode() constants not supported by PHP 5.3 [MAILPOET-812] 2017-02-14 12:22:35 +03:00
3f188e3690 Updates lint rules to ignore pQuery class (name not in camel case caps,
etc.)
2017-02-13 21:00:46 -05:00
e74938df90 Updates code to use the extended pQuery class 2017-02-13 21:00:45 -05:00
93f7739f46 Extends pQuery to use UTF-8 encoding on older versions of PHP 2017-02-13 21:00:32 -05:00
a918091977 Merge pull request #815 from mailpoet/sendgrid_fix
Fixes SendGrid's error response [MAILPOET-810]
2017-02-13 10:51:34 +03:00
b539eae7f9 Fix SendGrid error message assignment [MAILPOET-810] 2017-02-13 10:35:21 +03:00
228a671749 Converts SendGrid's error response message from array to string 2017-02-11 05:41:02 -05:00
70fe253db3 Update Robo from 0.7.2 to 1.0.5 2017-02-09 19:08:04 +03:00
bdb97261fd Merge pull request #813 from mailpoet/alc_categories_fix
Fix categories not showing for posts in newsletter editor [MAILPOET-808]
2017-02-09 06:23:01 -05:00
8507c77699 Fix categories not showing for posts in newsletter editor [MAILPOET-808] 2017-02-09 11:13:46 +03:00
771ff134a8 Merge pull request #812 from mailpoet/create_form_in_widget_fix
Fix 'Create a new form' link on widgets page having no feedback [MAILPOET-691]
2017-02-08 11:05:23 -05:00
9c1cbba163 Fix 'Create a new form' link on widgets page having no feedback [MAILPOET-691] 2017-02-08 13:30:49 +03:00
f51122b58f Fix subscriber stats for lists ignoring subscription status and including trashed items [MAILPOET-807] 2017-02-06 16:04:16 +03:00
e8fd992235 Add GA UTM params to 'View Email Plans' link in Settings [MAILPOET-806] 2017-02-06 12:56:39 +03:00
e126278e32 Bump up the release version to 3.0.0-beta.17 2017-02-02 17:47:21 +03:00
9d2651083d Merge pull request #808 from mailpoet/translation_plugin
Whitelist translation plugin [MAILPOET-805]
2017-02-02 15:48:02 +03:00
1e1ae4c3cf Whitelist translation handling plugin's admin assets on MP pages
[MAILPOET-805]
2017-02-02 14:10:57 +02:00
385f5ab535 Merge pull request #807 from mailpoet/sending_svc_subscriber_count
Add subscriber count reporting on Sending Service key validation [MAILPOET-804]
2017-02-02 13:19:39 +02:00
dc371d76ca Rework subscriber count reporting after a code review [MAILPOET-804]
Move updateSubscriberCount() out of checkKey()
Move wp_remote_post() to request()
Simplify a response check
2017-02-01 21:04:11 +03:00
be0c9b71d8 Add subscriber count reporting on Sending Service key validation [MAILPOET-804] 2017-02-01 15:58:49 +03:00
6e250d9317 Merge pull request #806 from mailpoet/update_sending_methods_strings
Update sending method descriptions for the new shop [MAILPOET-794]
2017-02-01 13:54:52 +02:00
afeaa00fc7 Merge branch 'master' into update_sending_methods_strings 2017-02-01 14:33:05 +03:00
6575d1579d Merge pull request #796 from mailpoet/sending_svc_api_consolidation
Consolidate Sending Service API calls in one class [MAILPOET-795]
2017-02-01 13:29:34 +02:00
282199d362 Merge pull request #784 from mailpoet/sending_svc_key_validation
Add sending service key validation [MAILPOET-743]
2017-02-01 13:29:08 +02:00
3e5c46e8f3 Cut the text to fit in a smaller box [MAILPOET-794] 2017-02-01 13:11:48 +03:00
71515f3ff0 Updated changelog to fix WP plugin repo parsing 2017-01-31 17:24:35 +02:00
934a8d5bf8 Update changelog 2017-01-31 16:44:14 +02:00
6be2464c86 Fix build script to include mailpoet_initializer.php in the build 2017-01-31 14:54:39 +02:00
ace8a52262 Update release information for 3.0.0-beta.16 2017-01-31 14:20:30 +02:00
7d37d279cd Merge pull request #805 from mailpoet/translations
Translations update
2017-01-30 18:18:22 -05:00
5525a959a8 Fix remaining unit tests after translation changes 2017-01-30 21:50:22 +02:00
a421dbd674 Fix tests 2017-01-30 21:35:49 +02:00
bedfc4f80c Add context to 'Select' translation strings 2017-01-30 21:35:49 +02:00
af2a6b2559 Fix parsing of starting and ending translation string quotes 2017-01-30 21:35:49 +02:00
cb8c32e171 Add 'Move to trash' to separate noun from verb for certain languages 2017-01-30 21:35:49 +02:00
8abec208fc Rewritten some translation strings 2017-01-30 21:35:49 +02:00
5264cb1cf4 Split firstname and lastname into two words 2017-01-30 21:33:59 +02:00
47e0e1a836 Add one and remove two spaces 2017-01-30 21:33:59 +02:00
e602612cd6 Add missing hyphens 2017-01-30 21:33:59 +02:00
9f7ae122e3 Add missing periods to translation strings 2017-01-30 21:33:59 +02:00
22caba31e3 Update sending method strings for the new shop [MAILPOET-794] 2017-01-30 13:44:26 +03:00
82ab4acb8d Improve key validation messages handling [MAILPOET-743]
Hide error messages when the sending method is changed
Verify key and display a message when saving settings
2017-01-30 13:32:43 +03:00
9466be4793 Merge pull request #804 from mailpoet/requirement_check_update
Fixes PDO extension check condition [MAILPOET-800 ]
2017-01-30 11:04:09 +03:00
a2e2090cbb Update KB link in the main plugin file 2017-01-30 10:41:11 +03:00
d100d61403 Updates KB links 2017-01-28 11:07:41 -05:00
d781ef6d01 Fixes scheduler test that fails on last Saturday 2017-01-28 11:07:26 -05:00
1dafc4da04 Adds CSS Parser to the list of vendor classes 2017-01-27 19:05:44 -05:00
063c271e40 Fixes PDO extension check condition 2017-01-27 18:49:33 -05:00
a53007e30b Merge pull request #803 from mailpoet/conflict_resolver_fix
Fixes fatal error on PHP 5.3 [MAILPOET-798]
2017-01-27 20:17:10 +03:00
c616b3299a Reverts to the use of public class property and introduces ugliness of
$_this
2017-01-27 11:51:26 -05:00
86eab0d8f8 Merge pull request #802 from mailpoet/conflict_resolver_fix
Fixes fatal error on PHP 5.3 [MAILPOET-798]
2017-01-27 19:38:12 +03:00
bfd35b1cdc Changes class variable to static; prevents
Fixed 'using $this when not in object contex' error on PHP 5.3
2017-01-27 09:12:31 -05:00
461203279b Consolidate Sending Service API calls in one class [MAILPOET-795] 2017-01-27 16:35:12 +03:00
b9c45b46ba Remove a duplicate function [MAILPOET-743] 2017-01-27 16:28:58 +03:00
1a42ae4cca Fix a unit test [MAILPOET-743] 2017-01-27 16:22:12 +03:00
f2ad7ee34c Fix code style [MAILPOET-743] 2017-01-27 16:22:12 +03:00
37017ef69d Fix appearance and logic of some key validation messages [MAILPOET-743] 2017-01-27 16:22:12 +03:00
157725c300 Fix a string for an expiring key [MAILPOET-743] 2017-01-27 16:22:12 +03:00
98d6f55a6e Tweak Sending Service key validation after a code review [MAILPOET-743]
* Abstract key state to unbound it from the API response codes
* Rename SendingServiceKeyCheck task for clarity
* Add a setter for the API key in the Bridge API class
* Make some smaller fixes
2017-01-27 16:22:11 +03:00
425d45a862 Remove unused imports from Cron tests [MAILPOET-743] 2017-01-27 16:22:11 +03:00
438b4fb1ec Add unit tests [MAILPOET-743] 2017-01-27 16:22:09 +03:00
1f91d40def Add sending service key validation [MAILPOET-743] 2017-01-27 16:20:26 +03:00
c5e1def2f9 Merge pull request #801 from mailpoet/list-unsubscribe_header
Add List-Unsubscribe header to emails [MAILPOET-793]
2017-01-26 17:51:33 -05:00
65ba834742 Merge pull request #800 from mailpoet/forms_listing_copy_fix
Fix a string displayed when there are no forms [MAILPOET-738]
2017-01-26 17:40:12 -05:00
19dc048858 Remove unused imports [MAILPOET-793] 2017-01-26 21:11:39 +03:00
938279bf8f Remove unsubscribe link generation from Mailer - to be solved in another task [MAILPOET-793] 2017-01-26 21:07:03 +03:00
dd2df429ef Add List-Unsubscribe header to emails [MAILPOET-793]
Amazon SES supports custom headers only via 'SendRawEmail' action
MailPoet Sending Service doesn't support custom headers yet
2017-01-26 15:38:23 +03:00
c4e05912ff Fix a string displayed when there are no forms [MAILPOET-738] 2017-01-26 11:19:23 +03:00
bb34e8477f Merge pull request #799 from mailpoet/welcome_email_preview_fix
Prevents previewing of sent welcome emails [MAILPOET-796]
2017-01-26 11:10:11 +03:00
32f7d7771f Prevents previewing of sent welcome emails 2017-01-25 19:06:35 -05:00
e77717c4c2 Merge pull request #798 from mailpoet/form_segments_fix
Filter lists that can be subscribed to using any particular form [MAILPOET-777]
2017-01-25 18:34:30 -05:00
d27d5ae5dd Merge pull request #797 from mailpoet/form_fields_filter
Fix fubscription form failing when some fields are absent or don't ex…
2017-01-25 17:48:48 -05:00
168263f0ea Fix code style [MAILPOET-777] 2017-01-25 16:29:23 +03:00
f1ced11809 Remove leading slashes in unit test imports [MAILPOET-764] 2017-01-25 16:28:36 +03:00
c2546e8aed Filter lists that can be subscribed to using any particular form [MAILPOET-777] 2017-01-25 16:15:42 +03:00
b7ef191641 Remove leading slashes in imports [MAILPOET-764] 2017-01-25 10:22:27 +03:00
2220a13399 Remove unused imports [MAILPOET-764] 2017-01-25 10:14:38 +03:00
31ec7475c8 - Bumps up release version to Beta 15
- Updates changelog
- Cleans up code comments in the main mailpoet.php file
2017-01-24 13:20:08 -05:00
bfdc13a8d1 Fix fubscription form failing when some fields are absent or don't exist [MAILPOET-764] 2017-01-24 21:12:56 +03:00
9a3c4ff7de Merge pull request #794 from mailpoet/initial_requirements_check
Updated plugin initialization logic [MAILPOET-790]
2017-01-23 18:45:41 +02:00
25410eb09c - Prefixes functions 2017-01-23 11:08:36 -05:00
122f88668a - Removes anonymous functions not supported on PHP 5.2 2017-01-23 11:07:29 -05:00
9c35eb9723 - Moves plugin initialization into a separate file that's included after
PHP version and core dependency checks are run
2017-01-23 09:05:21 -05:00
fa528ed1ff Merge pull request #795 from mailpoet/preview_link_update
Allows sharing of newsletter preview links [MAILPOET-791]
2017-01-23 15:52:11 +03:00
1a7623bc4a - Adds unit tests 2017-01-20 09:24:45 -05:00
3a4a37e1af - Sets subscriber to the logged in WP user when subscriber is not found 2017-01-20 09:16:43 -05:00
888a566dda - Includes newsletter hash in preview URLs thus not requiring user
validation
2017-01-20 09:16:43 -05:00
3567779faf Merge pull request #792 from mailpoet/remove_all_lists_fix
Fix 'Subscribers without a list' filter not showing unsubscribed subscribers [MAILPOET-789]
2017-01-19 20:47:58 -05:00
cb5b0bd753 - Removes PHP version check that's been moved to the main plugin file 2017-01-19 20:29:03 -05:00
88d0511adb - Loads autoloader class and initializes the plugin 2017-01-19 20:29:02 -05:00
a4a654cfd5 - Removes the use of namespace to ensure PHP 5.2 compatibility
- Adds a PHP version check and disabled the plugin if the check fails
- Adds a check for Initializer and autoload core files
- Moves plugin initialization logic outside to the Initializer class
2017-01-19 20:28:57 -05:00
4d3c90ce0d Exclude trashed and multiple-list subscribers [MAILPOET-789] 2017-01-19 23:04:29 +03:00
f51aba4dbd Bumps up release version to Beta 14
Updates changelog
2017-01-19 12:30:17 -05:00
f651c06cb9 Merge pull request #793 from mailpoet/conflict_resolver_fix
Replaces reliance on style/script names with asset location [MAILPOET-723]
2017-01-19 18:35:20 +02:00
940328c608 - Updates assets locations to more precise names 2017-01-19 11:26:32 -05:00
ce85600753 Merge pull request #789 from mailpoet/build_sh_update
Update tests and risky files removal in build.sh
2017-01-19 10:24:27 -05:00
5666116645 - Replaces reliance on style/script names with asset location
- Updates unit tests
2017-01-19 10:20:22 -05:00
815461a851 Add a unit test [MAILPOET-789] 2017-01-19 17:37:01 +03:00
1102467e39 Fix 'Subscribers without a list' filter not showing unsubscribed subscribers [MAILPOET-789] 2017-01-19 17:36:28 +03:00
a5ee865271 Merge pull request #790 from mailpoet/remove_all_lists_fix
Fix all lists removal when editing subscribers [MAILPOET-726]
2017-01-18 20:25:25 -05:00
59bda6cf6c Merge pull request #791 from mailpoet/first_last_names_fix
Fix MySQL strict mode error when saving a subscriber without first or…
2017-01-18 20:14:42 -05:00
a4d9d55b09 Fix code style [MAILPOET-780] 2017-01-18 19:37:16 +03:00
8cf918013d Fix MySQL strict mode error when saving a subscriber without first or last name [MAILPOET-780] 2017-01-18 19:06:33 +03:00
7789a10026 Fix code style [MAILPOET-726] 2017-01-18 15:47:16 +03:00
ce0ad33c32 Fix all lists removal when editing subscribers [MAILPOET-726] 2017-01-18 15:33:20 +03:00
63d1fe17a9 Merge pull request #788 from mailpoet/mysql_timeout_fix
Updates MySQL unit test condition
2017-01-17 21:30:57 +03:00
da92795635 Update tests and risky files removal in build.sh 2017-01-17 21:17:02 +03:00
915f8b5865 - Updates test condition 2017-01-17 13:03:02 -05:00
8ae939080b Bump up plugin version to 3.0.0-beta.13 2017-01-17 20:25:57 +03:00
610f74343c Merge pull request #787 from mailpoet/mysql_timeout_fix
Updates MySQL wait_timeout configuration logic [MAILPOET-786]
2017-01-17 20:21:05 +03:00
4de03db125 - Updates test condition 2017-01-17 11:59:22 -05:00
f734d47b26 - Extracts database configuration into a separate class
- Conditionally sets the session wait_timeout value
- Updates unit tests
2017-01-17 11:23:00 -05:00
9e879d0539 Merge pull request #786 from mailpoet/conflict_resolver_test_update
Fixes conflict resolver unit tests [MAILPOET-723]
2017-01-17 16:45:44 +03:00
ff6dffd626 Merge pull request #785 from mailpoet/form_css_fix
Fix Windows line breaks compatibility in unit test [MAILPOET-784]
2017-01-17 08:32:33 -05:00
efe187953c - Mocks a list of permitted assets 2017-01-17 08:30:51 -05:00
ab8a503a48 Fix Windows line breaks compatibility in unit test [MAILPOET-784] 2017-01-17 15:53:15 +03:00
81d91188ac Merge pull request #782 from mailpoet/conflict_resolution_implementation
Unloads all scripts/styles that are not loaded by default by WP in admin panel [MAILPOET-723]
2017-01-16 17:30:03 +02:00
d3353b793f Merge pull request #783 from mailpoet/mysql_timeout_fix
Increases MySQL timeout limit [MAILPOET-786]
2017-01-16 17:21:49 +03:00
625f828cce - Sets MySQL timeout to 60 seconds 2017-01-16 09:07:34 -05:00
c90dd94cf3 Merge pull request #781 from mailpoet/form_css_fix
Fixes some from CSS styles not being saved [MAILPOET-784]
2017-01-16 15:28:42 +02:00
a851527ff5 - Unloads all scripts/styles that are not loaded by default by WP in
admin panel
2017-01-15 15:35:48 -05:00
76e292f494 - Fixes test when premium unlocker is enabled 2017-01-13 18:03:25 -05:00
ed886280de - Rewrites the CSS styles processor/renderer class
- Adds unit tests
2017-01-13 13:16:57 -05:00
f3b2db48c4 - Add new dependency library used to parse CSS rules 2017-01-13 13:16:56 -05:00
b60c758281 Merge pull request #780 from mailpoet/conflict_resolution_implementation
Resolves client- and server-side conflicts with other plugins [MAILPOET-769] [MAILPOET-723]
2017-01-13 13:32:32 +02:00
b758284df7 - Fixes unit test 2017-01-12 17:49:28 -05:00
c6d43099a1 - Extracts check for current plugin page into a separate method 2017-01-12 17:48:42 -05:00
fde283dd56 Merge pull request #778 from mailpoet/settings_typo_fix
Corrects typo in subscription management shortcode [MAILPOET-783]
2017-01-12 22:22:35 +03:00
5800883416 - Updates action names 2017-01-11 21:18:37 -05:00
39a6318105 - Adds scipts/styles conflict resolver and executes it only on MailPoet
admin menu pages
- Adds unit tests
2017-01-11 20:52:03 -05:00
4196d35e35 - Adds new ConflictResolver class
- Executes URL query parameter conflict resolver action in Router class
- Adds unit tests
2017-01-11 20:52:03 -05:00
c0653ce26c - Corrects typo in subscription management shortcode 2017-01-11 13:58:50 -05:00
131f12d19e Update changelog and version for release 3.0.0-beta.12 2017-01-10 13:13:30 +02:00
3e734b5c44 Merge pull request #776 from mailpoet/js_conflict
Load MailPoet assets only on Widgets admin page [MAILPOET-740]
2017-01-09 15:38:52 -05:00
76a41d53d6 Remove unused dependencies from I18n and newsletter editor scripts 2017-01-09 22:35:40 +02:00
43cb03105b Change MailPoet JS assets to be loaded only on Admin Widgets page 2017-01-09 22:35:40 +02:00
3647f70daa Merge pull request #768 from mailpoet/date_display_fix
Updates date:dtext shortcode to display full day name [MAILPOET-772]
2017-01-09 19:36:27 +02:00
5956a200ea Merge pull request #770 from mailpoet/newsletter_preview_by_email_send_error_update
Fixes mailer error message not being displayed when sending newsletter preview [MAILPOET-773]
2017-01-09 18:07:52 +03:00
449eb28b2a - Updates code formatting 2017-01-09 09:37:56 -05:00
912fca0e73 Merge pull request #775 from mailpoet/emails_listing_performance_fix
Add queue_id index names [MAILPOET-746]
2017-01-09 09:11:11 -05:00
a3f2c32a6d - Adds custom date format as a shortcode action's argument
- Updates shortcodes logic to allow action arguments other than
"default"
2017-01-09 09:05:24 -05:00
e175e63a7c Merge pull request #771 from mailpoet/hooks_update
Updates hooks logic [MAILPOET-771]
2017-01-09 15:16:47 +02:00
bfe898aae8 Merge pull request #774 from mailpoet/cron_daemon_ping
New "ping" cron daemon router endpoint [MAILPOET-779]
2017-01-09 15:42:18 +03:00
099c2a390d Merge pull request #772 from mailpoet/ALC_update
Adds post ID data tag to ALC posts displayed as a list [MAILPOET-775]
2017-01-09 11:57:35 +03:00
8fe57ff57f Merge branch 'master' into emails_listing_performance_fix 2017-01-09 11:27:35 +03:00
6dc9f9d2ab Add queue_id index names [MAILPOET-746] 2017-01-09 11:14:38 +03:00
5463dd10e2 Merge pull request #769 from mailpoet/sender_email_header
Sets "sender" email header for SMTP/PHPMail methods [MAILPOET-774]
2017-01-09 11:02:46 +03:00
b8c56623a6 Update unit tests [MAILPOET-774] 2017-01-09 10:55:36 +03:00
a6b00e1ba7 - Adds new "ping" cron daemon router endpoint
- Removes the requirement to have data payload for router requests
2017-01-08 22:25:39 -05:00
aa0078e5e4 - Fixes CircleCI's Apache configuration. Error: "Client denied by server
configuration"
2017-01-08 21:58:28 -05:00
714f81d936 - Moves hooks setup to wp_load action
- Adds post notification scheduler to all post types
2017-01-08 17:27:02 -05:00
497c2fb595 - Introduces shortcode to custom format dates 2017-01-06 21:29:05 -05:00
c291fada74 - Adds post ID data tag when ALC is configured to display posts as a
list
2017-01-05 13:24:41 -05:00
e4166cecba - Updates date:dtext shortcode to display full day name 2017-01-04 13:06:29 -05:00
3a1568a31d - Fixes mailer error message not being displayed when newsletter preview
sending fails
2017-01-04 13:04:53 -05:00
02a5de0cd6 - Sets "sender" email header for SMTP/PHPMail methods 2017-01-04 10:22:17 -05:00
f5dce907ff Merge pull request #767 from mailpoet/2017_unit_tests
Fix hardcoded year in unit tests [MAILPOET-767]
2017-01-02 18:56:50 -05:00
2692c7c7dd Fix unit test using hardcoded year to work in 2017 2017-01-02 13:52:05 +02:00
4cfe3c534c Merge pull request #766 from mailpoet/emails_listing_performance_fix
Add indexes for even more speedy statistics retrieval [MAILPOET-746]
2016-12-31 14:22:15 -05:00
f8d78d87af Add indexes for even more speedy statistics retrieval [MAILPOET-746] 2016-12-31 22:19:51 +03:00
3b6e06eccb - Bumps up release version to 3.0.0-beta.11
- Updates changelog
2016-12-31 13:44:18 -05:00
09b2246186 Merge pull request #764 from mailpoet/emails_listing_performance_fix
Rewrite newsletter statistics query, remove redundant queue data from…
2016-12-31 13:34:22 -05:00
af83b02129 Merge pull request #765 from mailpoet/premium_plugin_unit_test
Fixes subscriber limit unit test when premium plugin is active
2016-12-31 19:33:14 +03:00
093fd2f082 Rename variables in unit test [MAILPOET-746] 2016-12-31 19:28:02 +03:00
c24d8135aa - Fixes subscriber limit unit test when premium plugin is active 2016-12-31 10:26:58 -05:00
41fdc3af13 Rewrite newsletter statistics query, remove redundant queue data from the server response [MAILPOET-746] 2016-12-31 13:14:10 +03:00
ec9417d293 Merge pull request #763 from mailpoet/logo_border_fix
Removes 1px border around logo in the welcome page
2016-12-30 20:24:36 +03:00
6eb78b5bf7 - Removes 1px border around logo on welcome/update pages that's introduced
by WP 4.7
2016-12-30 12:07:33 -05:00
877e110188 Merge pull request #762 from mailpoet/newsletter_preview_send_fix
Fixes newsletter send preview [MAILPOET-765]
2016-12-30 19:08:05 +03:00
e6d909da21 - Updates unit test 2016-12-30 10:59:37 -05:00
c26a3f704b Merge pull request #760 from mailpoet/rendering_fix
Fix ALC/regular posts being displayed without line breaks [MAILPOET-763]
2016-12-30 18:42:08 +03:00
9425e390c5 Merge pull request #761 from mailpoet/existing_subscriber_update
Update subscriber data on repeated subscriptions [MAILPOET-760]
2016-12-30 10:32:06 -05:00
698cdecbfe - Conditionally keeps margin/padding for ALC posts inside editor
- Adds line breaks for ALC posts in the renderer
2016-12-30 10:17:43 -05:00
d5a1d94bca Wipe unconfirmed subscriber data during import [MAILPOET-760] 2016-12-30 10:53:29 +03:00
4f37a44363 - Fixes newsletter preview not being sent
- Adds unit test
2016-12-29 18:46:22 -05:00
95f8f130ea Update subscriber data on repeated subscriptions [MAILPOET-760] 2016-12-29 15:29:32 +03:00
fb29800c7d - Replaces line breaks with empty paragraphs 2016-12-28 19:30:52 -05:00
d2b41a5b90 - Bumps up release version to 3.0.0-beta.10
- Updates changelog
2016-12-27 17:29:42 -05:00
71db3e569d Merge pull request #759 from mailpoet/deleted_lists_fix
Show deleted lists in newsletter listings [MAILPOET-489]
2016-12-27 11:26:59 -05:00
9a8f028a01 Fix code style [MAILPOET-489] 2016-12-27 19:16:18 +03:00
2c5e73305a Show deleted lists in newsletter listings [MAILPOET-489] 2016-12-27 13:13:05 +03:00
90e7026355 Merge pull request #739 from mailpoet/archives_shortcode_fix
Fixes archives shortcode and ability to manage subscription/unsubscribe [MAILPOET-737]
2016-12-27 09:39:15 +03:00
d63ab6a927 - Uses newsletter hash over id when looking for a newsletter 2016-12-26 19:42:00 -05:00
e5cf57e4f8 Merge pull request #756 from mailpoet/save_before_send_preview
Save newsletter before sending preview [MAILPOET-702]
2016-12-25 16:17:41 -05:00
6beada63de - Allows administrators to preview all newsletters
- Allows non-administrators to preview newsletters only when newsletter
hash is specified
2016-12-25 16:07:33 -05:00
6699b52184 Merge pull request #758 from mailpoet/return_path_implementation
Implements return path for SMTP/PHPMail/AmazonSES [MAILPOET-761]
2016-12-23 19:32:08 +03:00
c651a8bbe8 - Implements return path for SMTP/PHPMail/AmazonSES 2016-12-23 11:09:10 -05:00
4a171dca2d Merge pull request #757 from mailpoet/date_fix
Fixes date formatting [MAILPOET-759]
2016-12-23 15:20:10 +03:00
f821a60a2c - Removes open tracking code URL when newsletter is previewed 2016-12-22 22:58:43 -05:00
24a3866e2a Merge pull request #755 from mailpoet/svn_publish_improve
Improve SVN publish command [MAILPOET-758]
2016-12-22 21:14:34 -05:00
fc54f31d3d - Prevents viewing newsletters if subscriber does not exist and token
does not match
2016-12-22 21:13:21 -05:00
616883ed63 - Fixes date formatting 2016-12-22 15:29:00 -05:00
b6ce513927 Save newsletter before sending preview [MAILPOET-702] 2016-12-22 21:56:34 +03:00
456152b5cb Merge pull request #753 from mailpoet/bounced_option_on_subscription_page
Display 'bounced' option on subscription page only if the user is bounced…
2016-12-22 09:34:00 -05:00
0be790971a Merge pull request #754 from mailpoet/utf8_fix
Removes setting DB character set to utf8 [MAILPOET-757]
2016-12-22 10:27:03 +03:00
e255484bc8 Quote path in awk command for Windows compatibility [MAILPOET-758] 2016-12-22 10:16:15 +03:00
fc53aca31d Remove database dependency for SVN publish task [MAILPOET-758] 2016-12-22 10:04:28 +03:00
31116a7cf6 - Removes setting DB character set to utf8 2016-12-21 18:21:36 -05:00
ee0c824126 Add form select block unit test 2016-12-21 21:22:52 +03:00
9ee66160ec Display 'bounced' option on subscription page only if user is bounced and make it disabled [MAILPOET-754] 2016-12-21 21:04:28 +03:00
bc91b12cf3 Bump up release version to 3.0.0-beta.9 2016-12-20 19:39:15 +03:00
457c43cd77 Merge pull request #752 from mailpoet/mysql_fix
MySQL configuration fix [MAILPOET-755]
2016-12-20 19:14:52 +03:00
949d6033d7 - Fixes DB configuration being partially set 2016-12-20 10:14:04 -05:00
cad6391fc6 - Updates the format of db timezone offset to two-digit hours and minutes 2016-12-20 10:13:11 -05:00
e5e5e7b426 - Fixes preview of unsent post notifications 2016-12-19 19:19:51 -05:00
9095482af2 - Updates unit tests 2016-12-18 23:24:58 -05:00
9698cf2d2e - Optimizes ViewInBrowser router endpoint
- Optimizes ViewInBrowser class
- Optimizes and updates shortcode link category to use the refactored
  getViewInBrowserUrl() method
- Updates Shortcodes to use the refactored getViewInBrowserUrl() method
2016-12-18 23:24:57 -05:00
707afc2ae0 - Adds a new method to create a URL data object as a numeric array instead
of associative, thus reducing the size of the object
- Adds a new method to convert numeric URL data object array into associative array
- Preserves backward compatibility with previous MP3 Beta versions by checking if the
  URL data object is already an associative array
- Adds different types of newsletter display
2016-12-18 23:24:50 -05:00
3b795a3e58 - Prevents deleted newsletters from showing up in archives
- Adds a relationship to the sending queue table
- Resets hash on newsletter duplication and notification history creation
- Updates hash generation to use random string instead of newsletter id
2016-12-18 23:08:08 -05:00
062f849fc8 - Isolates shortcodes regex into a class method
- Adds a new method to create a URL data object as a numeric array instead
  of associative, thus reducing the size of the object
- Adds a new method to convert numeric URL data object array into associative
  array
- Preserves backward compatibility with previous MP3 Beta versions
  by checking if the URL data object is already an associative array
2016-12-18 23:08:08 -05:00
98c6c29716 - Limits the length of subscriber token to allow for smaller URL data
objects
2016-12-18 23:08:07 -05:00
b4da3ecfb3 - Updates post processing filter naming convention
- Allows returning of text or html rendered body from the renderer
2016-12-18 23:08:07 -05:00
709f45941a - Allows returning of text or html rendered body from the sending queue
model
2016-12-18 23:08:07 -05:00
9ac4c3de72 - Adds new "hash" column to the newsletters table
- Updates newsletter model to automatically generate hash when saving
  newsletter
- Adds new getByHash method to the newsletter model
2016-12-18 23:08:07 -05:00
eee22227b3 - Removes unused class import
- Fixes newsletter URL generation in archive shortcode
- Disables generation of subscription management/unsubscribe/view in
  browser shortcodes when newsletter is previewed
2016-12-18 23:08:07 -05:00
edcce542c3 Merge pull request #747 from mailpoet/svn_push_command
Add a command to push new release to WP SVN [MAILPOET-673]
2016-12-16 14:50:37 +02:00
a354a380ba Merge pull request #749 from mailpoet/change_dup_import_msg
Change no subscribers added/updated string [MAILPOET-741]
2016-12-16 07:46:49 -05:00
54eb667654 Merge pull request #751 from mailpoet/makepot
Makepot task fix [MAILPOET-742]
2016-12-16 15:24:58 +03:00
10207112bc Fix regex matching __() function 2016-12-16 12:23:06 +02:00
892eea238f Merge pull request #750 from mailpoet/fix_bounce_api_response_code
Change bounce API OK response code from 201 to 200 [MAILPOET-747]
2016-12-15 17:24:09 -05:00
e6bb1666ee Remove obsolete wysija-newsletters gettext domain 2016-12-15 20:24:04 +02:00
2be9985d20 Fix finding __() and _n() i18n function calls 2016-12-15 20:24:04 +02:00
f4b7acca1e Fix parsing function call arguments when arg strings contain commas 2016-12-15 20:24:04 +02:00
de9d3655f0 Change bounce API OK response code from 201 to 200 [MAILPOET-747] 2016-12-15 19:49:39 +03:00
dfa13726e7 Add force mode to svn:publish command, add svn:checkout command 2016-12-15 16:20:12 +03:00
61ab583030 Merge pull request #748 from mailpoet/bump_wp_tested_to_4.7
Bump 'Tested up to' and 'Requires at least' versions [MAILPOET-744]
2016-12-15 12:20:19 +02:00
6954501915 Change no subscribers added/updated string [MAILPOET-741] 2016-12-15 12:02:06 +03:00
45a8103322 Bump 'Tested up to' and 'Requires at least' versions [MAILPOET-744] 2016-12-15 11:52:21 +03:00
c4896f4662 Merge pull request #746 from mailpoet/ALC_title_alignment
Fixes alignment not working for ALC titles [MAILPOET-734]
2016-12-15 10:59:23 +03:00
71711b4a0d Add a command to push new release to WP SVN 2016-12-14 18:24:41 +03:00
2634b606f6 - Fixes ALC transformer class to append style tags with semicolon 2016-12-13 19:32:50 -05:00
429 changed files with 15669 additions and 4206 deletions

View File

@ -8,8 +8,7 @@ Listen 8080
LogLevel notice
<Directory /home/ubuntu/mailpoet/wordpress>
AllowOverride All
Allow from All
Require all granted
</Directory>
</VirtualHost>

View File

@ -13,4 +13,7 @@ WP_TEST_MAILER_MAILPOET_API=""
WP_TEST_MAILER_SENDGRID_API=""
WP_TEST_MAILER_SMTP_HOST=""
WP_TEST_MAILER_SMTP_LOGIN=""
WP_TEST_MAILER_SMTP_PASSWORD=""
WP_TEST_MAILER_SMTP_PASSWORD=""
WP_SVN_USERNAME=""
WP_SVN_PASSWORD=""
WP_TRANSIFEX_API_TOKEN=""

42
.gitignore vendored
View File

@ -1,20 +1,22 @@
.DS_Store
TODO
composer.phar
/vendor
tests/_output/*
tests/acceptance.suite.yml
tests/_support/_generated/*
node_modules
.env
npm-debug.log
!tasks/**
/views/cache/**
temp
.idea
mailpoet.zip
tests/javascript/testBundles
assets/css/*.css
assets/js/*.js
.vagrant
lang
.DS_Store
TODO
composer.phar
/vendor
tests/_output/*
tests/acceptance.suite.yml
tests/_support/_generated/*
node_modules
.env
npm-debug.log
!tasks/**
/views/cache/**
temp
.idea
mailpoet.zip
tests/javascript/testBundles
assets/css/*.css
assets/js/*.js
.vagrant
lang
.mp_svn
/nbproject/

9
.tx/config Normal file
View File

@ -0,0 +1,9 @@
[main]
host = https://www.transifex.com
[mp3.mailpoet]
source_file = lang/mailpoet.pot
file_filter = lang/mailpoet-<lang>.po
source_lang = en_US
type = PO
minimum_perc = 75

View File

@ -5,30 +5,32 @@
- CamelCase for classes.
- camelCase for methods.
- snake_case for variables and class properties.
- Max line length at 80 chars.
- Classes can be no longer than 100 LOC.
- Methods can be no longer than 5 LOC.
- Pass no more than 4 parameters/hash keys into a method.
- Composition over Inheritance.
- Comments are a code smell.
- Routes can instantiate only one object.
- Comments are a code smell. If you need to use a comment - see if same idea can be achieved by more clearly expressing code.
- Require other classes with 'use' at the beginning of the class file.
- Do not specify 'public' if method is public, it's implicit.
- Always use guard clauses.
- Ensure compatibility with PHP 5.3 and newer versions.
- Cover your code in tests.
Recommendations:
- Max line length at 80 chars.
- Keep classes under 100 LOC.
- Keep methods under 10 LOC.
- Pass no more than 4 parameters/hash keys into a method.
- Keep Pull Requests small, under 100 LOC changed.
## Git flow.
- Do not commit to master.
- Open a short-living feature branch.
- Open a pull request.
- Add close #issue in pull request description.
- Add Jira issue reference in the title of the Pull Request.
- Work on the pull request.
- Wait for confirmation before merging to master.
- No one will accept a pull request that doesn't have 100% test coverage.
- Wait for review and confirmation from another developer before merging to master.
- Commit title no more than 80 chars, empty line after.
- Commit description as long as you want, 80 chars wrap.
- Keep the GitHub open issues count at less than 10.
## Issues creation.
- Issues are managed on Jira.
- Discuss issues on public Slack chats, discuss code in pull requests.
- Organize features on Trello.
- Open a small github issue only when it has been discussed.
- Open a small Jira issue only when it has been discussed.

View File

@ -46,11 +46,21 @@ $ ./do compile:all
$ ./do test:unit
```
- JS tests (using Mocha):
```sh
$ ./do test:javascript
```
- Debug tests:
```sh
$ ./do test:debug
```
- Code linters and quality checkers:
```sh
$ ./do qa
```
# CSS
- [Stylus](https://learnboost.github.io/stylus/)
- [Nib extension](http://tj.github.io/nib/)
@ -109,6 +119,7 @@ Once javascript is compiled with `./do compile:javascript`, your module will be
```php
__()
_n()
_x()
```
```html
@ -128,3 +139,39 @@ _n()
- Handlebars.
You can use Twig i18n functions in Handlebars, just load your template from a Twig view.
# Build
To build a plugin , run `./build.sh`.
Some build process steps are described below (their dependencies etc.).
## packtranslations step
This step imports translations from Transifex and generates MO files. It requires:
* `tx` client: https://docs.transifex.com/client/installing-the-client
* `msgfmt` command (from Gettext package)
Finally , a `WP_TRANSIFEX_API_TOKEN` environment variable should be initialized with a valid key.
# Publish
The `publish` command currently does the following:
* Pushes translations POT file to Transifex;
* Publishes the release in SVN.
Before you run it, you need to:
1. Ensure there is an up-to-date local copy of MailPoet SVN repository in `.mp_svn` directory by running `./do svn:checkout`.
2. Have all your features merged in Git `master`, your `mailpoet.php` and `readme.txt` tagged with a new version.
3. Run `./build.sh` to produce a `mailpoet.zip` distributable archive.
Everything's ready? Then run `./do publish`.
If the job goes fine, you'll get a message like this:
```
Go to '.mp_svn' and run 'svn ci -m "Release 3.0.0-beta.9"' to publish the
release
Run 'svn copy ...' to tag the release
```
It's quite literal: you can review the changes to be pushed and if you're satisfied, run the suggested command to finish the release publishing process.
If you're confident, execute `./do publish --force` and your release will be published to the remote SVN repository without manual intervention (automatically). For easier authentication you might want to set `WP_SVN_USERNAME` and `WP_SVN_PASSWORD` environment variables.

View File

@ -68,9 +68,9 @@ class RoboFile extends \Robo\Tasks {
}
function compileAll() {
$collection = $this->collection();
$collection->add(array($this, 'compileJs'));
$collection->add(array($this, 'compileCss'));
$collection = $this->collectionBuilder();
$collection->addCode(array($this, 'compileJs'));
$collection->addCode(array($this, 'compileCss'));
return $collection->run();
}
@ -99,16 +99,29 @@ class RoboFile extends \Robo\Tasks {
function makepot() {
return $this->_exec('./node_modules/.bin/grunt makepot'.
' --gruntfile '.__DIR__.'/tasks/makepot/makepot.js'.
' --base_path '.__DIR__
' --gruntfile='.__DIR__.'/tasks/makepot/makepot.js'.
' --base_path='.__DIR__
);
}
function pushpot() {
return $this->_exec('./node_modules/.bin/grunt pushpot'.
' --gruntfile '.__DIR__.'/tasks/makepot/makepot.js'.
' --base_path '.__DIR__
);
return $this->collectionBuilder()
->addCode(array($this, 'txinit'))
->taskExec('tx push -s')
->run();
}
function packtranslations() {
return $this->collectionBuilder()
->addCode(array($this, 'txinit'))
->taskExec('./tasks/pack_translations.sh')
->run();
}
function txinit() {
// Define WP_TRANSIFEX_API_TOKEN env. variable
$this->loadEnv();
return $this->_exec('./tasks/transifex_init.sh');
}
function testUnit($opts=['file' => null, 'xml' => false]) {
@ -171,9 +184,9 @@ class RoboFile extends \Robo\Tasks {
}
function qa() {
$collection = $this->collection();
$collection->add(array($this, 'qaLint'));
$collection->add(function() {
$collection = $this->collectionBuilder();
$collection->addCode(array($this, 'qaLint'));
$collection->addCode(function() {
return $this->qaCodeSniffer('all');
});
return $collection->run();
@ -193,14 +206,169 @@ class RoboFile extends \Robo\Tasks {
'./vendor/bin/phpcs '.
'--standard=./tasks/code_sniffer/MailPoet '.
'--ignore=./lib/Util/Sudzy/*,./lib/Util/CSS.php,./lib/Util/XLSXWriter.php,'.
'./lib/Config/PopulatorData/Templates/* '.
'./lib/Util/pQuery/*,./lib/Config/PopulatorData/Templates/* '.
'lib/ '.
$severityFlag
);
}
function svnCheckout() {
$svn_dir = ".mp_svn";
$collection = $this->collectionBuilder();
// Clean up the SVN dir for faster shallow checkout
if(file_exists($svn_dir)) {
$collection->taskExecStack()
->exec('rm -rf ' . $svn_dir);
}
$collection->taskFileSystemStack()
->mkdir($svn_dir);
return $collection->taskExecStack()
->stopOnFail()
->dir($svn_dir)
->exec('svn co https://plugins.svn.wordpress.org/mailpoet/ -N .')
->exec('svn up trunk')
->exec('svn up assets')
->run();
}
function svnPublish($opts = ['force' => false]) {
$this->loadWPFunctions();
$svn_dir = ".mp_svn";
$plugin_data = get_plugin_data('mailpoet.php', false, false);
$plugin_version = $plugin_data['Version'];
$plugin_dist_name = sanitize_title_with_dashes($plugin_data['Name']);
$plugin_dist_file = $plugin_dist_name . '.zip';
$this->say('Publishing version: ' . $plugin_version);
// Sanity checks
if(!is_readable($plugin_dist_file)) {
$this->say("Failed to access " . $plugin_dist_file);
return;
} elseif(!file_exists($svn_dir . "/.svn/")) {
$this->say("$svn_dir/.svn/ dir not found, is it a SVN repository?");
return;
} elseif(file_exists($svn_dir . "/tags/" . $plugin_version)) {
$this->say("A SVN tag already exists: " . $plugin_version);
return;
}
$collection = $this->collectionBuilder();
// Clean up tmp dirs if the previous run was halted
if(file_exists("$svn_dir/trunk_new") || file_exists("$svn_dir/trunk_old")) {
$collection->taskFileSystemStack()
->stopOnFail()
->remove(array("$svn_dir/trunk_new", "$svn_dir/trunk_old"));
}
// Extract the distributable zip to tmp trunk dir
$collection->taskExtract($plugin_dist_file)
->to("$svn_dir/trunk_new")
->preserveTopDirectory(false);
// Rename current trunk
if(file_exists("$svn_dir/trunk")) {
$collection->taskFileSystemStack()
->rename("$svn_dir/trunk", "$svn_dir/trunk_old");
}
// Replace old trunk with a new one
$collection->taskFileSystemStack()
->stopOnFail()
->rename("$svn_dir/trunk_new", "$svn_dir/trunk")
->remove("$svn_dir/trunk_old");
// Add new repository assets
$collection->taskFileSystemStack()
->mirror('./plugin_repository/assets', "$svn_dir/assets_new");
// Rename current assets folder
if(file_exists("$svn_dir/assets")) {
$collection->taskFileSystemStack()
->rename("$svn_dir/assets", "$svn_dir/assets_old");
}
// Replace old assets with new ones
$collection->taskFileSystemStack()
->stopOnFail()
->rename("$svn_dir/assets_new", "$svn_dir/assets")
->remove("$svn_dir/assets_old");
// Windows compatibility
$awkCmd = '{print " --force \""$2"\""}';
// Mac OS X compatibility
$xargsFlag = (stripos(PHP_OS, 'Darwin') !== false) ? '' : '-r';
$collection->taskExecStack()
->stopOnFail()
// Set SVN repo as working directory
->dir($svn_dir)
// Remove files from SVN repo that have already been removed locally
->exec("svn st | grep ^! | awk '$awkCmd' | xargs $xargsFlag svn rm")
// Recursively add files to SVN that haven't been added yet
->exec("svn add --force * --auto-props --parents --depth infinity -q");
$result = $collection->run();
if($result->wasSuccessful()) {
// Run or suggest release command depending on a flag
$repo_url = "https://plugins.svn.wordpress.org/$plugin_dist_name";
$release_cmd = "svn ci -m \"Release $plugin_version\"";
$tag_cmd = "svn copy $repo_url/trunk $repo_url/tags/$plugin_version -m \"Tag $plugin_version\"";
if(!empty($opts['force'])) {
$svn_login = getenv('WP_SVN_USERNAME');
$svn_password = getenv('WP_SVN_PASSWORD');
if ($svn_login && $svn_password) {
$release_cmd .= " --username $svn_login --password $svn_password";
} else {
$release_cmd .= ' --force-interactive';
}
$result = $this->taskExecStack()
->stopOnFail()
->dir($svn_dir)
->exec($release_cmd)
->exec($tag_cmd)
->run();
} else {
$this->yell(
"Go to '$svn_dir' and run '$release_cmd' to publish the release"
);
$this->yell(
"Run '$tag_cmd' to tag the release"
);
}
}
return $result;
}
public function publish($opts = ['force' => false]) {
return $this->collectionBuilder()
->addCode(array($this, 'pushpot'))
->addCode(function () use ($opts) {
return $this->svnPublish($opts);
})
->run();
}
protected function loadEnv() {
$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();
}
protected function loadWPFunctions() {
$this->loadEnv();
define('ABSPATH', getenv('WP_TEST_PATH') . '/');
define('WPINC', 'wp-includes');
require_once(ABSPATH . WPINC . '/functions.php');
require_once(ABSPATH . WPINC . '/formatting.php');
require_once(ABSPATH . WPINC . '/plugin.php');
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
}
}

View File

@ -22,3 +22,5 @@
@require 'progress_bar'
@require 'subscribers'
@require 'mp2migrator'

View File

@ -1,3 +1,53 @@
$excellent-badge-color = #2993ab
$good-badge-color = #f0b849
$bad-badge-color = #d54e21
$green-badge-color = #55bd56
#newsletters_container
h2.nav-tab-wrapper
margin-bottom: 1rem
margin-bottom: 1rem
.mailpoet_stats_text
font-size: 14px
font-weight: 600;
.mailpoet_stat
&_excellent
color: $excellent-badge-color
&_good
color: $good-badge-color
&_bad
color: $bad-badge-color
&_hidden
display: none
&_link_small
text-decoration: underline !important
font-size: 0.75rem
.mailpoet_badge
padding: 4px 6px 3px 6px
color: #FFFFFF
margin-right: 4px
text-transform: uppercase
font-size: 0.5625rem
font-weight: 500
border-radius: 3px
letter-spacing: 1px
vertical-align: middle
&_excellent
background: $excellent-badge-color
&_good
background: $good-badge-color
&_bad
background: $bad-badge-color
&_green
background: $green-badge-color

View File

@ -0,0 +1,33 @@
#logger
width: 100%
height: 300px
background-color: transparent
border: 0
border-top: 1px #aba9a9 solid
padding: 2px
overflow: scroll
resize: both
font-size: 0.85em
margin-top: 20px
#progressbar
width: 50%
background-color: #d8d8d8
border-radius: 5px
progressbar_color = #fecf23
progressbar_gradient_to_color = #fd9215
.ui-progressbar .ui-progressbar-value
height: 100%
background-color: progressbar_color
background-image: linear-gradient(to bottom, progressbar_color, progressbar_gradient_to_color)
border-radius: 3px
box-shadow: 0 1px 0 rgba(255,255,255,0.5) inset
border 0
.mailpoet_progress_label
font-size: 15px
.error_msg
color: #f00

View File

@ -34,7 +34,7 @@ $block-text-line-height = $text-line-height
position: relative
line-height: $block-text-line-height
p, h1, h2, h3, h4, h5, h6
h1, h2, h3, h4, h5, h6
line-height: $block-text-line-height
padding: 0
margin: 0
@ -44,9 +44,15 @@ $block-text-line-height = $text-line-height
h1, h2, h3, h4, h5, h6
margin-bottom: 0.3em
p
p:not(.mailpoet_wp_post)
margin-top: 0
margin-bottom: 0
padding: 0
margin: 0
p
line-height: $block-text-line-height
font-style: normal
font-weight: normal
ul

View File

@ -131,6 +131,7 @@ body
display: none
.wrap > .mailpoet_notice,
.notice
.update-nag
margin-left: 2px + 15px !important

View File

@ -4,6 +4,7 @@
padding: 0
width: 100%
margin: 0
margin-bottom: 10px
border-radius: 5px
position: relative
@ -25,5 +26,5 @@
.mailpoet_progress_complete
.mailpoet_progress_bar
background-color: #fecf23
background-image: linear-gradient(top, #fecf23, #fd9215)
background-color: hsla(191, 78%, 80%, 1)
background-image: linear-gradient(top, hsla(191, 78%, 80%, 1), hsla(191, 76%, 67%, 1))

View File

@ -15,13 +15,12 @@
padding 15px 15px 0 15px
margin 0 25px 25px 0
width 300px
height 250px
height 300px
border 1px solid #dedede
background-color #fff
h3
text-align center
height 54px
line-height 54px
font-size 1.5em
.mailpoet_description
font-size 14px
@ -39,6 +38,7 @@
font-weight bold
.mailpoet_active
.mailpoet_status
background-color #088b00
span
visibility visible
#mailpoet_mta_activate
@ -52,6 +52,15 @@
.button-secondary
margin 0 -6px -4px 0
// premium key
.mailpoet_key
&_valid
&::before
content ' '
&_invalid
&::before
content: ' '
// responsive
@media screen and (max-width: 782px)
.form-table th

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -5,6 +5,7 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery,
options: {},
defaults: {
url: null,
api_version: null,
endpoint: null,
action: null,
token: null,
@ -30,6 +31,7 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery,
getParams: function() {
return {
action: 'mailpoet',
api_version: this.options.api_version,
token: this.options.token,
endpoint: this.options.endpoint,
method: this.options.action,

View File

@ -143,9 +143,7 @@ define('date',
var convertedFormat = [];
var escapeToken = false;
for (var index in format) {
var token = format[index];
for(var index = 0, token = ''; token = format.charAt(index); index++){
if (escapeToken === true) {
convertedFormat.push('['+token+']');
escapeToken = false;

View File

@ -64,6 +64,7 @@ define(
this.setState({ loading: true });
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: this.props.endpoint,
action: 'get',
data: {
@ -112,6 +113,7 @@ define(
}
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: this.props.endpoint,
action: 'save',
data: item

View File

@ -1024,7 +1024,7 @@ WysijaForm.Widget = Class.create(WysijaForm.Block, {
},
editSettings: function() {
MailPoet.Modal.popup({
title: 'Edit field settings', // TODO: translate!
title: MailPoet.I18n.t('editFieldSettings'),
template: jQuery('#form_template_field_settings').html(),
data: this.getData(),
onSuccess: function() {
@ -1061,4 +1061,4 @@ function info(value) {
} catch(e) {}
}
module.exports = WysijaForm;
module.exports = WysijaForm;

View File

@ -77,7 +77,7 @@ const messages = {
const bulk_actions = [
{
name: 'trash',
label: MailPoet.I18n.t('trash'),
label: MailPoet.I18n.t('moveToTrash'),
onSuccess: messages.onTrash
}
];
@ -97,6 +97,7 @@ const item_actions = [
label: MailPoet.I18n.t('duplicate'),
onClick: function(item, refresh) {
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'forms',
action: 'duplicate',
data: {
@ -125,6 +126,7 @@ const item_actions = [
const FormList = React.createClass({
createForm() {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'forms',
action: 'create'
}).done((response) => {

View File

@ -1,10 +1,8 @@
define('i18n',
[
'mailpoet',
'underscore',
'mailpoet'
], function(
MailPoet,
_
MailPoet
) {
'use strict';

View File

@ -82,7 +82,7 @@ const ListingItem = React.createClass({
null,
this.props.item.id
) }>
{MailPoet.I18n.t('trash')}
{MailPoet.I18n.t('moveToTrash')}
</a>
</span>
);
@ -198,6 +198,17 @@ const ListingItem = React.createClass({
const ListingItems = React.createClass({
render: function() {
if (this.props.items.length === 0) {
let message;
if (this.props.loading === true) {
message = (this.props.messages.onLoadingItems
&& this.props.messages.onLoadingItems(this.props.group))
|| MailPoet.I18n.t('loadingItems');
} else {
message = (this.props.messages.onNoItemsFound
&& this.props.messages.onNoItemsFound(this.props.group))
|| MailPoet.I18n.t('noItemsFound');
}
return (
<tbody>
<tr className="no-items">
@ -207,11 +218,7 @@ const ListingItems = React.createClass({
+ (this.props.is_selectable ? 1 : 0)
}
className="colspanchange">
{
(this.props.loading === true)
? MailPoet.I18n.t('loadingItems')
: MailPoet.I18n.t('noItemsFound')
}
{message}
</td>
</tr>
</tbody>
@ -445,6 +452,7 @@ const Listing = React.createClass({
this.clearSelection();
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: this.props.endpoint,
action: 'listing',
data: {
@ -495,6 +503,7 @@ const Listing = React.createClass({
});
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: this.props.endpoint,
action: 'restore',
data: {
@ -522,6 +531,7 @@ const Listing = React.createClass({
});
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: this.props.endpoint,
action: 'trash',
data: {
@ -549,6 +559,7 @@ const Listing = React.createClass({
});
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: this.props.endpoint,
action: 'delete',
data: {
@ -611,6 +622,7 @@ const Listing = React.createClass({
}
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: this.props.endpoint,
action: 'bulkAction',
data: data
@ -788,6 +800,12 @@ const Listing = React.createClass({
groups = false;
}
// messages
let messages = {};
if (this.props.messages !== undefined) {
messages = this.props.messages;
}
return (
<div>
{ groups }
@ -841,6 +859,7 @@ const Listing = React.createClass({
count={ this.state.count }
limit={ this.state.limit }
item_actions={ item_actions }
messages={ messages }
items={ items } />
<tfoot>
@ -873,4 +892,4 @@ const Listing = React.createClass({
}
});
module.exports = Listing;
module.exports = Listing;

View File

@ -164,11 +164,16 @@ define([
{ 'one-page': (this.props.count <= this.props.limit) }
);
var numberOfItemsLabel;
if (this.props.count == 1) {
numberOfItemsLabel = MailPoet.I18n.t('numberOfItemsSingular');
} else {
numberOfItemsLabel = MailPoet.I18n.t('numberOfItemsMultiple')
.replace('%$1d', this.props.count.toLocaleString());
}
return (
<div className={ classes }>
<span className="displaying-num">{
MailPoet.I18n.t('numberOfItems').replace('%$1d', this.props.count.toLocaleString())
}</span>
<span className="displaying-num">{ numberOfItemsLabel }</span>
{ pagination }
</div>
);

View File

@ -28,6 +28,9 @@ define('modal', ['mailpoet', 'jquery'],
opened: false,
locked: false,
// previously focused element
prevFocus: null,
// sub panels
subpanels: [],
@ -59,6 +62,9 @@ define('modal', ['mailpoet', 'jquery'],
// display overlay
overlay: false,
// focus upon displaying
focus: true,
// highlighted elements
highlight: null,
@ -71,7 +77,7 @@ define('modal', ['mailpoet', 'jquery'],
options: {},
templates: {
overlay: '<div id="mailpoet_modal_overlay" style="display:none;"></div>',
popup: '<div id="mailpoet_popup">'+
popup: '<div id="mailpoet_popup" tabindex="-1">'+
'<div class="mailpoet_popup_wrapper">'+
'<a href="javascript:;" id="mailpoet_modal_close"></a>'+
'<div id="mailpoet_popup_title"><h2></h2></div>'+
@ -85,11 +91,11 @@ define('modal', ['mailpoet', 'jquery'],
'</div>',
panel: '<div id="mailpoet_panel">'+
'<a href="javascript:;" id="mailpoet_modal_close"></a>'+
'<div class="mailpoet_panel_wrapper">'+
'<div class="mailpoet_panel_wrapper" tabindex="-1">'+
'<div class="mailpoet_panel_body clearfix"></div>'+
'</div>'+
'</div>',
subpanel: '<div class="mailpoet_panel_wrapper">'+
subpanel: '<div class="mailpoet_panel_wrapper" tabindex="-1">'+
'<div class="mailpoet_panel_body clearfix"></div>'+
'</div>'
},
@ -251,6 +257,11 @@ define('modal', ['mailpoet', 'jquery'],
// add sub panel content
jQuery('.mailpoet_'+this.options.type+'_body').last()
.html(this.subpanels[(this.subpanels.length - 1)].element);
// focus on sub panel
if(this.options.focus) {
this.focus();
}
} else if (this.options.element) {
jQuery('.mailpoet_'+this.options.type+'_body').empty();
jQuery('.mailpoet_'+this.options.type+'_body')
@ -369,6 +380,9 @@ define('modal', ['mailpoet', 'jquery'],
// set modal dimensions
this.setDimensions();
// remember the previously focused element
this.prevFocus = jQuery(':focus');
// add a flag on the body so that we can prevent scrolling
jQuery('body').addClass('mailpoet_modal_opened');
@ -388,6 +402,10 @@ define('modal', ['mailpoet', 'jquery'],
}
}
if(this.options.focus) {
this.focus();
}
// set popup as opened
this.opened = true;
@ -398,6 +416,16 @@ define('modal', ['mailpoet', 'jquery'],
return this;
},
focus: function() {
if(this.options.type == 'popup') {
jQuery('#mailpoet_'+this.options.type).focus();
} else {
// panel and subpanel
jQuery('#mailpoet_'+this.options.type+' .mailpoet_panel_wrapper')
.filter(':visible').focus();
}
return this;
},
highlightOn: function(element) {
jQuery(element).addClass('mailpoet_modal_highlight');
return this;
@ -579,6 +607,11 @@ define('modal', ['mailpoet', 'jquery'],
// remove last subpanels
this.subpanels.pop();
// focus on previous panel
if(this.options.focus) {
this.focus();
}
return this;
}
@ -591,6 +624,11 @@ define('modal', ['mailpoet', 'jquery'],
// destroy modal element
this.destroy();
// restore the previously focused element
if(this.prevFocus !== undefined){
this.prevFocus.focus();
}
// reset options
this.options = {
onSuccess: null,

View File

@ -0,0 +1,187 @@
define('mp2migrator', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
'use strict';
MailPoet.MP2Migrator = {
fatal_error: '',
is_logging: false,
startLogger: function () {
MailPoet.MP2Migrator.is_logging = true;
clearTimeout(MailPoet.MP2Migrator.displayLogs_timeout);
clearTimeout(MailPoet.MP2Migrator.updateProgressbar_timeout);
clearTimeout(MailPoet.MP2Migrator.update_wordpress_info_timeout);
setTimeout(MailPoet.MP2Migrator.updateDisplay, 1000)
},
stopLogger: function () {
MailPoet.MP2Migrator.is_logging = false;
},
updateDisplay: function () {
MailPoet.MP2Migrator.displayLogs();
MailPoet.MP2Migrator.updateProgressbar();
},
displayLogs: function () {
jQuery.ajax({
url: mailpoet_mp2_migrator.log_file_url,
cache: false
}).done(function (result) {
jQuery("#logger").html('');
result.split("\n").forEach(function (row) {
if(row.substr(0, 7) === '[ERROR]' || row.substr(0, 9) === '[WARNING]' || row === MailPoet.I18n.t('import_stopped_by_user')) {
row = '<span class="error_msg">' + row + '</span>'; // Mark the errors in red
}
// Test if the import is complete
else if(row === MailPoet.I18n.t('import_complete')) {
jQuery('#import-actions').hide();
jQuery('#upgrade-completed').show();
}
jQuery("#logger").append(row + "<br />\n");
});
jQuery("#logger").append('<span class="error_msg">' + MailPoet.MP2Migrator.fatal_error + '</span>' + "<br />\n");
}).always(function () {
if(MailPoet.MP2Migrator.is_logging) {
MailPoet.MP2Migrator.displayLogs_timeout = setTimeout(MailPoet.MP2Migrator.displayLogs, 1000);
}
});
},
updateProgressbar: function () {
jQuery.ajax({
url: mailpoet_mp2_migrator.progress_url,
cache: false,
dataType: 'json'
}).always(function (result) {
// Move the progress bar
var progress = 0;
if((result.total !== undefined) && (Number(result.total) !== 0)) {
progress = Math.round(Number(result.current) / Number(result.total) * 100);
}
jQuery('#progressbar').progressbar('option', 'value', progress);
jQuery('#progresslabel').html(progress + '%');
if(Number(result.current !== 0)) {
jQuery('#skip-import').hide();
}
if(MailPoet.MP2Migrator.is_logging) {
MailPoet.MP2Migrator.updateProgressbar_timeout = setTimeout(MailPoet.MP2Migrator.updateProgressbar, 1000);
}
});
},
startImport: function () {
MailPoet.MP2Migrator.fatal_error = '';
// Start displaying the logs
MailPoet.MP2Migrator.startLogger();
// Disable the import button
MailPoet.MP2Migrator.import_button_label = jQuery('#import').val();
jQuery('#import').val(MailPoet.I18n.t('importing')).attr('disabled', 'disabled');
// Hide the Skip button
jQuery('#skip-import').hide();
// Show the stop button
jQuery('#stop-import').show();
// Run the import
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'MP2Migrator',
action: 'import',
data: {
}
}).always(function () {
MailPoet.MP2Migrator.stopLogger();
MailPoet.MP2Migrator.updateDisplay(); // Get the latest information after the import was stopped
MailPoet.MP2Migrator.reactivateImportButton();
}).done(function (response) {
if(response) {
MailPoet.MP2Migrator.fatal_error = response.data;
}
}).fail(function (response) {
if(response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function (error) {
return error.message;
}),
{scroll: true}
);
}
});
return false;
},
reactivateImportButton: function () {
jQuery('#import').val(MailPoet.MP2Migrator.import_button_label).removeAttr('disabled');
jQuery('#stop-import').hide();
},
stopImport: function () {
jQuery('#stop-import').attr('disabled', 'disabled');
// Stop the import
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'MP2Migrator',
action: 'stopImport',
data: {
}
}).always(function () {
jQuery('#stop-import').removeAttr('disabled'); // Enable the button
MailPoet.MP2Migrator.reactivateImportButton();
MailPoet.MP2Migrator.updateDisplay(); // Get the latest information after the import was stopped
});
MailPoet.MP2Migrator.stopLogger();
return false;
},
skipImport: function () {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'MP2Migrator',
action: 'skipImport',
data: {
}
}).done(function () {
MailPoet.MP2Migrator.gotoWelcomePage();
});
return false;
},
gotoWelcomePage: function () {
window.location.href = 'admin.php?page=mailpoet-welcome';
return false;
}
};
/**
* Actions to run when the DOM is ready
*/
jQuery(function () {
jQuery('#progressbar').progressbar({value: 0});
// Import button
jQuery('#import').click(function() {
MailPoet.MP2Migrator.startImport();
});
// Stop import button
jQuery('#stop-import').click(function() {
MailPoet.MP2Migrator.stopImport();
});
// Skip import link
jQuery('#skip-import').click(function() {
MailPoet.MP2Migrator.skipImport();
});
// Go to welcome page
jQuery('#goto-welcome').click(function() {
MailPoet.MP2Migrator.gotoWelcomePage();
});
// Update the display
MailPoet.MP2Migrator.updateDisplay();
});
});

View File

@ -1,22 +1,14 @@
define([
'backbone',
'backbone.marionette',
'backbone.supermodel',
'backbone.radio',
'jquery',
'underscore',
'handlebars',
'handlebars_helpers'
], function(Backbone, Marionette, SuperModel, jQuery, _, Handlebars) {
], function(Backbone, Marionette, Radio, jQuery, _, Handlebars) {
var app = new Marionette.Application(), AppView;
// Decoupled communication between application components
app.getChannel = function(channel) {
if (channel === undefined) return app.channel;
return Radio.channel(channel);
};
AppView = Marionette.LayoutView.extend({
var AppView = Marionette.View.extend({
el: '#mailpoet_editor',
regions: {
stylesRegion: '#mailpoet_editor_styles',
@ -27,10 +19,23 @@ define([
},
});
app.on('start', function(options) {
app._appView = new AppView();
var EditorApplication = Marionette.Application.extend({
region: '#mailpoet_editor',
onStart: function() {
this._appView = new AppView();
this.showView(this._appView);
},
getChannel: function(channel) {
if (channel === undefined) channel = 'global';
return Radio.channel(channel);
}
});
var app = new EditorApplication();
window.EditorApplication = app;
return app;
});

View File

@ -6,8 +6,9 @@
define([
'backbone.marionette',
'newsletter_editor/behaviors/BehaviorsLookup',
'mailpoet',
'spectrum'
], function(Marionette, BehaviorsLookup, Spectrum) {
], function(Marionette, BehaviorsLookup, MailPoet, Spectrum) {
BehaviorsLookup.ColorPickerBehavior = Marionette.Behavior.extend({
onRender: function() {
@ -17,6 +18,8 @@ define([
showInitial: true,
preferredFormat: "hex6",
allowEmpty: true,
chooseText: MailPoet.I18n.t('selectColor'),
cancelText: MailPoet.I18n.t('cancelColorSelection')
});
},
});

View File

@ -71,6 +71,7 @@ define([
markerWidth = '',
markerHeight = '',
containerOffset = element.offset(),
viewCollection = that.getCollection(),
marker, targetModel, targetView, targetElement,
topOffset, leftOffset, isLastBlockInsertion,
$targetBlock, margin;
@ -80,19 +81,19 @@ define([
element.find('.mailpoet_drop_marker').remove();
// Allow empty collections to handle their own drop marking
if (view.model.get('blocks').isEmpty()) return;
if (viewCollection.isEmpty()) return;
if (view.collection.length === 0) {
if (viewCollection.length === 0) {
targetElement = element.find(view.childViewContainer);
topOffset = targetElement.offset().top - element.offset().top;
leftOffset = targetElement.offset().left - element.offset().left;
markerWidth = targetElement.width();
markerHeight = targetElement.height();
} else {
isLastBlockInsertion = view.collection.length === dropPosition.index;
targetModel = isLastBlockInsertion ? view.collection.at(dropPosition.index - 1) : view.collection.at(dropPosition.index);
isLastBlockInsertion = that.getCollection().length === dropPosition.index;
targetModel = isLastBlockInsertion ? viewCollection.at(dropPosition.index - 1) : viewCollection.at(dropPosition.index);
targetView = view.children.findByModel(targetModel);
targetView = that.getChildren().findByModel(targetModel);
targetElement = targetView.$el;
topOffset = targetElement.offset().top - containerOffset.top;
@ -135,10 +136,10 @@ define([
if (dropPosition.index === 0) {
marker.addClass('mailpoet_drop_marker_first');
}
if (view.collection.length - 1 === dropPosition.index) {
if (viewCollection.length - 1 === dropPosition.index) {
marker.addClass('mailpoet_drop_marker_last');
}
if (dropPosition.index > 0 && view.collection.length - 1 > dropPosition.index) {
if (dropPosition.index > 0 && viewCollection.length - 1 > dropPosition.index) {
marker.addClass('mailpoet_drop_marker_middle');
}
marker.addClass('mailpoet_drop_marker_' + dropPosition.position);
@ -147,9 +148,9 @@ define([
// compensated for to position marker right in the middle of two
// blocks
if (dropPosition.position === 'before') {
$targetBlock = view.children.findByModel(view.collection.at(dropPosition.index-1)).$el;
$targetBlock = that.getChildren().findByModel(viewCollection.at(dropPosition.index-1)).$el;
} else {
$targetBlock = view.children.findByModel(view.collection.at(dropPosition.index)).$el;
$targetBlock = that.getChildren().findByModel(viewCollection.at(dropPosition.index)).$el;
}
margin = $targetBlock.outerHeight(true) - $targetBlock.outerHeight();
@ -182,6 +183,7 @@ define([
view.model.get('blocks').length
),
droppableModel = event.draggable.getDropModel(),
viewCollection = that.getCollection(),
droppedView, droppedModel, index, tempCollection, tempCollection2;
if (dropPosition === undefined) return;
@ -196,22 +198,22 @@ define([
orientation: 'vertical',
});
tempCollection.get('blocks').add(droppableModel);
view.collection.add(tempCollection, {at: index});
viewCollection.add(tempCollection, {at: index});
} else {
view.collection.add(droppableModel, {at: index});
viewCollection.add(droppableModel, {at: index});
}
droppedView = view.children.findByModel(droppableModel);
droppedView = that.getChildren().findByModel(droppableModel);
} else {
// Special insertion by replacing target block with collection
// and inserting dropModel into that
var tempModel = view.collection.at(dropPosition.index);
var tempModel = viewCollection.at(dropPosition.index);
tempCollection = new (EditorApplication.getBlockTypeModel('container'))({
orientation: (view.model.get('orientation') === 'vertical') ? 'horizontal' : 'vertical',
});
view.collection.remove(tempModel);
viewCollection.remove(tempModel);
if (tempCollection.get('orientation') === 'horizontal') {
if (dropPosition.position === 'before') {
@ -242,10 +244,10 @@ define([
tempCollection.get('blocks').add(droppableModel);
}
}
view.collection.add(tempCollection, {at: dropPosition.index});
viewCollection.add(tempCollection, {at: dropPosition.index});
// Call post add actions
droppedView = view.children.findByModel(tempCollection).children.findByModel(droppableModel);
droppedView = that.getChildren().findByModel(tempCollection).children.findByModel(droppableModel);
}
// Call post add actions
@ -290,7 +292,7 @@ define([
unsafe = !!unsafe;
if (this.view.collection.length === 0) {
if (this.getCollection().length === 0) {
return {
insertionType: 'normal',
index: 0,
@ -327,7 +329,7 @@ define([
index = indexAndPosition.index;
}
if (!unsafe && orientation === 'vertical' && insertionType === 'special' && this.view.collection.at(index).get('orientation') === 'horizontal') {
if (!unsafe && orientation === 'vertical' && insertionType === 'special' && this.getCollection().at(index).get('orientation') === 'horizontal') {
// Prevent placing horizontal container in another horizontal container,
// which would allow breaking the column limit.
// Switch that to normal insertion
@ -356,7 +358,7 @@ define([
var index = this._computeCellIndex(eventX, eventY),
// TODO: Handle case when there are no children, container is empty
targetView = this.view.children.findByModel(this.view.collection.at(index)),
targetView = this.getChildren().findByModel(this.getCollection().at(index)),
orientation = this.view.model.get('orientation'),
element = targetView.$el,
eventOffset, closeOffset, elementDimension;
@ -391,7 +393,7 @@ define([
_computeCellIndex: function(eventX, eventY) {
var orientation = this.view.model.get('orientation'),
eventOffset = (orientation === 'vertical') ? eventY : eventX,
resultView = this.view.children.find(function(view) {
resultView = this.getChildren().find(function(view) {
var element = view.$el,
closeOffset, farOffset;
@ -414,15 +416,24 @@ define([
_canAcceptNormalInsertion: function() {
var orientation = this.view.model.get('orientation'),
depth = this.view.renderOptions.depth,
childCount = this.view.children.length;
childCount = this.getChildren().length;
// Note that depth is zero indexed. Root container has depth=0
return orientation === 'vertical' || (orientation === 'horizontal' && depth === 1 && childCount < this.options.columnLimit);
},
_canAcceptSpecialInsertion: function() {
var orientation = this.view.model.get('orientation'),
depth = this.view.renderOptions.depth,
childCount = this.view.children.length;
childCount = this.getChildren().length;
return depth === 0 || (depth === 1 && orientation === 'horizontal' && childCount <= this.options.columnLimit);
},
getCollectionView: function() {
return this.view.getChildView('blocks');
},
getChildren: function() {
return this.getCollectionView().children;
},
getCollection: function() {
return this.getCollectionView().collection;
}
});
});

View File

@ -60,10 +60,17 @@ define([
editor.on('click', function(e) {
editor.focus();
if (that._isActivationClick) {
editor.selection.setRng(
tinymce.dom.RangeUtils.getCaretRangeFromPoint(e.clientX, e.clientY, editor.getDoc())
);
that._isActivationClick = false;
}
});
editor.on('focus', function(e) {
that.view.triggerMethod('text:editor:focus');
that._isActivationClick = true;
});
editor.on('blur', function(e) {

View File

@ -129,6 +129,12 @@ define([
Module.AutomatedLatestContentBlockView = base.BlockView.extend({
className: "mailpoet_block mailpoet_automated_latest_content_block mailpoet_droppable_block",
initialize: function() {
function replaceButtonStylesHandler(data) {
this.model.set({"readMoreButton": data});
}
App.getChannel().on("replaceAllButtonStyles", replaceButtonStylesHandler.bind(this));
},
getTemplate: function() { return templates.automatedLatestContentBlock; },
regions: {
toolsRegion: '.mailpoet_tools',
@ -151,8 +157,8 @@ define([
emptyContainerMessage: MailPoet.I18n.t('noPostsToDisplay'),
};
this.toolsView = new Module.AutomatedLatestContentBlockToolsView({ model: this.model });
this.toolsRegion.show(this.toolsView);
this.postsRegion.show(new ContainerView({ model: this.model.get('_container'), renderOptions: renderOptions }));
this.showChildView('toolsRegion', this.toolsView);
this.showChildView('postsRegion', new ContainerView({ model: this.model.get('_container'), renderOptions: renderOptions }));
},
});
@ -189,11 +195,6 @@ define([
"click .mailpoet_done_editing": "close",
};
},
templateHelpers: function() {
return {
model: this.model.toJSON(),
};
},
onRender: function() {
var that = this;
@ -377,7 +378,7 @@ define([
},
});
App.on('before:start', function() {
App.on('before:start', function(App, options) {
App.registerBlockType('automatedLatestContent', {
blockModel: Module.AutomatedLatestContentBlockModel,
blockView: Module.AutomatedLatestContentBlockView,
@ -390,7 +391,7 @@ define([
});
});
App.on('start', function() {
App.on('start', function(App, options) {
App._ALCSupervisor = new Module.ALCSupervisor();
App._ALCSupervisor.refresh();
});

View File

@ -17,7 +17,7 @@ define([
"use strict";
var Module = {},
AugmentedView = Marionette.LayoutView.extend({});
AugmentedView = Marionette.View.extend({});
Module.BlockModel = SuperModel.extend({
stale: [], // Attributes to be removed upon saving
@ -82,7 +82,7 @@ define([
},
HighlightEditingBehavior: {},
},
templateHelpers: function() {
templateContext: function() {
return {
model: this.model.toJSON(),
viewCid: this.cid,
@ -125,6 +125,12 @@ define([
return this.model.clone();
}.bind(this);
},
disableDragging: function() {
this.$el.addClass('mailpoet_ignore_drag');
},
enableDragging: function() {
this.$el.removeClass('mailpoet_ignore_drag');
},
showBlock: function() {
if (this._isFirstRender) {
this.transitionIn();
@ -193,7 +199,7 @@ define([
this.on('hideTools', this.hideDeletionConfirmation, this);
this.on('showSettings', this.changeSettings);
},
templateHelpers: function() {
templateContext: function() {
return {
model: this.model.toJSON(),
viewCid: this.cid,
@ -217,7 +223,7 @@ define([
},
});
Module.BlockSettingsView = Marionette.LayoutView.extend({
Module.BlockSettingsView = Marionette.View.extend({
className: 'mailpoet_editor_settings',
behaviors: {
ColorPickerBehavior: {},
@ -240,6 +246,11 @@ define([
MailPoet.Modal.panel(panelParams);
}
},
templateContext: function() {
return {
model: this.model.toJSON()
};
},
close: function(event) {
this.destroy();
},
@ -271,7 +282,7 @@ define([
},
});
Module.WidgetView = Marionette.ItemView.extend({
Module.WidgetView = Marionette.View.extend({
className: 'mailpoet_widget mailpoet_droppable_block mailpoet_droppable_widget',
behaviors: {
DraggableBehavior: {

View File

@ -56,7 +56,7 @@ define([
},
onRender: function() {
this.toolsView = new Module.ButtonBlockToolsView({ model: this.model });
this.toolsRegion.show(this.toolsView);
this.showChildView('toolsRegion', this.toolsView);
},
});
@ -98,12 +98,11 @@ define([
"click .mailpoet_done_editing": "close",
};
},
templateHelpers: function() {
return {
model: this.model.toJSON(),
templateContext: function() {
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
availableStyles: App.getAvailableStyles().toJSON(),
renderOptions: this.renderOptions,
};
});
},
applyToAll: function() {
App.getChannel().trigger('replaceAllButtonStyles', _.pick(this.model.toJSON(), 'styles', 'type'));
@ -133,7 +132,7 @@ define([
},
});
App.on('before:start', function() {
App.on('before:start', function(App, options) {
App.registerBlockType('button', {
blockModel: Module.ButtonBlockModel,
blockView: Module.ButtonBlockView,

View File

@ -74,29 +74,43 @@ define([
},
});
Module.ContainerBlockView = Marionette.CompositeView.extend({
regionClass: Marionette.Region,
Module.ContainerBlocksView = Marionette.CollectionView.extend({
className: 'mailpoet_container',
childView: function(model) {
return App.getBlockTypeView(model.get('type'));
},
childViewOptions: function() {
var newRenderOptions = _.clone(this.renderOptions);
if (newRenderOptions.depth !== undefined) {
newRenderOptions.depth += 1;
}
return {
renderOptions: newRenderOptions
};
},
emptyView: function() { return Module.ContainerBlockEmptyView; },
emptyViewOptions: function() { return { renderOptions: this.renderOptions }; },
initialize: function(options) {
this.renderOptions = options.renderOptions;
}
});
Module.ContainerBlockView = base.BlockView.extend({
regions: _.extend({}, base.BlockView.prototype.regions, {
blocks: {
el: '> .mailpoet_container',
replaceElement: true
},
}),
className: 'mailpoet_block mailpoet_container_block mailpoet_droppable_block mailpoet_droppable_layout_block',
getTemplate: function() { return templates.containerBlock; },
childViewContainer: '> .mailpoet_container',
getEmptyView: function() { return Module.ContainerBlockEmptyView; },
emptyViewOptions: function() { return { renderOptions: this.renderOptions }; },
modelEvents: {
'change': 'render',
'delete': 'deleteBlock',
},
events: {
"mouseenter": "showTools",
"mouseleave": "hideTools",
events: _.extend({}, base.BlockView.prototype.events, {
"click .mailpoet_newsletter_layer_selector": "toggleEditingLayer",
},
regions: {
toolsRegion: '> .mailpoet_tools',
},
}),
ui: {
tools: '> .mailpoet_tools'
},
behaviors: {
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
ContainerDropZoneBehavior: {},
DraggableBehavior: {
cloneOriginal: true,
@ -125,8 +139,7 @@ define([
return view.renderOptions.depth === 1;
},
},
HighlightEditingBehavior: {}
},
}),
onDragSubstituteBy: function() {
// For two and three column layouts display their respective widgets,
// otherwise always default to one column layout widget
@ -137,39 +150,12 @@ define([
return Module.OneColumnContainerWidgetView;
},
constructor: function() {
// Set the block collection to be handled by this view as well
arguments[0].collection = arguments[0].model.get('blocks');
Marionette.CompositeView.apply(this, arguments);
this.$el.addClass('mailpoet_editor_view_' + this.cid);
},
initialize: function(options) {
base.BlockView.prototype.initialize.apply(this, arguments);
this.renderOptions = _.defaults(options.renderOptions || {}, {});
this.on('dom:refresh', this.showBlock, this);
this._isFirstRender = true;
},
// Determines which view type should be used for a child
getChildView: function(model) {
// TODO: If type does not have a type registered, use a generic one
return App.getBlockTypeView(model.get('type'));
},
childViewOptions: function() {
var newRenderOptions = _.clone(this.renderOptions);
if (newRenderOptions.depth !== undefined) {
newRenderOptions.depth += 1;
}
return {
renderOptions: newRenderOptions
};
},
templateHelpers: function() {
return {
model: this.model.toJSON(),
viewCid: this.cid,
};
},
onRender: function() {
this._rebuildRegions();
this.toolsView = new Module.ContainerBlockToolsView({
model: this.model,
tools: {
@ -179,10 +165,15 @@ define([
layerSelector: false,
},
});
this.toolsRegion.show(this.toolsView);
},
onBeforeDestroy: function() {
this.regionManager.destroy();
this.showChildView('toolsRegion', this.toolsView);
this.showChildView('blocks', new Module.ContainerBlocksView({
collection: this.model.get('blocks'),
renderOptions: this.renderOptions
}));
// TODO: Look for a better way to do this than here
// Sets child container orientation HTML class here, as child CollectionView won't have access to model and will overwrite existing region element instead
this.$('> .mailpoet_container').attr('class', 'mailpoet_container mailpoet_container_' + this.model.get('orientation'));
},
showTools: function() {
if (this.renderOptions.depth === 1 && !this.$el.hasClass('mailpoet_container_layer_active')) {
@ -222,76 +213,14 @@ define([
}
event.stopPropagation();
},
_buildRegions: function(regions) {
var that = this;
var defaults = {
regionClass: this.getOption('regionClass'),
parentEl: function() { return that.$el; }
};
return this.regionManager.addRegions(regions, defaults);
},
_rebuildRegions: function() {
if (this.regionManager === undefined) {
this.regionManager = new Marionette.RegionManager();
}
this.regionManager.destroy();
_.extend(this, this._buildRegions(this.regions));
},
getDropFunc: function() {
return function() {
return this.model.clone();
}.bind(this);
},
showBlock: function() {
if (this._isFirstRender) {
this.transitionIn();
this._isFirstRender = false;
}
},
deleteBlock: function() {
this.transitionOut().done(function() {
this.model.destroy();
}.bind(this));
},
transitionIn: function() {
return this._transition('slideDown', 'fadeIn', 'easeIn');
},
transitionOut: function() {
return this._transition('slideUp', 'fadeOut', 'easeOut');
},
_transition: function(slideDirection, fadeDirection, easing) {
var promise = jQuery.Deferred();
this.$el.velocity(
slideDirection,
{
duration: 250,
easing: easing,
complete: function() {
promise.resolve();
}.bind(this),
}
).velocity(
fadeDirection,
{
duration: 250,
easing: easing,
queue: false, // Do not enqueue, trigger animation in parallel
}
);
return promise;
},
});
Module.ContainerBlockEmptyView = Marionette.ItemView.extend({
Module.ContainerBlockEmptyView = Marionette.View.extend({
getTemplate: function() { return templates.containerEmpty; },
initialize: function(options) {
this.renderOptions = _.defaults(options.renderOptions || {}, {});
},
templateHelpers: function() {
templateContext: function() {
return {
isRoot: this.renderOptions.depth === 0,
emptyContainerMessage: this.renderOptions.emptyContainerMessage || '',
@ -322,12 +251,12 @@ define([
});
},
onRender: function() {
this.columnsSettingsRegion.show(this._columnsSettingsView);
this.showChildView('columnsSettingsRegion', this._columnsSettingsView);
},
});
Module.ContainerBlockColumnsSettingsView = Marionette.CollectionView.extend({
getChildView: function() { return Module.ContainerBlockColumnSettingsView; },
childView: function() { return Module.ContainerBlockColumnSettingsView; },
childViewOptions: function(model, index) {
return {
columnIndex: index,
@ -335,12 +264,12 @@ define([
},
});
Module.ContainerBlockColumnSettingsView = Marionette.ItemView.extend({
Module.ContainerBlockColumnSettingsView = Marionette.View.extend({
getTemplate: function() { return templates.containerBlockColumnSettings; },
initialize: function(options) {
this.columnNumber = (options.columnIndex || 0) + 1;
},
templateHelpers: function() {
templateContext: function() {
return {
model: this.model.toJSON(),
columnNumber: this.columnNumber,
@ -405,7 +334,7 @@ define([
},
});
App.on('before:start', function() {
App.on('before:start', function(App, options) {
App.registerBlockType('container', {
blockModel: Module.ContainerBlockModel,
blockView: Module.ContainerBlockView,

View File

@ -59,14 +59,14 @@ define([
this.listenTo(this.model, 'change:src change:styles.block.backgroundColor change:styles.block.borderStyle change:styles.block.borderWidth change:styles.block.borderColor applyToAll', this.render);
this.listenTo(this.model, 'change:styles.block.padding', this.changePadding);
},
templateHelpers: function() {
templateContext: function() {
return _.extend({
totalHeight: parseInt(this.model.get('styles.block.padding'), 10)*2 + parseInt(this.model.get('styles.block.borderWidth')) + 'px',
}, base.BlockView.prototype.templateHelpers.apply(this));
}, base.BlockView.prototype.templateContext.apply(this));
},
onRender: function() {
this.toolsView = new Module.DividerBlockToolsView({ model: this.model });
this.toolsRegion.show(this.toolsView);
this.showChildView('toolsRegion', this.toolsView);
},
onBeforeDestroy: function() {
App.getChannel().off('replaceAllDividers', this._replaceDividerHandler);
@ -104,12 +104,11 @@ define([
'change:styles.block.borderColor': 'repaintDividerStyleOptions',
};
},
templateHelpers: function() {
return {
model: this.model.toJSON(),
templateContext: function() {
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
availableStyles: App.getAvailableStyles().toJSON(),
renderOptions: this.renderOptions,
};
});
},
changeStyle: function(event) {
var style = jQuery(event.currentTarget).data('style');
@ -140,7 +139,7 @@ define([
}
},
});
App.on('before:start', function() {
App.on('before:start', function(App, options) {
App.registerBlockType('divider', {
blockModel: Module.DividerBlockModel,
blockView: Module.DividerBlockView,

View File

@ -55,7 +55,7 @@ define([
onDragSubstituteBy: function() { return Module.FooterWidgetView; },
onRender: function() {
this.toolsView = new Module.FooterBlockToolsView({ model: this.model });
this.toolsRegion.show(this.toolsView);
this.showChildView('toolsRegion', this.toolsView);
},
onTextEditorChange: function(newContent) {
this.model.set('text', newContent);
@ -68,12 +68,6 @@ define([
this.enableDragging();
this.enableShowingTools();
},
disableDragging: function() {
this.$('.mailpoet_content').addClass('mailpoet_ignore_drag');
},
enableDragging: function() {
this.$('.mailpoet_content').removeClass('mailpoet_ignore_drag');
},
});
Module.FooterBlockToolsView = base.BlockToolsView.extend({
@ -96,11 +90,10 @@ define([
"click .mailpoet_done_editing": "close",
};
},
templateHelpers: function() {
return {
model: this.model.toJSON(),
templateContext: function() {
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
availableStyles: App.getAvailableStyles().toJSON(),
};
});
},
});
@ -116,7 +109,7 @@ define([
},
});
App.on('before:start', function() {
App.on('before:start', function(App, options) {
App.registerBlockType('footer', {
blockModel: Module.FooterBlockModel,
blockView: Module.FooterBlockView,

View File

@ -55,7 +55,7 @@ define([
onDragSubstituteBy: function() { return Module.HeaderWidgetView; },
onRender: function() {
this.toolsView = new Module.HeaderBlockToolsView({ model: this.model });
this.toolsRegion.show(this.toolsView);
this.showChildView('toolsRegion', this.toolsView);
},
onTextEditorChange: function(newContent) {
this.model.set('text', newContent);
@ -68,12 +68,6 @@ define([
this.enableDragging();
this.enableShowingTools();
},
disableDragging: function() {
this.$('.mailpoet_content').addClass('mailpoet_ignore_drag');
},
enableDragging: function() {
this.$('.mailpoet_content').removeClass('mailpoet_ignore_drag');
},
});
Module.HeaderBlockToolsView = base.BlockToolsView.extend({
@ -96,11 +90,10 @@ define([
"click .mailpoet_done_editing": "close",
};
},
templateHelpers: function() {
return {
model: this.model.toJSON(),
templateContext: function() {
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
availableStyles: App.getAvailableStyles().toJSON(),
};
});
},
});
@ -116,7 +109,7 @@ define([
},
});
App.on('before:start', function() {
App.on('before:start', function(App, options) {
App.registerBlockType('header', {
blockModel: Module.HeaderBlockModel,
blockView: Module.HeaderBlockView,

View File

@ -36,17 +36,17 @@ define([
className: "mailpoet_block mailpoet_image_block mailpoet_droppable_block",
getTemplate: function() { return templates.imageBlock; },
onDragSubstituteBy: function() { return Module.ImageWidgetView; },
templateHelpers: function() {
templateContext: function() {
return _.extend({
imageMissingSrc: App.getConfig().get('urls.imageMissing'),
}, base.BlockView.prototype.templateHelpers.apply(this));
}, base.BlockView.prototype.templateContext.apply(this));
},
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
ShowSettingsBehavior: {},
}),
onRender: function() {
this.toolsView = new Module.ImageBlockToolsView({ model: this.model });
this.toolsRegion.show(this.toolsView);
this.showChildView('toolsRegion', this.toolsView);
if (this.model.get('fullWidth')) {
this.$el.addClass('mailpoet_full_image');
@ -65,7 +65,7 @@ define([
events: function() {
return {
"input .mailpoet_field_image_link": _.partial(this.changeField, "link"),
"input .mailpoet_field_image_address": _.partial(this.changeField, "src"),
"input .mailpoet_field_image_address": 'changeAddress',
"input .mailpoet_field_image_alt_text": _.partial(this.changeField, "alt"),
"change .mailpoet_field_image_full_width": _.partial(this.changeBoolCheckboxField, "fullWidth"),
"change .mailpoet_field_image_alignment": _.partial(this.changeField, "styles.block.textAlign"),
@ -327,6 +327,20 @@ define([
this._mediaManager.open();
},
changeAddress: function(event) {
var src = jQuery(event.target).val();
var image = new Image();
image.onload = function() {
this.model.set({
src: src,
width: image.naturalWidth + 'px',
height: image.naturalHeight + 'px'
});
}.bind(this);
image.src = src;
},
onBeforeDestroy: function() {
base.BlockSettingsView.prototype.onBeforeDestroy.apply(this, arguments);
if (typeof this._mediaManager === 'object') {
@ -351,7 +365,7 @@ define([
});
Module.ImageWidgetView = ImageWidgetView;
App.on('before:start', function() {
App.on('before:start', function(App, options) {
App.registerBlockType('image', {
blockModel: Module.ImageBlockModel,
blockView: Module.ImageBlockView,

View File

@ -166,8 +166,8 @@ define([
this.model.reply('blockView', this.notifyAboutSelf, this);
},
onRender: function() {
if (!this.toolsRegion.hasView()) {
this.toolsRegion.show(this.toolsView);
if (!this.getRegion('toolsRegion').hasView()) {
this.showChildView('toolsRegion', this.toolsView);
}
this.trigger('showSettings');
@ -177,7 +177,7 @@ define([
disableDragAndDrop: true,
emptyContainerMessage: MailPoet.I18n.t('noPostsToDisplay'),
};
this.postsRegion.show(new ContainerView({ model: this.model.get('_transformedPosts'), renderOptions: renderOptions }));
this.showChildView('postsRegion', new ContainerView({ model: this.model.get('_transformedPosts'), renderOptions: renderOptions }));
},
notifyAboutSelf: function() {
return this;
@ -202,7 +202,7 @@ define([
'click .mailpoet_settings_posts_show_post_selection': 'switchToPostSelection',
'click .mailpoet_settings_posts_insert_selected': 'insertPosts',
},
templateHelpers: function() {
templateContext: function() {
return {
model: this.model.toJSON(),
};
@ -259,16 +259,24 @@ define([
},
});
var PostSelectionSettingsView = Marionette.CompositeView.extend({
getTemplate: function() { return templates.postSelectionPostsBlockSettings; },
getChildView: function() { return SinglePostSelectionSettingsView; },
childViewContainer: '.mailpoet_post_selection_container',
getEmptyView: function() { return EmptyPostSelectionSettingsView; },
var PostsSelectionCollectionView = Marionette.CollectionView.extend({
childView: function() { return SinglePostSelectionSettingsView; },
emptyView: function() { return EmptyPostSelectionSettingsView; },
childViewOptions: function() {
return {
blockModel: this.model,
blockModel: this.blockModel,
};
},
initialize: function(options) {
this.blockModel = options.blockModel;
},
});
var PostSelectionSettingsView = Marionette.View.extend({
getTemplate: function() { return templates.postSelectionPostsBlockSettings; },
regions: {
posts: '.mailpoet_post_selection_container',
},
events: function() {
return {
'change .mailpoet_settings_posts_content_type': _.partial(this.changeField, 'contentType'),
@ -276,21 +284,19 @@ define([
'input .mailpoet_posts_search_term': _.partial(this.changeField, 'search'),
};
},
constructor: function() {
// Set the block collection to be handled by this view as well
arguments[0].collection = arguments[0].model.get('_availablePosts');
Marionette.CompositeView.apply(this, arguments);
},
onRender: function() {
// Dynamically update available post types
CommunicationComponent.getPostTypes().done(_.bind(this._updateContentTypes, this));
var postsView = new PostsSelectionCollectionView({
collection: this.model.get('_availablePosts'),
blockModel: this.model
});
this.showChildView('posts', postsView);
},
onAttach: function() {
var that = this;
// Dynamically update available post types
//CommunicationComponent.getPostTypes().done(_.bind(this._updateContentTypes, this));
this.$('.mailpoet_posts_categories_and_tags').select2({
multiple: true,
allowClear: true,
@ -372,18 +378,18 @@ define([
},
});
var EmptyPostSelectionSettingsView = Marionette.ItemView.extend({
var EmptyPostSelectionSettingsView = Marionette.View.extend({
getTemplate: function() { return templates.emptyPostPostsBlockSettings; },
});
var SinglePostSelectionSettingsView = Marionette.ItemView.extend({
var SinglePostSelectionSettingsView = Marionette.View.extend({
getTemplate: function() { return templates.singlePostPostsBlockSettings; },
events: function() {
return {
'change .mailpoet_select_post_checkbox': 'postSelectionChange',
};
},
templateHelpers: function() {
templateContext: function() {
return {
model: this.model.toJSON(),
index: this._index,
@ -428,7 +434,7 @@ define([
"change .mailpoet_posts_sort_by": _.partial(this.changeField, "sortBy"),
};
},
templateHelpers: function() {
templateContext: function() {
return {
model: this.model.toJSON(),
};
@ -520,7 +526,7 @@ define([
},
});
App.on('before:start', function() {
App.on('before:start', function(App, options) {
App.registerBlockType('posts', {
blockModel: Module.PostsBlockModel,
blockView: Module.PostsBlockView,

View File

@ -17,6 +17,7 @@ define([
base = BaseBlock,
SocialBlockSettingsIconSelectorView,
SocialBlockSettingsIconView,
SocialBlockSettingsIconCollectionView,
SocialBlockSettingsStylesView;
Module.SocialIconModel = SuperModel.extend({
@ -82,13 +83,13 @@ define([
},
});
var SocialIconView = Marionette.ItemView.extend({
var SocialIconView = Marionette.View.extend({
tagName: 'span',
getTemplate: function() { return templates.socialIconBlock; },
modelEvents: {
'change': 'render',
},
templateHelpers: function() {
templateContext: function() {
var allIconSets = App.getAvailableStyles().get('socialIconSets');
return {
model: this.model.toJSON(),
@ -98,150 +99,29 @@ define([
},
});
Module.SocialBlockView = Marionette.CompositeView.extend({
regionClass: Marionette.Region,
Module.SocialIconCollectionView = Marionette.CollectionView.extend({
childView: SocialIconView,
});
Module.SocialBlockView = base.BlockView.extend({
className: 'mailpoet_block mailpoet_social_block mailpoet_droppable_block',
getTemplate: function() { return templates.socialBlock; },
childViewContainer: '.mailpoet_social',
modelEvents: {
'change': 'render',
'delete': 'deleteBlock',
},
events: {
"mouseover": "showTools",
"mouseout": "hideTools",
},
regions: {
toolsRegion: '> .mailpoet_tools',
},
regions: _.extend({}, base.BlockView.prototype.regions, {
icons: '.mailpoet_social'
}),
ui: {
tools: '> .mailpoet_tools'
},
behaviors: {
DraggableBehavior: {
cloneOriginal: true,
hideOriginal: true,
onDrop: function(options) {
// After a clone of model has been dropped, cleanup
// and destroy self
options.dragBehavior.view.model.destroy();
},
onDragSubstituteBy: function(behavior) {
var WidgetView, node;
// When block is being dragged, display the widget icon instead.
// This will create an instance of block's widget view and
// use it's rendered DOM element instead of the content block
if (_.isFunction(behavior.view.onDragSubstituteBy)) {
WidgetView = new (behavior.view.onDragSubstituteBy())();
WidgetView.render();
node = WidgetView.$el.get(0).cloneNode(true);
WidgetView.destroy();
return node;
}
},
},
HighlightEditingBehavior: {},
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
ShowSettingsBehavior: {},
},
}),
onDragSubstituteBy: function() { return Module.SocialWidgetView; },
constructor: function() {
// Set the block collection to be handled by this view as well
arguments[0].collection = arguments[0].model.get('icons');
Marionette.CompositeView.apply(this, arguments);
},
initialize: function() {
this.on('showSettings', this.showSettings, this);
this.on('dom:refresh', this.showBlock, this);
this._isFirstRender = true;
},
// Determines which view type should be used for a child
childView: SocialIconView,
templateHelpers: function() {
return {
model: this.model.toJSON(),
viewCid: this.cid,
};
},
onRender: function() {
this._rebuildRegions();
this.toolsView = new Module.SocialBlockToolsView({ model: this.model });
this.toolsRegion.show(this.toolsView);
},
onBeforeDestroy: function() {
this.regionManager.destroy();
},
showTools: function(_event) {
this.$(this.ui.tools).addClass('mailpoet_display_tools');
_event.stopPropagation();
},
hideTools: function(_event) {
this.$(this.ui.tools).removeClass('mailpoet_display_tools');
_event.stopPropagation();
},
showSettings: function(options) {
this.toolsView.triggerMethod('showSettings', options);
},
getDropFunc: function() {
return function() {
return this.model.clone();
}.bind(this);
},
_buildRegions: function(regions) {
var that = this;
var defaults = {
regionClass: this.getOption('regionClass'),
parentEl: function() { return that.$el; }
};
return this.regionManager.addRegions(regions, defaults);
},
_rebuildRegions: function() {
if (this.regionManager === undefined) {
this.regionManager = new Marionette.RegionManager();
}
this.regionManager.destroy();
_.extend(this, this._buildRegions(this.regions));
},
showBlock: function() {
if (this._isFirstRender) {
this.transitionIn();
this._isFirstRender = false;
}
},
deleteBlock: function() {
this.transitionOut().done(function() {
this.model.destroy();
}.bind(this));
},
transitionIn: function() {
return this._transition('slideDown', 'fadeIn', 'easeIn');
},
transitionOut: function() {
return this._transition('slideUp', 'fadeOut', 'easeOut');
},
_transition: function(slideDirection, fadeDirection, easing) {
var promise = jQuery.Deferred();
this.$el.velocity(
slideDirection,
{
duration: 250,
easing: easing,
complete: function() {
promise.resolve();
}.bind(this),
}
).velocity(
fadeDirection,
{
duration: 250,
easing: easing,
queue: false, // Do not enqueue, trigger animation in parallel
}
);
return promise;
this.showChildView('toolsRegion', this.toolsView);
this.showChildView('icons', new Module.SocialIconCollectionView({
collection: this.model.get('icons')
}))
},
});
@ -268,13 +148,13 @@ define([
this._stylesView = new SocialBlockSettingsStylesView({ model: this.model });
},
onRender: function() {
this.iconRegion.show(this._iconSelectorView);
this.stylesRegion.show(this._stylesView);
this.showChildView('iconRegion', this._iconSelectorView);
this.showChildView('stylesRegion', this._stylesView);
}
});
// Single icon settings view, used by the selector view
SocialBlockSettingsIconView = Marionette.ItemView.extend({
SocialBlockSettingsIconView = Marionette.View.extend({
getTemplate: function() { return templates.socialSettingsIcon; },
events: function() {
return {
@ -294,17 +174,16 @@ define([
this.$('.mailpoet_social_icon_image').attr('alt', this.model.get('text'));
},
},
templateHelpers: function() {
templateContext: function() {
var icons = App.getConfig().get('socialIcons'),
// Construct icon type list of format [{iconType: 'type', title: 'Title'}, ...]
availableIconTypes = _.map(_.keys(icons.attributes), function(key) { return { iconType: key, title: icons.get(key).get('title') }; }),
allIconSets = App.getAvailableStyles().get('socialIconSets');
return {
model: this.model.toJSON(),
return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), {
iconTypes: availableIconTypes,
currentType: icons.get(this.model.get('iconType')).toJSON(),
allIconSets: allIconSets.toJSON(),
};
});
},
deleteIcon: function() {
this.model.destroy();
@ -321,34 +200,41 @@ define([
},
});
// Select icons section container view
SocialBlockSettingsIconSelectorView = Marionette.CompositeView.extend({
getTemplate: function() { return templates.socialSettingsIconSelector; },
childView: SocialBlockSettingsIconView,
SocialBlockSettingsIconCollectionView = Marionette.CollectionView.extend({
behaviors: {
SortableBehavior: {
items: '> div',
},
},
childViewContainer: '#mailpoet_social_icon_selector_contents',
childView: SocialBlockSettingsIconView,
});
// Select icons section container view
SocialBlockSettingsIconSelectorView = Marionette.View.extend({
getTemplate: function() { return templates.socialSettingsIconSelector; },
regions: {
'icons': '#mailpoet_social_icon_selector_contents'
},
events: {
'click .mailpoet_add_social_icon': 'addSocialIcon',
},
modelEvents: {
'change:iconSet': 'render',
},
behaviors: {
SortableBehavior: {
items: '#mailpoet_social_icon_selector_contents > div',
},
},
constructor: function() {
// Set the icon collection to be handled by this view as well
arguments[0].collection = arguments[0].model.get('icons');
Marionette.CompositeView.apply(this, arguments);
},
addSocialIcon: function() {
// Add a social icon with default values
this.collection.add({});
this.model.get('icons').add({});
},
onRender: function() {
this.showChildView('icons', new SocialBlockSettingsIconCollectionView({
collection: this.model.get('icons')
}));
}
});
SocialBlockSettingsStylesView = Marionette.ItemView.extend({
SocialBlockSettingsStylesView = Marionette.View.extend({
getTemplate: function() { return templates.socialSettingsStyles; },
modelEvents: {
'change': 'render',
@ -359,7 +245,7 @@ define([
initialize: function() {
this.listenTo(this.model.get('icons'), 'add remove change', this.render);
},
templateHelpers: function() {
templateContext: function() {
var allIconSets = App.getAvailableStyles().get('socialIconSets');
return {
activeSet: this.model.get('iconSet'),
@ -411,7 +297,7 @@ define([
},
});
App.on('before:start', function() {
App.on('before:start', function(App, options) {
App.registerBlockType('social', {
blockModel: Module.SocialBlockModel,
blockView: Module.SocialBlockView,

View File

@ -50,7 +50,7 @@ define([
},
onRender: function() {
this.toolsView = new Module.SpacerBlockToolsView({ model: this.model });
this.toolsRegion.show(this.toolsView);
this.showChildView('toolsRegion', this.toolsView);
},
changeHeight: function() {
this.$('.mailpoet_spacer').css('height', this.model.get('styles.block.height'));
@ -87,7 +87,7 @@ define([
},
});
App.on('before:start', function() {
App.on('before:start', function(App, options) {
App.registerBlockType('spacer', {
blockModel: Module.SpacerBlockModel,
blockView: Module.SpacerBlockView,

View File

@ -32,7 +32,7 @@ define([
validElements: "p[class|style],span[class|style],a[href|class|title|target|style],h1[class|style],h2[class|style],h3[class|style],ol[class|style],ul[class|style],li[class|style],strong[class|style],em[class|style],strike,br,blockquote[class|style],table[class|style],tr[class|style],th[class|style],td[class|style]",
invalidElements: "script",
blockFormats: 'Heading 1=h1;Heading 2=h2;Heading 3=h3;Paragraph=p',
plugins: "link code textcolor colorpicker mailpoet_shortcodes",
plugins: "link lists code textcolor colorpicker mailpoet_shortcodes paste",
configurationFilter: function(originalSettings) {
return _.extend({}, originalSettings, {
mailpoet_shortcodes: App.getConfig().get('shortcodes').toJSON(),
@ -58,7 +58,7 @@ define([
settings: false,
},
});
this.toolsRegion.show(this.toolsView);
this.showChildView('toolsRegion', this.toolsView);
},
onTextEditorChange: function(newContent) {
this.model.set('text', newContent);
@ -71,13 +71,6 @@ define([
this.enableDragging();
this.enableShowingTools();
},
disableDragging: function() {
this.$('.mailpoet_content').addClass('mailpoet_ignore_drag');
},
enableDragging: function() {
this.$('.mailpoet_content').removeClass('mailpoet_ignore_drag');
},
});
Module.TextBlockToolsView = base.BlockToolsView.extend({
@ -100,7 +93,7 @@ define([
},
});
App.on('before:start', function() {
App.on('before:start', function(App, options) {
App.registerBlockType('text', {
blockModel: Module.TextBlockModel,
blockView: Module.TextBlockView,

View File

@ -9,6 +9,7 @@ define([
Module._query = function(args) {
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'automatedLatestContent',
action: args.action,
data: args.options || {}
@ -81,6 +82,7 @@ define([
Module.saveNewsletter = function(options) {
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
action: 'save',
data: options || {}
@ -89,13 +91,14 @@ define([
Module.previewNewsletter = function(options) {
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
action: 'sendPreview',
data: options || {}
});
};
App.on('start', function(options) {
App.on('start', function(App, options) {
// Prefetch post types
Module.getPostTypes();
});

View File

@ -24,7 +24,7 @@ define([
return Module._config;
};
App.on('before:start', function(options) {
App.on('before:start', function(App, options) {
// Expose config methods globally
App.getConfig = Module.getConfig;
App.setConfig = Module.setConfig;

View File

@ -1,8 +1,9 @@
define([
'newsletter_editor/App',
'backbone.supermodel',
'underscore'
], function(App, SuperModel, _) {
'underscore',
'mailpoet'
], function(App, SuperModel, _, MailPoet) {
"use strict";
var Module = {};
@ -66,7 +67,7 @@ define([
return _.filter(blocks, predicate);
};
App.on('before:start', function(options) {
App.on('before:start', function(App, options) {
// Expose block methods globally
App.registerBlockType = Module.registerBlockType;
App.getBlockTypeModel = Module.getBlockTypeModel;
@ -79,15 +80,24 @@ define([
Module.newsletter = new Module.NewsletterModel(_.omit(_.clone(options.newsletter), ['body']));
});
App.on('start', function(options) {
App.on('start', function(App, options) {
var body = options.newsletter.body;
App._contentContainer = new (App.getBlockTypeModel('container'))(body.content, {parse: true});
var content = (_.has(body, 'content')) ? body.content : {};
if (!_.has(options.newsletter, 'body') || !_.isObject(options.newsletter.body)) {
MailPoet.Notice.error(
MailPoet.I18n.t('newsletterBodyIsCorrupted'),
{ static: true }
);
}
App._contentContainer = new (App.getBlockTypeModel('container'))(content, {parse: true});
App._contentContainerView = new (App.getBlockTypeView('container'))({
model: App._contentContainer,
renderOptions: { depth: 0 },
});
App._appView.contentRegion.show(App._contentContainerView);
App._appView.showChildView('contentRegion', App._contentContainerView);
});

View File

@ -10,9 +10,9 @@ define([
var Module = {};
Module.HeadingView = Marionette.ItemView.extend({
Module.HeadingView = Marionette.View.extend({
getTemplate: function() { return templates.heading; },
templateHelpers: function() {
templateContext: function() {
return {
model: this.model.toJSON(),
};
@ -28,8 +28,8 @@ define([
},
});
App.on('start', function(options) {
App._appView.headingRegion.show(new Module.HeadingView({ model: App.getNewsletter() }));
App.on('start', function(App, options) {
App._appView.showChildView('headingRegion', new Module.HeadingView({ model: App.getNewsletter() }));
});
return Module;

View File

@ -40,15 +40,14 @@ define([
App.getChannel().trigger('beforeEditorSave', json);
// save newsletter
CommunicationComponent.saveNewsletter(json).done(function(response) {
return CommunicationComponent.saveNewsletter(json).done(function(response) {
if(response.success !== undefined && response.success === true) {
// TODO: Handle translations
//MailPoet.Notice.success("<?php _e('Newsletter has been saved.'); ?>");
} else if(response.error !== undefined) {
if(response.error.length === 0) {
// TODO: Handle translations
MailPoet.Notice.error(
"An unknown error occurred, please check your settings.",
MailPoet.I18n.t('templateSaveFailed'),
{
scroll: true,
}
@ -66,6 +65,14 @@ define([
});
};
// For getting a promise after triggering save event
Module.saveAndProvidePromise = function(saveResult) {
var promise = Module.save();
if (saveResult !== undefined) {
saveResult.promise = promise;
}
};
Module.getThumbnail = function(element, options) {
var promise = html2canvas(element, options || {});
@ -102,6 +109,7 @@ define([
});
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletterTemplates',
action: 'save',
data: data
@ -135,7 +143,7 @@ define([
});
};
Module.SaveView = Marionette.LayoutView.extend({
Module.SaveView = Marionette.View.extend({
getTemplate: function() { return templates.save; },
events: {
'click .mailpoet_save_button': 'save',
@ -161,7 +169,7 @@ define([
},
beforeSave: function() {
// TODO: Add a loading animation instead
this.$('.mailpoet_autosaved_at').text('Saving...');
this.$('.mailpoet_autosaved_at').text(MailPoet.I18n.t('saving'));
},
afterSave: function(json, response) {
this.validateNewsletter(json);
@ -322,8 +330,7 @@ define([
Module.beforeExitWithUnsavedChanges = function(e) {
if (saveTimeout) {
// TODO: Translate this message
var message = "There are unsaved changes which will be lost if you leave this page.";
var message = MailPoet.I18n.t('unsavedChangesWillBeLost');
e = e || window.event;
if (e) {
@ -334,18 +341,18 @@ define([
}
};
App.on('before:start', function(options) {
App.save = Module.save;
App.on('before:start', function(App, options) {
App.save = Module.saveAndProvidePromise;
App.getChannel().on('autoSave', Module.autoSave);
window.onbeforeunload = Module.beforeExitWithUnsavedChanges;
App.getChannel().on('save', function() { App.save(); });
App.getChannel().on('save', function(saveResult) { App.save(saveResult); });
});
App.on('start', function(options) {
App.on('start', function(App, options) {
var saveView = new Module.SaveView();
App._appView.bottomRegion.show(saveView);
App._appView.showChildView('bottomRegion', saveView);
});
return Module;

View File

@ -52,7 +52,7 @@ define([
Module.registerLayoutWidget = function(widget) { return Module._layoutWidgets.add(widget); };
Module.getLayoutWidgets = function() { return Module._layoutWidgets; };
var SidebarView = Marionette.LayoutView.extend({
var SidebarView = Marionette.View.extend({
getTemplate: function() { return templates.sidebar; },
regions: {
contentRegion: '.mailpoet_content_region',
@ -96,17 +96,17 @@ define([
.on('scroll', this.updateHorizontalScroll.bind(this));
},
onRender: function() {
this.contentRegion.show(new Module.SidebarWidgetsView({
collection: App.getWidgets(),
}));
this.layoutRegion.show(new Module.SidebarLayoutWidgetsView({
collection: App.getLayoutWidgets(),
}));
this.stylesRegion.show(new Module.SidebarStylesView({
this.showChildView('contentRegion', new Module.SidebarWidgetsView(
App.getWidgets()
));
this.showChildView('layoutRegion', new Module.SidebarLayoutWidgetsView(
App.getLayoutWidgets()
));
this.showChildView('stylesRegion', new Module.SidebarStylesView({
model: App.getGlobalStyles(),
availableStyles: App.getAvailableStyles(),
}));
this.previewRegion.show(new Module.SidebarPreviewView());
this.showChildView('previewRegion', new Module.SidebarPreviewView());
},
updateHorizontalScroll: function() {
// Fixes the sidebar so that on narrower screens the horizontal
@ -136,15 +136,31 @@ define([
},
});
/**
* Draggable widget collection view
*/
Module.SidebarWidgetsCollectionView = Marionette.CollectionView.extend({
childView: function(item) { return item.get('widgetView'); }
});
/**
* Responsible for rendering draggable content widgets
*/
Module.SidebarWidgetsView = Marionette.CompositeView.extend({
Module.SidebarWidgetsView = Marionette.View.extend({
getTemplate: function() { return templates.sidebarContent; },
getChildView: function(model) {
return model.get('widgetView');
regions: {
widgets: '.mailpoet_region_content'
},
childViewContainer: '.mailpoet_region_content',
initialize: function(widgets) {
this.widgets = widgets;
},
onRender: function() {
this.showChildView('widgets', new Module.SidebarWidgetsCollectionView({
collection: this.widgets
}));
}
});
/**
@ -153,11 +169,15 @@ define([
Module.SidebarLayoutWidgetsView = Module.SidebarWidgetsView.extend({
getTemplate: function() { return templates.sidebarLayout; },
});
/**
* Responsible for managing global styles
*/
Module.SidebarStylesView = Marionette.LayoutView.extend({
Module.SidebarStylesView = Marionette.View.extend({
getTemplate: function() { return templates.sidebarStyles; },
behaviors: {
ColorPickerBehavior: {},
},
events: function() {
return {
"change #mailpoet_text_font_color": _.partial(this.changeColorField, 'text.fontColor'),
@ -196,7 +216,7 @@ define([
"change #mailpoet_background_color": _.partial(this.changeColorField, 'body.backgroundColor'),
};
},
templateHelpers: function() {
templateContext: function() {
return {
model: this.model.toJSON(),
availableStyles: this.availableStyles.toJSON(),
@ -205,15 +225,6 @@ define([
initialize: function(options) {
this.availableStyles = options.availableStyles;
},
onRender: function() {
this.$('.mailpoet_color').spectrum({
clickoutFiresChange: true,
showInput: true,
showInitial: true,
preferredFormat: "hex6",
allowEmpty: true,
});
},
changeField: function(field, event) {
this.model.set(field, jQuery(event.target).val());
},
@ -226,7 +237,7 @@ define([
},
});
Module.SidebarPreviewView = Marionette.LayoutView.extend({
Module.SidebarPreviewView = Marionette.View.extend({
getTemplate: function() { return templates.sidebarPreview; },
events: {
'click .mailpoet_show_preview': 'showPreview',
@ -249,6 +260,7 @@ define([
MailPoet.Modal.loading(true);
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
action: 'showPreview',
data: json,
@ -301,31 +313,37 @@ define([
// send test email
MailPoet.Modal.loading(true);
CommunicationComponent.previewNewsletter(data).always(function() {
MailPoet.Modal.loading(false);
}).done(function(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('newsletterPreviewSent'),
{ scroll: true });
}).fail(function(response) {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true, static: true }
);
}
// save before sending
var saveResult = {promise: null};
App.getChannel().trigger('save', saveResult);
saveResult.promise.always(function() {
CommunicationComponent.previewNewsletter(data).always(function() {
MailPoet.Modal.loading(false);
}).done(function(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('newsletterPreviewSent'),
{ scroll: true });
}).fail(function(response) {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true, static: true }
);
}
});
});
},
});
Module.NewsletterPreviewView = Marionette.ItemView.extend({
Module.NewsletterPreviewView = Marionette.View.extend({
getTemplate: function() { return templates.newsletterPreview; },
initialize: function(options) {
this.previewUrl = options.previewUrl;
this.width = App.getConfig().get('newsletterPreview.width');
this.height = App.getConfig().get('newsletterPreview.height')
},
templateHelpers: function() {
templateContext: function() {
return {
previewUrl: this.previewUrl,
width: this.width,
@ -334,18 +352,18 @@ define([
}
});
App.on('before:start', function(options) {
App.on('before:start', function(App, options) {
App.registerWidget = Module.registerWidget;
App.getWidgets = Module.getWidgets;
App.registerLayoutWidget = Module.registerLayoutWidget;
App.getLayoutWidgets = Module.getLayoutWidgets;
});
App.on('start', function(options) {
App.on('start', function(App, options) {
var stylesModel = App.getGlobalStyles(),
sidebarView = new SidebarView();
App._appView.sidebarRegion.show(sidebarView);
App._appView.showChildView('sidebarRegion', sidebarView);
});
return Module;

View File

@ -46,11 +46,14 @@ define([
},
});
Module.StylesView = Marionette.ItemView.extend({
Module.StylesView = Marionette.View.extend({
getTemplate: function() { return templates.styles; },
modelEvents: {
'change': 'render',
},
serializeData: function() {
return this.model.toJSON();
}
});
Module._globalStyles = new SuperModel();
@ -65,20 +68,20 @@ define([
return App.getConfig().get('availableStyles');
};
App.on('before:start', function(options) {
App.on('before:start', function(App, options) {
// Expose style methods to global application
App.getGlobalStyles = Module.getGlobalStyles;
App.setGlobalStyles = Module.setGlobalStyles;
App.getAvailableStyles = Module.getAvailableStyles;
var body = options.newsletter.body;
this.setGlobalStyles(body.globalStyles);
var globalStyles = (_.has(body, 'globalStyles')) ? body.globalStyles : {};
this.setGlobalStyles(globalStyles);
});
App.on('start', function(options) {
App.on('start', function(App, options) {
var stylesView = new Module.StylesView({ model: App.getGlobalStyles() });
App._appView.stylesRegion.show(stylesView);
App._appView.showChildView('stylesRegion', stylesView);
});
return Module;

View File

@ -11,13 +11,13 @@
/*jshint unused:false */
/*global tinymce:true */
tinymce.PluginManager.add('mailpoet_shortcodes', function(editor, url) {
var appendLabelAndClose = function(text) {
editor.insertContent('[' + text + ']');
var appendLabelAndClose = function(shortcode) {
editor.insertContent(shortcode);
editor.windowManager.close();
},
generateOnClickFunc = function(id) {
generateOnClickFunc = function(shortcode) {
return function() {
appendLabelAndClose(id);
appendLabelAndClose(shortcode);
};
};

View File

@ -0,0 +1,37 @@
import React from 'react'
import classNames from 'classnames'
import ReactTooltip from 'react-tooltip'
class Badge extends React.Component {
render() {
const badgeClasses = classNames(
'mailpoet_badge',
this.props.type ? `mailpoet_badge_${this.props.type}` : ''
);
const tooltip = this.props.tooltip ? this.props.tooltip.replace(/\n/g, '<br />') : false;
// tooltip ID must be unique, defaults to tooltip text
const tooltipId = this.props.tooltipId || tooltip;
return (
<span>
<span
className={badgeClasses}
data-tip={tooltip}
data-for={tooltipId}
>
{this.props.name}
</span>
{ tooltip && (
<ReactTooltip
place="right"
multiline={true}
id={tooltipId}
/>
) }
</span>
);
}
}
export default Badge;

View File

@ -0,0 +1,105 @@
import MailPoet from 'mailpoet'
import React from 'react'
import Badge from './badge.jsx'
const badges = {
excellent: {
name: MailPoet.I18n.t('excellentBadgeName'),
tooltipTitle: MailPoet.I18n.t('excellentBadgeTooltip')
},
good: {
name: MailPoet.I18n.t('goodBadgeName'),
tooltipTitle: MailPoet.I18n.t('goodBadgeTooltip')
},
bad: {
name: MailPoet.I18n.t('badBadgeName'),
tooltipTitle: MailPoet.I18n.t('badBadgeTooltip')
}
};
const stats = {
opened: {
badgeRanges: [30, 10, 0],
badgeTypes: [
'excellent',
'good',
'bad'
],
tooltipText: MailPoet.I18n.t('openedStatTooltip'),
},
clicked: {
badgeRanges: [3, 1, 0],
badgeTypes: [
'excellent',
'good',
'bad'
],
tooltipText: MailPoet.I18n.t('clickedStatTooltip')
},
unsubscribed: {
badgeRanges: [3, 1, 0],
badgeTypes: [
'bad',
'good',
'excellent'
],
tooltipText: MailPoet.I18n.t('unsubscribedStatTooltip')
},
};
class StatsBadge extends React.Component {
getBadgeType(stat, rate) {
const len = stat.badgeRanges.length;
for (var i = 0; i < len; i++) {
if (rate > stat.badgeRanges[i]) {
return stat.badgeTypes[i];
}
}
// rate must be zero at this point
return stat.badgeTypes[len - 1];
}
render() {
const stat = stats[this.props.stat] || null;
if (!stat) {
return null;
}
const rate = this.props.rate;
if (rate < 0 || rate > 100) {
return null;
}
const badgeType = this.getBadgeType(stat, rate);
const badge = badges[badgeType] || null;
if (!badge) {
return null;
}
const tooltipText = `${badge.tooltipTitle}\n\n${stat.tooltipText}`;
const tooltipId = this.props.tooltipId || null;
const content = (
<Badge
type={badgeType}
name={badge.name}
tooltip={tooltipText}
tooltipId={tooltipId}
/>
);
if (this.props.headline) {
return (
<div>
<span className={`mailpoet_stat_${badgeType}`}>
{this.props.headline}
</span> {content}
</div>
);
}
return content;
}
}
export default StatsBadge;

View File

@ -1,13 +1,18 @@
import React from 'react'
import ReactDOM from 'react-dom'
import ReactStringReplace from 'react-string-replace'
import { Link } from 'react-router'
import MailPoet from 'mailpoet'
import classNames from 'classnames'
import moment from 'moment'
import jQuery from 'jquery'
import Hooks from 'wp-js-hooks'
import StatsBadge from 'newsletters/badges/stats.jsx'
const _QueueMixin = {
pauseSending: function(newsletter) {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'sendingQueue',
action: 'pause',
data: {
@ -27,6 +32,7 @@ const _QueueMixin = {
},
resumeSending: function(newsletter) {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'sendingQueue',
action: 'resume',
data: {
@ -138,40 +144,162 @@ const _QueueMixin = {
};
const _StatisticsMixin = {
renderStatistics: function(newsletter) {
if (
newsletter.statistics
&& newsletter.queue
&& newsletter.queue.status !== 'scheduled'
) {
const total_sent = ~~(newsletter.queue.count_processed);
let percentage_clicked = 0;
let percentage_opened = 0;
let percentage_unsubscribed = 0;
if (total_sent > 0) {
percentage_clicked = Math.round(
(~~(newsletter.statistics.clicked) * 100) / total_sent
);
percentage_opened = Math.round(
(~~(newsletter.statistics.opened) * 100) / total_sent
);
percentage_unsubscribed = Math.round(
(~~(newsletter.statistics.unsubscribed) * 100) / total_sent
);
}
return (
<span>
{ percentage_opened }%, { percentage_clicked }%, { percentage_unsubscribed }%
</span>
);
} else {
renderStatistics: function(newsletter, is_sent, current_time) {
if (is_sent === undefined) {
// condition for standard and post notification listings
is_sent = newsletter.statistics
&& newsletter.queue
&& newsletter.queue.status !== 'scheduled'
}
if (!is_sent) {
return (
<span>{MailPoet.I18n.t('notSentYet')}</span>
);
}
let params = {};
params = Hooks.applyFilters('mailpoet_newsletters_listing_stats_before', params, newsletter);
// welcome emails provide explicit total_sent value
const total_sent = ~~(newsletter.total_sent || newsletter.queue.count_processed);
let percentage_clicked = 0;
let percentage_opened = 0;
let percentage_unsubscribed = 0;
if (total_sent > 0) {
percentage_clicked = (newsletter.statistics.clicked * 100) / total_sent;
percentage_opened = (newsletter.statistics.opened * 100) / total_sent;
percentage_unsubscribed = (newsletter.statistics.unsubscribed * 100) / total_sent;
}
// format to 1 decimal place
const percentage_clicked_display = MailPoet.Num.toLocaleFixed(percentage_clicked, 1);
const percentage_opened_display = MailPoet.Num.toLocaleFixed(percentage_opened, 1);
const percentage_unsubscribed_display = MailPoet.Num.toLocaleFixed(percentage_unsubscribed, 1);
let show_stats_timeout,
newsletter_date,
sent_hours_ago,
too_early_for_stats,
show_kb_link;
if (current_time !== undefined) {
// standard emails and post notifications:
// display green box for newsletters that were just sent
show_stats_timeout = 6; // in hours
newsletter_date = newsletter.queue.scheduled_at || newsletter.queue.created_at;
sent_hours_ago = moment(current_time).diff(moment(newsletter_date), 'hours');
too_early_for_stats = sent_hours_ago < show_stats_timeout;
show_kb_link = true;
} else {
// welcome emails: no green box and KB link
too_early_for_stats = false;
show_kb_link = false;
}
const improveStatsKBLink = 'http://beta.docs.mailpoet.com/article/191-how-to-improve-my-open-and-click-rates';
// thresholds to display badges
const min_newsletters_sent = 20;
const min_newsletter_opens = 5;
let content;
if (total_sent >= min_newsletters_sent
&& newsletter.statistics.opened >= min_newsletter_opens
&& !too_early_for_stats
) {
// display stats with badges
content = (
<div className="mailpoet_stats_text">
<div>
<span>{ percentage_opened_display }% </span>
<StatsBadge
stat="opened"
rate={percentage_opened}
tooltipId={`opened-${newsletter.id}`}
/>
</div>
<div>
<span>{ percentage_clicked_display }% </span>
<StatsBadge
stat="clicked"
rate={percentage_clicked}
tooltipId={`clicked-${newsletter.id}`}
/>
</div>
<div>
<span className="mailpoet_stat_hidden">{ percentage_unsubscribed_display }%</span>
</div>
</div>
);
} else {
// display simple stats
content = (
<div>
<span className="mailpoet_stats_text">
{ percentage_opened_display }%,
{ " " }
{ percentage_clicked_display }%
<span className="mailpoet_stat_hidden">
, { percentage_unsubscribed_display }%
</span>
</span>
{ too_early_for_stats && (
<div className="mailpoet_badge mailpoet_badge_green">
{MailPoet.I18n.t('checkBackInHours')
.replace('%$1d', show_stats_timeout - sent_hours_ago)}
</div>
) }
</div>
);
}
// thresholds to display bad open rate help
const max_percentage_opened = 5;
const min_sent_hours_ago = 24;
const min_total_sent = 10;
let after_content;
if (show_kb_link
&& percentage_opened < max_percentage_opened
&& sent_hours_ago >= min_sent_hours_ago
&& total_sent >= min_total_sent
) {
// help link for bad open rate
after_content = (
<div>
<a
href={improveStatsKBLink}
target="_blank"
className="mailpoet_stat_link_small"
>
{MailPoet.I18n.t('improveThisLinkText')}
</a>
</div>
);
}
if (total_sent > 0 && params.link) {
// wrap content in a link
return (
<div>
<Link
key={ `stats-${newsletter.id}` }
to={ params.link }
>
{content}
</Link>
{after_content}
</div>
);
}
return (
<div>
{content}
{after_content}
</div>
);
}
}
@ -225,6 +353,7 @@ const _MailerMixin = {
},
resumeMailerSending() {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'mailer',
action: 'resumeSending'
}).done(function() {

View File

@ -98,7 +98,7 @@ const columns = [
const bulk_actions = [
{
name: 'trash',
label: MailPoet.I18n.t('trash'),
label: MailPoet.I18n.t('moveToTrash'),
onSuccess: messages.onTrash
}
];
@ -129,6 +129,7 @@ const newsletter_actions = [
label: MailPoet.I18n.t('duplicate'),
onClick: function(newsletter, refresh) {
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
action: 'duplicate',
data: {
@ -164,6 +165,7 @@ const NewsletterListNotification = React.createClass({
e.persist();
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
action: 'setStatus',
data: {
@ -340,4 +342,4 @@ const NewsletterListNotification = React.createClass({
}
});
module.exports = NewsletterListNotification;
module.exports = NewsletterListNotification;

View File

@ -3,6 +3,7 @@ import { Router, Link } from 'react-router'
import classNames from 'classnames'
import jQuery from 'jquery'
import MailPoet from 'mailpoet'
import Hooks from 'wp-js-hooks'
import Listing from 'listing/listing.jsx'
import ListingTabs from 'newsletters/listings/tabs.jsx'
@ -40,7 +41,7 @@ const columns = [
}
];
const newsletter_actions = [
let newsletter_actions = [
{
name: 'view',
link: function(newsletter) {
@ -53,8 +54,15 @@ const newsletter_actions = [
}
];
newsletter_actions = Hooks.applyFilters('mailpoet_newsletters_listings_notification_history_actions', newsletter_actions);
const NewsletterListNotificationHistory = React.createClass({
mixins: [ QueueMixin, StatisticsMixin, MailerMixin ],
renderSentDate: function(newsletter) {
return (newsletter.queue.status === 'completed')
? ( <abbr>{ MailPoet.Date.format(newsletter.updated_at) }</abbr> )
: MailPoet.I18n.t('notSentYet')
},
renderItem: function(newsletter, actions, meta) {
const rowClasses = classNames(
'manage-column',
@ -75,7 +83,7 @@ const NewsletterListNotificationHistory = React.createClass({
<a
href={ newsletter.preview_url }
target="_blank"
>{ newsletter.queue.newsletter_rendered_subject }</a>
>{ newsletter.queue.newsletter_rendered_subject || newsletter.subject }</a>
</strong>
{ actions }
</td>
@ -87,11 +95,11 @@ const NewsletterListNotificationHistory = React.createClass({
</td>
{ (mailpoet_tracking_enabled === true) ? (
<td className="column" data-colname={ MailPoet.I18n.t('statistics') }>
{ this.renderStatistics(newsletter) }
{ this.renderStatistics(newsletter, undefined, meta.current_time) }
</td>
) : null }
<td className="column-date" data-colname={ MailPoet.I18n.t('lastModifiedOn') }>
<abbr>{ MailPoet.Date.format(newsletter.updated_at) }</abbr>
{ this.renderSentDate(newsletter) }
</td>
</div>
);

View File

@ -3,6 +3,7 @@ import { Router, Link } from 'react-router'
import classNames from 'classnames'
import jQuery from 'jquery'
import MailPoet from 'mailpoet'
import Hooks from 'wp-js-hooks'
import Listing from 'listing/listing.jsx'
import ListingTabs from 'newsletters/listings/tabs.jsx'
@ -93,12 +94,12 @@ const columns = [
const bulk_actions = [
{
name: 'trash',
label: MailPoet.I18n.t('trash'),
label: MailPoet.I18n.t('moveToTrash'),
onSuccess: messages.onTrash
}
];
const newsletter_actions = [
let newsletter_actions = [
{
name: 'view',
link: function(newsletter) {
@ -124,6 +125,7 @@ const newsletter_actions = [
label: MailPoet.I18n.t('duplicate'),
onClick: function(newsletter, refresh) {
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
action: 'duplicate',
data: {
@ -151,6 +153,8 @@ const newsletter_actions = [
}
];
newsletter_actions = Hooks.applyFilters('mailpoet_newsletters_listings_standard_actions', newsletter_actions);
const NewsletterListStandard = React.createClass({
mixins: [ QueueMixin, StatisticsMixin, MailerMixin ],
renderItem: function(newsletter, actions, meta) {
@ -183,7 +187,7 @@ const NewsletterListStandard = React.createClass({
</td>
{ (mailpoet_tracking_enabled === true) ? (
<td className="column" data-colname={ MailPoet.I18n.t('statistics') }>
{ this.renderStatistics(newsletter) }
{ this.renderStatistics(newsletter, undefined, meta.current_time) }
</td>
) : null }
<td className="column-date" data-colname={ MailPoet.I18n.t('lastModifiedOn') }>
@ -223,4 +227,4 @@ const NewsletterListStandard = React.createClass({
}
});
module.exports = NewsletterListStandard;
module.exports = NewsletterListStandard;

View File

@ -5,12 +5,13 @@ import { createHashHistory } from 'history'
import Listing from 'listing/listing.jsx'
import ListingTabs from 'newsletters/listings/tabs.jsx'
import { MailerMixin } from 'newsletters/listings/mixins.jsx'
import { StatisticsMixin, MailerMixin } from 'newsletters/listings/mixins.jsx'
import classNames from 'classnames'
import jQuery from 'jquery'
import MailPoet from 'mailpoet'
import _ from 'underscore'
import Hooks from 'wp-js-hooks'
const mailpoet_roles = window.mailpoet_roles || {};
const mailpoet_segments = window.mailpoet_segments || {};
@ -95,12 +96,12 @@ const columns = [
const bulk_actions = [
{
name: 'trash',
label: MailPoet.I18n.t('trash'),
label: MailPoet.I18n.t('moveToTrash'),
onSuccess: messages.onTrash
}
];
const newsletter_actions = [
let newsletter_actions = [
{
name: 'view',
link: function(newsletter) {
@ -121,46 +122,22 @@ const newsletter_actions = [
);
}
},
{
name: 'duplicate',
label: MailPoet.I18n.t('duplicate'),
onClick: function(newsletter, refresh) {
return MailPoet.Ajax.post({
endpoint: 'newsletters',
action: 'duplicate',
data: {
id: newsletter.id
}
}).done((response) => {
MailPoet.Notice.success(
(MailPoet.I18n.t('newsletterDuplicated')).replace(
'%$1s', response.data.subject
)
);
refresh();
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
}
});
}
},
{
name: 'trash'
}
];
newsletter_actions = Hooks.applyFilters('mailpoet_newsletters_listings_welcome_notification_actions', newsletter_actions);
const NewsletterListWelcome = React.createClass({
mixins: [ MailerMixin ],
mixins: [ StatisticsMixin, MailerMixin ],
updateStatus: function(e) {
// make the event persist so that we can still override the selected value
// in the ajax callback
e.persist();
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
action: 'setStatus',
data: {
@ -274,35 +251,6 @@ const NewsletterListWelcome = React.createClass({
</span>
);
},
renderStatistics: function(newsletter) {
if (mailpoet_tracking_enabled === false) {
return;
}
if (newsletter.total_sent > 0 && newsletter.statistics) {
const total_sent = ~~(newsletter.total_sent);
const percentage_clicked = Math.round(
(~~(newsletter.statistics.clicked) * 100) / total_sent
);
const percentage_opened = Math.round(
(~~(newsletter.statistics.opened) * 100) / total_sent
);
const percentage_unsubscribed = Math.round(
(~~(newsletter.statistics.unsubscribed) * 100) / total_sent
);
return (
<span>
{ percentage_opened }%, { percentage_clicked }%, { percentage_unsubscribed }%
</span>
);
} else {
return (
<span>{MailPoet.I18n.t('notSentYet')}</span>
);
}
},
renderItem: function(newsletter, actions) {
const rowClasses = classNames(
'manage-column',
@ -329,7 +277,10 @@ const NewsletterListWelcome = React.createClass({
</td>
{ (mailpoet_tracking_enabled === true) ? (
<td className="column" data-colname={ MailPoet.I18n.t('statistics') }>
{ this.renderStatistics(newsletter) }
{ this.renderStatistics(
newsletter,
newsletter.total_sent > 0 && newsletter.statistics
) }
</td>
) : null }
<td className="column-date" data-colname={ MailPoet.I18n.t('lastModifiedOn') }>
@ -369,4 +320,4 @@ const NewsletterListWelcome = React.createClass({
}
});
module.exports = NewsletterListWelcome;
module.exports = NewsletterListWelcome;

View File

@ -2,13 +2,13 @@ import React from 'react'
import ReactDOM from 'react-dom'
import { Router, Route, IndexRedirect, Link, useRouterHistory } from 'react-router'
import { createHashHistory } from 'history'
import Hooks from 'wp-js-hooks'
import NewsletterTypes from 'newsletters/types.jsx'
import NewsletterTemplates from 'newsletters/templates.jsx'
import NewsletterSend from 'newsletters/send.jsx'
import NewsletterTypeStandard from 'newsletters/types/standard.jsx'
import NewsletterTypeWelcome from 'newsletters/types/welcome/welcome.jsx'
import NewsletterTypeNotification from 'newsletters/types/notification/notification.jsx'
import NewsletterListStandard from 'newsletters/listings/standard.jsx'
@ -27,6 +27,9 @@ const App = React.createClass({
const container = document.getElementById('newsletters_container');
if(container) {
let extra_routes = [];
extra_routes = Hooks.applyFilters('mailpoet_newsletters_before_router', extra_routes);
const mailpoet_listing = ReactDOM.render((
<Router history={ history }>
<Route path="/" component={ App }>
@ -40,12 +43,13 @@ if(container) {
<Route path="new" component={ NewsletterTypes } />
{/* New newsletter: types */}
<Route path="new/standard" component={ NewsletterTypeStandard } />
<Route path="new/welcome" component={ NewsletterTypeWelcome } />
<Route path="new/notification" component={ NewsletterTypeNotification } />
{/* Template selection */}
<Route name="template" path="template/:id" component={ NewsletterTemplates } />
{/* Sending options */}
<Route path="send/:id" component={ NewsletterSend } />
{/* Extra routes */}
{ extra_routes.map(rt => <Route key={rt.path} path={rt.path} component={rt.component} />) }
</Route>
</Router>
), container);

View File

@ -64,6 +64,7 @@ define(
this.setState({ loading: true });
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
action: 'get',
data: {
@ -97,6 +98,7 @@ define(
case 'notification':
case 'welcome':
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
action: 'setStatus',
data: {
@ -120,6 +122,7 @@ define(
}).fail(this._showError);
default:
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'sendingQueue',
action: 'add',
data: {
@ -173,15 +176,21 @@ define(
var data = this.state.item;
this.setState({ loading: true });
// Ensure that body is JSON encoded
if (!_.isUndefined(data.body)) {
data.body = JSON.stringify(data.body);
}
// Store only properties that can be changed on this page
const IGNORED_NEWSLETTER_PROPERTIES = [
'preheader', 'body', 'created_at', 'deleted_at', 'hash',
'status', 'updated_at', 'type'
];
const newsletterData = _.omit(
data,
IGNORED_NEWSLETTER_PROPERTIES
);
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
action: 'save',
data: data,
data: newsletterData,
}).always(() => {
this.setState({ loading: false });
});

View File

@ -1,11 +1,13 @@
define(
[
'mailpoet',
'wp-js-hooks',
'newsletters/types/notification/scheduling.jsx',
'underscore'
],
function(
MailPoet,
Hooks,
Scheduling,
_
) {
@ -35,8 +37,9 @@ define(
tip: MailPoet.I18n.t('segmentsTip'),
type: 'selection',
placeholder: MailPoet.I18n.t('selectSegmentPlaceholder'),
id: "mailpoet_segments",
endpoint: "segments",
id: 'mailpoet_segments',
api_version: window.mailpoet_api_version,
endpoint: 'segments',
multiple: true,
filter: function(segment) {
return !!(!segment.deleted_at);
@ -101,6 +104,8 @@ define(
}
];
fields = Hooks.applyFilters('mailpoet_newsletters_3rd_step_fields', fields);
return {
getFields: function(newsletter) {
return fields;

View File

@ -4,6 +4,7 @@ define(
'jquery',
'underscore',
'mailpoet',
'wp-js-hooks',
'form/fields/checkbox.jsx',
'form/fields/select.jsx',
'form/fields/text.jsx',
@ -13,6 +14,7 @@ define(
jQuery,
_,
MailPoet,
Hooks,
Checkbox,
Select,
Text
@ -339,8 +341,9 @@ define(
tip: MailPoet.I18n.t('segmentsTip'),
type: 'selection',
placeholder: MailPoet.I18n.t('selectSegmentPlaceholder'),
id: "mailpoet_segments",
endpoint: "segments",
id: 'mailpoet_segments',
api_version: window.mailpoet_api_version,
endpoint: 'segments',
multiple: true,
filter: function(segment) {
return !!(!segment.deleted_at);
@ -411,6 +414,8 @@ define(
}
];
fields = Hooks.applyFilters('mailpoet_newsletters_3rd_step_fields', fields);
return {
getFields: function(newsletter) {
return fields;

View File

@ -1,10 +1,12 @@
define(
[
'mailpoet',
'wp-js-hooks',
'newsletters/types/welcome/scheduling.jsx'
],
function(
MailPoet,
Hooks,
Scheduling
) {
@ -71,6 +73,8 @@ define(
}
];
fields = Hooks.applyFilters('mailpoet_newsletters_3rd_step_fields', fields);
return {
getFields: function(newsletter) {
return fields;
@ -83,4 +87,3 @@ define(
};
}
);

View File

@ -27,6 +27,7 @@ define(
MailPoet.Modal.loading(true);
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletterTemplates',
action: 'save',
data: template
@ -97,6 +98,7 @@ define(
MailPoet.Modal.loading(true);
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletterTemplates',
action: 'getAll',
}).always(() => {
@ -130,6 +132,7 @@ define(
}
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
action: 'save',
data: {
@ -158,6 +161,7 @@ define(
)
) {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletterTemplates',
action: 'delete',
data: {

View File

@ -2,12 +2,14 @@ define(
[
'react',
'mailpoet',
'wp-js-hooks',
'react-router',
'newsletters/breadcrumb.jsx'
],
function(
React,
MailPoet,
Hooks,
Router,
Breadcrumb
) {
@ -22,6 +24,7 @@ define(
},
createNewsletter: function(type) {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
action: 'create',
data: {
@ -40,6 +43,49 @@ define(
});
},
render: function() {
var types = [
{
'id': 'standard',
'title': MailPoet.I18n.t('regularNewsletterTypeTitle'),
'description': MailPoet.I18n.t('regularNewsletterTypeDescription'),
'action': function() {
return (
<a className="button button-primary" onClick={ this.createNewsletter.bind(null, 'standard') }>
{MailPoet.I18n.t('create')}
</a>
)
}.bind(this)()
},
{
'id': 'welcome',
'title': MailPoet.I18n.t('welcomeNewsletterTypeTitle'),
'description': MailPoet.I18n.t('welcomeNewsletterTypeDescription'),
'action': function() {
return (
<div>
<a href="?page=mailpoet-premium" target="_blank">
{MailPoet.I18n.t('getPremiumVersion')}
</a>
</div>
)
}()
},
{
'id': 'notification',
'title': MailPoet.I18n.t('postNotificationNewsletterTypeTitle'),
'description': MailPoet.I18n.t('postNotificationNewsletterTypeDescription'),
'action': function() {
return (
<a className="button button-primary" onClick={ this.setupNewsletter.bind(null, 'notification') }>
{MailPoet.I18n.t('setUp')}
</a>
)
}.bind(this)()
}
];
types = Hooks.applyFilters('mailpoet_newsletters_types', types, this);
return (
<div>
<h1>{MailPoet.I18n.t('pickCampaignType')}</h1>
@ -47,65 +93,24 @@ define(
<Breadcrumb step="type" />
<ul className="mailpoet_boxes clearfix">
<li data-type="standard">
<div className="mailpoet_thumbnail"></div>
{types.map(function(type, index) {
return (
<li key={index} data-type={type.id}>
<div>
<div className="mailpoet_thumbnail"></div>
<div className="mailpoet_description">
<h3>{MailPoet.I18n.t('regularNewsletterTypeTitle')}</h3>
<p>
{MailPoet.I18n.t('regularNewsletterTypeDescription')}
</p>
</div>
<div className="mailpoet_description">
<h3>{type.title}</h3>
<p>{type.description}</p>
</div>
<div className="mailpoet_actions">
<a
className="button button-primary"
onClick={ this.createNewsletter.bind(null, 'standard') }
>
{MailPoet.I18n.t('create')}
</a>
</div>
</li>
<li data-type="welcome">
<div className="mailpoet_thumbnail"></div>
<div className="mailpoet_description">
<h3>{MailPoet.I18n.t('welcomeNewsletterTypeTitle')}</h3>
<p>
{MailPoet.I18n.t('welcomeNewsletterTypeDescription')}
</p>
</div>
<div className="mailpoet_actions">
<a
className="button button-primary"
onClick={ this.setupNewsletter.bind(null, 'welcome') }
>
{MailPoet.I18n.t('setUp')}
</a>
</div>
</li>
<li data-type="notification">
<div className="mailpoet_thumbnail"></div>
<div className="mailpoet_description">
<h3>{MailPoet.I18n.t('postNotificationNewsletterTypeTitle')}</h3>
<p>
{MailPoet.I18n.t('postNotificationsNewsletterTypeDescription')}
</p>
</div>
<div className="mailpoet_actions">
<a
className="button button-primary"
onClick={ this.setupNewsletter.bind(null, 'notification') }
>
{MailPoet.I18n.t('setUp')}
</a>
</div>
</li>
<div className="mailpoet_actions">
{type.action}
</div>
</div>
</li>
)
}, this)}
</ul>
</div>
);

View File

@ -44,6 +44,7 @@ define(
},
handleNext: function() {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
action: 'create',
data: _.extend({}, this.state, {

View File

@ -22,6 +22,7 @@ define(
componentDidMount: function() {
// No options for this type, create a newsletter upon mounting
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
action: 'create',
data: {

View File

@ -104,6 +104,7 @@ const WelcomeScheduling = React.createClass({
},
handleNext: function() {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
action: 'create',
data: {

View File

@ -1,102 +0,0 @@
define(
[
'underscore',
'react',
'react-router',
'mailpoet',
'newsletters/types/welcome/scheduling.jsx',
'newsletters/breadcrumb.jsx'
],
function(
_,
React,
Router,
MailPoet,
Scheduling,
Breadcrumb
) {
var field = {
name: 'options',
label: 'Event',
type: 'reactComponent',
component: Scheduling,
};
var availableSegments = window.mailpoet_segments || {},
defaultSegment = 1;
if (_.size(availableSegments) > 0) {
defaultSegment = _.first(availableSegments).id;
}
var NewsletterWelcome = React.createClass({
contextTypes: {
router: React.PropTypes.object.isRequired
},
getInitialState: function() {
return {
options: {
event: 'segment',
segment: defaultSegment,
role: 'subscriber',
afterTimeNumber: 1,
afterTimeType: 'immediate',
}
};
},
handleValueChange: function(event) {
var state = this.state;
state[event.target.name] = event.target.value;
this.setState(state);
},
handleNext: function() {
MailPoet.Ajax.post({
endpoint: 'newsletters',
action: 'create',
data: _.extend({}, this.state, {
type: 'welcome',
subject: MailPoet.I18n.t('draftNewsletterTitle'),
})
}).done((response) => {
this.showTemplateSelection(response.data.id);
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function(error) { return error.message; }),
{ scroll: true }
);
}
});
},
showTemplateSelection: function(newsletterId) {
this.context.router.push(`/template/${newsletterId}`);
},
render: function() {
return (
<div>
<h1>{MailPoet.I18n.t('welcomeNewsletterTypeTitle')}</h1>
<Breadcrumb step="type" />
<h3>{MailPoet.I18n.t('selectEventToSendWelcomeEmail')}</h3>
<Scheduling
item={this.state}
field={field}
onValueChange={this.handleValueChange} />
<p className="submit">
<input
className="button button-primary"
type="button"
onClick={ this.handleNext }
value={MailPoet.I18n.t('next')} />
</p>
</div>
);
},
});
return NewsletterWelcome;
}
);

View File

@ -102,22 +102,11 @@ define('notice', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
'setMessage', this.options.message
);
},
isHTML: function(str) {
var a = document.createElement('div');
a.innerHTML = str;
for (var c = a.childNodes, i = c.length; i--;) {
if (c[i].nodeType == 1) return true;
}
return false;
},
setMessage: function(message) {
message = this.formatMessage(message);
// if it's not an html message
// let's sugar coat the message with a fancy <p>
if (this.isHTML(message) === false) {
message = '<p>'+message+'</p>';
}
message = '<p>'+message+'</p>';
// set message
return this.element.html(message);
},
@ -153,13 +142,13 @@ define('notice', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
// set class name
switch (this.options.type) {
case 'success':
this.element.addClass('updated');
this.element.addClass('notice notice-success');
break;
case 'system':
this.element.addClass('update-nag');
this.element.addClass('notice notice-warning');
break;
case 'error':
this.element.addClass('error');
this.element.addClass('notice notice-error');
break;
}
@ -199,7 +188,7 @@ define('notice', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
// single id
jQuery('[data-id="' + all + '"]').trigger('close');
} else {
jQuery('.mailpoet_notice.updated:not([id]), .mailpoet_notice.error:not([id])')
jQuery('.mailpoet_notice.notice-success:not([id]), .mailpoet_notice.notice-error:not([id])')
.trigger('close');
}
},

21
assets/js/src/num.js Normal file
View File

@ -0,0 +1,21 @@
define('num',
[
'mailpoet'
], function(
MailPoet
) {
'use strict';
MailPoet.Num = {
toLocaleFixed: function (num, precision) {
precision = precision || 0;
var factor = Math.pow(10, precision);
return (Math.round(num * factor) / factor)
.toLocaleString(
undefined,
{minimumFractionDigits: precision, maximumFractionDigits: precision}
);
}
};
});

View File

@ -31,7 +31,7 @@ function(
});
form.parsley().on('form:submit', function(parsley) {
var data = form.serializeObject() || {};
var form_data = form.serializeObject() || {};
// check if we're on the same domain
if(isSameDomain(MailPoetForm.ajax_url) === false) {
// non ajax post request
@ -40,10 +40,11 @@ function(
// ajax request
MailPoet.Ajax.post({
url: MailPoetForm.ajax_url,
token: data.token,
token: form_data.token,
api_version: form_data.api_version,
endpoint: 'subscribers',
action: 'subscribe',
data: data
data: form_data.data
}).fail(function(response) {
form.find('.mailpoet_validate_error').html(
response.errors.map(function(error) {

View File

@ -90,7 +90,7 @@ const messages = {
const bulk_actions = [
{
name: 'trash',
label: MailPoet.I18n.t('trash'),
label: MailPoet.I18n.t('moveToTrash'),
onSuccess: messages.onTrash
}
];
@ -112,6 +112,7 @@ const item_actions = [
label: MailPoet.I18n.t('duplicate'),
onClick: (item, refresh) => {
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'segments',
action: 'duplicate',
data: {
@ -153,6 +154,7 @@ const item_actions = [
onClick: function(item, refresh) {
MailPoet.Modal.loading(true);
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'segments',
action: 'synchronize'
}).done(function(response) {

View File

@ -15,6 +15,7 @@ define(
MailPoet.Router = new (Backbone.Router.extend({
routes: {
'': 'sendingMethodGroup', // the default tab is currently mta, needs its own method
'mta(/:group)': 'sendingMethodGroup',
'(:tab)': 'tabs',
},
@ -32,7 +33,7 @@ define(
if(group === null) {
// show sending methods
jQuery('.mailpoet_sending_methods').fadeIn();
jQuery('.mailpoet_sending_methods, .mailpoet_sending_methods_help').fadeIn();
} else {
// toggle SPF (hidden if the sending method is MailPoet)
jQuery('#mailpoet_mta_spf')[
@ -42,7 +43,7 @@ define(
]();
// hide sending methods
jQuery('.mailpoet_sending_methods').hide();
jQuery('.mailpoet_sending_methods, .mailpoet_sending_methods_help').hide();
// display selected sending method's settings
jQuery('.mailpoet_sending_method[data-group="'+ group +'"]').show();
@ -51,7 +52,7 @@ define(
},
tabs: function(tab, section) {
// set default tab
tab = tab || 'basics';
tab = tab || 'mta';
// reset all active tabs
jQuery('.nav-tab-wrapper a').removeClass('nav-tab-active');

View File

@ -60,7 +60,8 @@ define(
label: MailPoet.I18n.t('lists'),
type: 'selection',
placeholder: MailPoet.I18n.t('selectList'),
endpoint: "segments",
api_version: window.mailpoet_api_version,
endpoint: 'segments',
multiple: true,
selected: function(subscriber) {
if (Array.isArray(subscriber.subscriptions) === false) {

View File

@ -138,6 +138,7 @@ define(
}
MailPoet.Modal.loading(true);
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'ImportExport',
action: 'processExport',
data: JSON.stringify({

View File

@ -190,6 +190,7 @@ define(
mailChimpKeyVerifyButtonElement.click(function () {
MailPoet.Modal.loading(true);
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'importExport',
action: 'getMailChimpLists',
data: {
@ -225,6 +226,7 @@ define(
}
MailPoet.Modal.loading(true);
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'importExport',
action: 'getMailChimpSubscribers',
data: {
@ -321,6 +323,10 @@ define(
// is the email in 'mailto:email' format?
email = test[1].trim();
}
// test for valid characters using WP's rule (https://core.trac.wordpress.org/browser/tags/4.7.3/src/wp-includes/formatting.php#L2902)
if (!/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.\-@]+$/.test(email) ) {
return false;
}
return email;
};
@ -543,7 +549,7 @@ define(
MailPoet.Notice.error(MailPoet.I18n.t('segmentSelectionRequired'), {
static: true,
scroll: true,
id: 'segmentSelection',
id: 'notice_segmentSelection',
hideClose: true
});
}
@ -572,6 +578,7 @@ define(
var segmentDescription = jQuery('#new_segment_description').val().trim();
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'ImportExport',
action: 'addSegment',
data: {
@ -633,12 +640,12 @@ define(
columnId = 'email';
} else if (subscribers.header) {
var headerName = subscribers.header[i],
header_name_match = mailpoetColumns.map(function (el) {
return el.id;
headerNameMatch = mailpoetColumns.map(function (el) {
return el.name;
}).indexOf(headerName);
// set column type using header
if (header_name_match !== -1) {
columnId = headerName;
if (headerNameMatch !== -1) {
columnId = mailpoetColumns[headerNameMatch].id;
}// set column type using header name
else if (headerName) {
if (/first|first name|given name/i.test(headerName)) {
@ -648,11 +655,6 @@ define(
} else if (/status/i.test(headerName)) {
columnId = 'status';
}
/*else if (/subscribed|subscription/i.test(headerName)) {
columnId = 'confirmed_at';
} else if (/ip/i.test(headerName)) {
columnId = 'confirmed_ip';
}*/
}
}
// make sure the column id has not been previously selected
@ -734,6 +736,7 @@ define(
// save custom field
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'customFields',
action: 'save',
data: data
@ -995,6 +998,7 @@ define(
queue.add(function(queue) {
queue.pause();
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'ImportExport',
action: 'processImport',
data: JSON.stringify({
@ -1005,8 +1009,8 @@ define(
updateSubscribers: (jQuery(':radio[name="subscriber_update_option"]:checked').val() === 'yes') ? true : false
})
}).done(function(response) {
importResults.created = response.data.created;
importResults.updated = response.data.updated;
importResults.created += response.data.created;
importResults.updated += response.data.updated;
importResults.segments = response.data.segments;
importResults.added_to_segment_with_welcome_notification = response.data.added_to_segment_with_welcome_notification;
queue.run();

View File

@ -81,6 +81,22 @@ const messages = {
).replace('%$1d', count.toLocaleString());
}
MailPoet.Notice.success(message);
},
onNoItemsFound: (group) => {
if (group === 'bounced' && !mailpoet_premium_active) {
return (
<div>
<p>{MailPoet.I18n.t('bouncedSubscribersHelp')}</p>
<p>
<a href={ `admin.php?page=mailpoet-premium` } className="button-primary">
{MailPoet.I18n.t('bouncedSubscribersPremiumButtonText')}
</a>
</p>
</div>
);
}
// use default message
return false;
}
};
@ -91,6 +107,7 @@ const bulk_actions = [
onSelect: function() {
let field = {
id: 'move_to_segment',
api_version: window.mailpoet_api_version,
endpoint: 'segments',
filter: function(segment) {
return !!(
@ -122,6 +139,7 @@ const bulk_actions = [
onSelect: function() {
let field = {
id: 'add_to_segment',
api_version: window.mailpoet_api_version,
endpoint: 'segments',
filter: function(segment) {
return !!(
@ -153,6 +171,7 @@ const bulk_actions = [
onSelect: function() {
let field = {
id: 'remove_from_segment',
api_version: window.mailpoet_api_version,
endpoint: 'segments',
filter: function(segment) {
return !!(
@ -200,7 +219,7 @@ const bulk_actions = [
},
{
name: 'trash',
label: MailPoet.I18n.t('trash'),
label: MailPoet.I18n.t('moveToTrash'),
onSuccess: messages.onTrash
}
];
@ -255,7 +274,7 @@ const SubscriberList = React.createClass({
case 'unsubscribed':
status = MailPoet.I18n.t('unsubscribed');
break;
case 'bounced':
status = MailPoet.I18n.t('bounced');
break;

View File

@ -3,6 +3,7 @@
# Translations (npm install & composer install need to be run before)
echo '[BUILD] Generating translations'
./do makepot
./do packtranslations
plugin_name='mailpoet'
@ -34,6 +35,7 @@ cp -Rf vendor $plugin_name
cp -Rf views $plugin_name
rm -Rf $plugin_name/assets/css/src
rm -Rf $plugin_name/assets/js/src
rm -Rf $plugin_name/lang/*.po
# Remove extra files (docs, examples,...) from 3rd party extensions
echo '[BUILD] Removing obsolete files from vendor libraries'
@ -50,17 +52,20 @@ rm -rf $plugin_name/vendor/soundasleep/html2text/tests
rm -rf $plugin_name/vendor/mtdowling/cron-expression/tests
rm -rf $plugin_name/vendor/swiftmailer/swiftmailer/tests
rm -rf $plugin_name/vendor/cerdic/css-tidy/testing
rm -rf $plugin_name/vendor/sabberworm/php-css-parser/tests
# Remove risky files from 3rd party extensions
echo '[BUILD] Removing risky and demo files from vendor libraries'
rm -f $plugin_name/vendor/j4mie/idiorm/demo.php
rm -f $plugin_name/vendor/cerdic/css-tidy/css_optimiser.php
rm -f $plugin_name/assets/js/lib/tinymce/package.json
# Copy release files.
echo '[BUILD] Copying release files'
cp license.txt $plugin_name
cp index.php $plugin_name
cp $plugin_name.php $plugin_name
cp mailpoet_initializer.php $plugin_name
cp readme.txt $plugin_name
cp uninstall.php $plugin_name

View File

@ -8,23 +8,26 @@
"require": {
"php": ">=5.3.3",
"twig/twig": "1.*",
"cerdic/css-tidy": "*",
"tburry/pquery": "*",
"cerdic/css-tidy": "^1.5.5",
"tburry/pquery": "^1.1.1",
"j4mie/paris": "1.5.4",
"swiftmailer/swiftmailer": "^5.4",
"mtdowling/cron-expression": "^1.1",
"nesbot/carbon": "^1.21",
"soundasleep/html2text": "dev-master"
"soundasleep/html2text": "^0.3.4",
"sabberworm/php-css-parser": "^8.1",
"symfony/polyfill-xml": "^1.3"
},
"require-dev": {
"codeception/codeception": "*",
"codeception/verify": "*",
"codegyre/robo": "*",
"vlucas/phpdotenv": "*",
"codeception/codeception": "^2.2.9",
"codeception/verify": "^0.3.3",
"consolidation/robo": "^1.0.5",
"henrikbjorn/lurker": "^1.2",
"vlucas/phpdotenv": "^2.4.0",
"umpirsky/twig-gettext-extractor": "1.1.*",
"raveren/kint": "^1.0",
"squizlabs/php_codesniffer": "*",
"wimg/php-compatibility": "*",
"squizlabs/php_codesniffer": "^2.8.1",
"wimg/php-compatibility": "^7.1.2",
"simplyadmire/composer-plugins" : "@dev"
},
"autoload": {
@ -34,7 +37,7 @@
}
},
"scripts": {
"post-update-cmd": "rm -rf vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility; cp -rpd vendor/wimg/php-compatibility vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility",
"post-install-cmd": "rm -rf vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility; cp -rpd vendor/wimg/php-compatibility vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility"
"post-update-cmd": "rm -rf vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility; cp -rp vendor/wimg/php-compatibility vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility",
"post-install-cmd": "rm -rf vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility; cp -rp vendor/wimg/php-compatibility vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility"
}
}
}

1417
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,152 +1,18 @@
<?php
namespace MailPoet\API;
use \MailPoet\Util\Security;
if(!defined('ABSPATH')) exit;
class API {
private $_endpoint;
private $_method;
private $_token;
private $_endpoint_class;
private $_data = array();
function init() {
// Admin Security token
add_action(
'admin_head',
array($this, 'setToken')
);
// ajax (logged in users)
add_action(
'wp_ajax_mailpoet',
array($this, 'setupAjax')
);
// ajax (logged out users)
add_action(
'wp_ajax_nopriv_mailpoet',
array($this, 'setupAjax')
);
static function JSON() {
return new \MailPoet\API\JSON\API();
}
function setupAjax() {
$this->getRequestData();
if($this->checkToken() === false) {
$error_response = new ErrorResponse(
array(
Error::UNAUTHORIZED => __('Invalid request.', 'mailpoet')
),
array(),
Response::STATUS_UNAUTHORIZED
);
$error_response->send();
static function MP($version) {
$api_class = sprintf('%s\MP\%s\API', __NAMESPACE__, $version);
if(class_exists($api_class)) {
return new $api_class();
}
$this->processRoute();
}
function getRequestData() {
$this->_endpoint = isset($_POST['endpoint'])
? trim($_POST['endpoint'])
: null;
$this->_method = isset($_POST['method'])
? trim($_POST['method'])
: null;
$this->_token = isset($_POST['token'])
? trim($_POST['token'])
: null;
if(!$this->_endpoint || !$this->_method) {
// throw exception bad request
$error_response = new ErrorResponse(
array(
Error::BAD_REQUEST => __('Invalid request.', 'mailpoet')
),
array(),
Response::STATUS_BAD_REQUEST
);
$error_response->send();
} else {
$this->_endpoint_class = (
__NAMESPACE__."\\Endpoints\\".ucfirst($this->_endpoint)
);
$this->_data = isset($_POST['data'])
? stripslashes_deep($_POST['data'])
: array();
// remove reserved keywords from data
if(is_array($this->_data) && !empty($this->_data)) {
// filter out reserved keywords from data
$reserved_keywords = array(
'token',
'endpoint',
'method',
'mailpoet_redirect'
);
$this->_data = array_diff_key(
$this->_data,
array_flip($reserved_keywords)
);
}
}
}
function processRoute() {
try {
$endpoint = new $this->_endpoint_class();
// check the accessibility of the requested endpoint's action
// by default, an endpoint's action is considered "private"
$permissions = $endpoint->permissions;
if(
array_key_exists($this->_method, $permissions) === false
||
$permissions[$this->_method] !== Access::ALL
) {
if($this->checkPermissions() === false) {
$error_response = new ErrorResponse(
array(
Error::FORBIDDEN => __(
'You do not have the required permissions.',
'mailpoet'
)
),
array(),
Response::STATUS_FORBIDDEN
);
$error_response->send();
}
}
$response = $endpoint->{$this->_method}($this->_data);
$response->send();
} catch(\Exception $e) {
$error_response = new ErrorResponse(
array($e->getCode() => $e->getMessage())
);
$error_response->send();
}
}
function checkPermissions() {
return current_user_can('manage_options');
}
function checkToken() {
return wp_verify_nonce($this->_token, 'mailpoet_token');
}
function setToken() {
$global = '<script type="text/javascript">';
$global .= 'var mailpoet_token = "';
$global .= Security::generateToken();
$global .= '";';
$global .= '</script>';
echo $global;
throw new \Exception(__('Invalid API version.', 'mailpoet'));
}
}

200
lib/API/JSON/API.php Normal file
View File

@ -0,0 +1,200 @@
<?php
namespace MailPoet\API\JSON;
use MailPoet\Config\Env;
use MailPoet\Util\Helpers;
use MailPoet\Util\Security;
use MailPoet\WP\Hooks;
if(!defined('ABSPATH')) exit;
class API {
private $_request_api_version;
private $_request_endpoint;
private $_request_method;
private $_request_token;
private $_request_endpoint_class;
private $_request_data = array();
private $_endpoint_namespaces = array();
private $_available_api_versions = array(
'v1'
);
const CURRENT_VERSION = 'v1';
function __construct() {
foreach($this->_available_api_versions as $available_api_version) {
$this->addEndpointNamespace(
sprintf('%s\%s', __NAMESPACE__, $available_api_version),
$available_api_version
);
}
}
function init() {
// admin security token and API version
add_action(
'admin_head',
array($this, 'setTokenAndAPIVersion')
);
// ajax (logged in users)
add_action(
'wp_ajax_mailpoet',
array($this, 'setupAjax')
);
// ajax (logged out users)
add_action(
'wp_ajax_nopriv_mailpoet',
array($this, 'setupAjax')
);
}
function setupAjax() {
Hooks::doAction('mailpoet_api_setup', array($this));
$this->setRequestData($_POST);
if($this->checkToken() === false) {
$error_message = __('Invalid API request.', 'mailpoet');
$error_response = $this->createErrorResponse(Error::UNAUTHORIZED, $error_message, Response::STATUS_UNAUTHORIZED);
return $error_response->send();
}
$response = $this->processRoute();
$response->send();
}
function setRequestData($data) {
$this->_request_api_version = !empty($data['api_version']) ? $data['api_version']: false;
$this->_request_endpoint = isset($data['endpoint'])
? Helpers::underscoreToCamelCase(trim($data['endpoint']))
: null;
// JS part of /wp-admin/customize.php does not like a 'method' field in a form widget
$method_param_name = isset($data['mailpoet_method']) ? 'mailpoet_method' : 'method';
$this->_request_method = isset($data[$method_param_name])
? Helpers::underscoreToCamelCase(trim($data[$method_param_name]))
: null;
$this->_request_token = isset($data['token'])
? trim($data['token'])
: null;
if(!$this->_request_endpoint || !$this->_request_method || !$this->_request_api_version) {
$error_message = __('Invalid API request.', 'mailpoet');
$error_response = $this->createErrorResponse(Error::BAD_REQUEST, $error_message, Response::STATUS_BAD_REQUEST);
return $error_response;
} else if(!empty($this->_endpoint_namespaces[$this->_request_api_version])) {
foreach($this->_endpoint_namespaces[$this->_request_api_version] as $namespace) {
$endpoint_class = sprintf(
'%s\%s',
$namespace,
ucfirst($this->_request_endpoint)
);
if(class_exists($endpoint_class)) {
$this->_request_endpoint_class = $endpoint_class;
break;
}
}
$this->_request_data = isset($data['data'])
? stripslashes_deep($data['data'])
: array();
// remove reserved keywords from data
if(is_array($this->_request_data) && !empty($this->_request_data)) {
// filter out reserved keywords from data
$reserved_keywords = array(
'token',
'endpoint',
'method',
'api_version',
'mailpoet_method', // alias of 'method'
'mailpoet_redirect'
);
$this->_request_data = array_diff_key(
$this->_request_data,
array_flip($reserved_keywords)
);
}
}
}
function processRoute() {
try {
if(empty($this->_request_endpoint_class)) {
throw new \Exception(__('Invalid API endpoint.', 'mailpoet'));
}
$endpoint = new $this->_request_endpoint_class();
// check the accessibility of the requested endpoint's action
// by default, an endpoint's action is considered "private"
$permissions = $endpoint->permissions;
if(array_key_exists($this->_request_method, $permissions) === false ||
$permissions[$this->_request_method] !== Access::ALL
) {
if($this->checkPermissions() === false) {
$error_message = __('You do not have the required permissions.', 'mailpoet');
$error_response = $this->createErrorResponse(Error::FORBIDDEN, $error_message, Response::STATUS_FORBIDDEN);
return $error_response;
}
}
$response = $endpoint->{$this->_request_method}($this->_request_data);
return $response;
} catch(\Exception $e) {
$error_message = $e->getMessage();
$error_response = $this->createErrorResponse(Error::BAD_REQUEST, $error_message, Response::STATUS_BAD_REQUEST);
return $error_response;
}
}
function checkPermissions() {
return current_user_can(Env::$required_permission);
}
function checkToken() {
return wp_verify_nonce($this->_request_token, 'mailpoet_token');
}
function setTokenAndAPIVersion() {
$global = '<script type="text/javascript">';
$global .= 'var mailpoet_token = "%s";';
$global .= 'var mailpoet_api_version = "%s";';
$global .= '</script>';
echo sprintf(
$global,
Security::generateToken(),
self::CURRENT_VERSION
);
}
function addEndpointNamespace($namespace, $version) {
if(!empty($this->_endpoint_namespaces[$version][$namespace])) return;
$this->_endpoint_namespaces[$version][] = $namespace;
}
function getEndpointNamespaces() {
return $this->_endpoint_namespaces;
}
function getRequestedEndpointClass() {
return $this->_request_endpoint_class;
}
function getRequestedAPIVersion() {
return $this->_request_api_version;
}
function createErrorResponse($error_type, $error_message, $response_status) {
$error_response = new ErrorResponse(
array(
$error_type => $error_message
),
array(),
$response_status
);
return $error_response;
}
}

View File

@ -1,5 +1,5 @@
<?php
namespace MailPoet\API;
namespace MailPoet\API\JSON;
if(!defined('ABSPATH')) exit;

View File

@ -1,5 +1,5 @@
<?php
namespace MailPoet\API;
namespace MailPoet\API\JSON;
if(!defined('ABSPATH')) exit;
@ -27,9 +27,9 @@ abstract class Endpoint {
function badRequest($errors = array(), $meta = array()) {
if(empty($errors)) {
$errors = array(
Error::BAD_REQUEST => __('Invalid request parameters.', 'mailpoet')
Error::BAD_REQUEST => __('Invalid request parameters', 'mailpoet')
);
}
return new ErrorResponse($errors, $meta, Response::STATUS_BAD_REQUEST);
}
}
}

View File

@ -1,5 +1,5 @@
<?php
namespace MailPoet\API;
namespace MailPoet\API\JSON;
if(!defined('ABSPATH')) exit;

View File

@ -1,5 +1,5 @@
<?php
namespace MailPoet\API;
namespace MailPoet\API\JSON;
if(!defined('ABSPATH')) exit;

View File

@ -1,5 +1,5 @@
<?php
namespace MailPoet\API;
namespace MailPoet\API\JSON;
if(!defined('ABSPATH')) exit;

View File

@ -1,5 +1,5 @@
<?php
namespace MailPoet\API;
namespace MailPoet\API\JSON;
if(!defined('ABSPATH')) exit;

View File

@ -1,7 +1,7 @@
<?php
namespace MailPoet\API\Endpoints;
use \MailPoet\API\Endpoint as APIEndpoint;
use \MailPoet\API\Error as APIError;
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\WP\Posts as WPPosts;
if(!defined('ABSPATH')) exit;
@ -28,17 +28,19 @@ class AutomatedLatestContent extends APIEndpoint {
function getTerms($data = array()) {
$taxonomies = (isset($data['taxonomies'])) ? $data['taxonomies'] : array();
$search = (isset($data['search'])) ? $data['search'] : '';
$limit = (isset($data['limit'])) ? (int)$data['limit'] : 10;
$limit = (isset($data['limit'])) ? (int)$data['limit'] : 50;
$page = (isset($data['page'])) ? (int)$data['page'] : 1;
return $this->successResponse(
get_terms(
$taxonomies,
WPPosts::getTerms(
array(
'taxonomy' => $taxonomies,
'hide_empty' => false,
'search' => $search,
'number' => $limit,
'offset' => $limit * ($page - 1)
'offset' => $limit * ($page - 1),
'orderby' => 'name',
'order' => 'ASC'
)
)
);

View File

@ -1,8 +1,8 @@
<?php
namespace MailPoet\API\Endpoints;
use \MailPoet\API\Endpoint as APIEndpoint;
use \MailPoet\API\Error as APIError;
use \MailPoet\Models\CustomField;
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Models\CustomField;
if(!defined('ABSPATH')) exit;

View File

@ -1,13 +1,13 @@
<?php
namespace MailPoet\API\Endpoints;
use MailPoet\API\Endpoint as APIEndpoint;
use MailPoet\API\Error as APIError;
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use \MailPoet\Models\Form;
use \MailPoet\Models\StatisticsForms;
use \MailPoet\Form\Renderer as FormRenderer;
use \MailPoet\Listing;
use \MailPoet\Form\Util;
use MailPoet\Models\Form;
use MailPoet\Models\StatisticsForms;
use MailPoet\Form\Renderer as FormRenderer;
use MailPoet\Listing;
use MailPoet\Form\Util;
if(!defined('ABSPATH')) exit;

View File

@ -1,10 +1,8 @@
<?php
namespace MailPoet\API\Endpoints;
use \MailPoet\API\Endpoint as APIEndpoint;
use \MailPoet\API\Error as APIError;
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\Subscribers\ImportExport\Import\MailChimp;
use MailPoet\Models\CustomField;
use MailPoet\Models\Segment;
if(!defined('ABSPATH')) exit;

View File

@ -0,0 +1,64 @@
<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
if(!defined('ABSPATH')) exit;
class MP2Migrator extends APIEndpoint {
public function __construct() {
$this->MP2Migrator = new \MailPoet\Config\MP2Migrator();
}
/**
* Import end point
*
* @param object $data
* @return object
*/
public function import($data) {
try {
$process = $this->MP2Migrator->import($data);
return $this->successResponse($process);
} catch(\Exception $e) {
return $this->errorResponse(array(
$e->getCode() => $e->getMessage()
));
}
}
/**
* Stop import end point
*
* @param object $data
* @return object
*/
public function stopImport($data) {
try {
$process = $this->MP2Migrator->stopImport();
return $this->successResponse($process);
} catch(\Exception $e) {
return $this->errorResponse(array(
$e->getCode() => $e->getMessage()
));
}
}
/**
* Skip import end point
*
* @param object $data
* @return object
*/
public function skipImport($data) {
try {
$process = $this->MP2Migrator->skipImport();
return $this->successResponse($process);
} catch(\Exception $e) {
return $this->errorResponse(array(
$e->getCode() => $e->getMessage()
));
}
}
}

View File

@ -1,7 +1,7 @@
<?php
namespace MailPoet\API\Endpoints;
use MailPoet\API\Endpoint as APIEndpoint;
use MailPoet\API\Error as APIError;
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Mailer\MailerLog;
if(!defined('ABSPATH')) exit;
@ -14,7 +14,10 @@ class Mailer extends APIEndpoint {
(isset($data['sender'])) ? $data['sender'] : false,
(isset($data['reply_to'])) ? $data['reply_to'] : false
);
$result = $mailer->send($data['newsletter'], $data['subscriber']);
$extra_params = array(
'test_email' => true
);
$result = $mailer->send($data['newsletter'], $data['subscriber'], $extra_params);
} catch(\Exception $e) {
return $this->errorResponse(array(
$e->getCode() => $e->getMessage()

View File

@ -1,7 +1,7 @@
<?php
namespace MailPoet\API\Endpoints;
use \MailPoet\API\Endpoint as APIEndpoint;
use \MailPoet\API\Error as APIError;
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Models\NewsletterTemplate;

View File

@ -1,9 +1,10 @@
<?php
namespace MailPoet\API\Endpoints;
namespace MailPoet\API\JSON\v1;
use MailPoet\API\Endpoint as APIEndpoint;
use MailPoet\API\Error as APIError;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Listing;
use MailPoet\Models\SendingQueue;
use MailPoet\Models\Setting;
use MailPoet\Models\Newsletter;
use MailPoet\Models\NewsletterTemplate;
@ -14,6 +15,7 @@ use MailPoet\Models\Subscriber;
use MailPoet\Newsletter\Renderer\Renderer;
use MailPoet\Newsletter\Scheduler\Scheduler;
use MailPoet\Newsletter\Url as NewsletterUrl;
use MailPoet\WP\Hooks;
if(!defined('ABSPATH')) exit;
@ -28,12 +30,12 @@ class Newsletters extends APIEndpoint {
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
));
} else {
return $this->successResponse(
$newsletter
$newsletter = $newsletter
->withSegments()
->withOptions()
->asArray()
);
->asArray();
$newsletter = Hooks::applyFilters('mailpoet_api_newsletters_get_after', $newsletter);
return $this->successResponse($newsletter);
}
}
@ -50,6 +52,8 @@ class Newsletters extends APIEndpoint {
unset($data['options']);
}
$data = Hooks::applyFilters('mailpoet_api_newsletters_save_before', $data);
$newsletter = Newsletter::createOrUpdate($data);
$errors = $newsletter->getErrors();
@ -70,31 +74,43 @@ class Newsletters extends APIEndpoint {
}
if(!empty($options)) {
NewsletterOption::where('newsletter_id', $newsletter->id)
->deleteMany();
$option_fields = NewsletterOptionField::where(
'newsletter_type',
$data['type']
)->findArray();
$newsletter->type
)->findMany();
// update newsletter options
foreach($option_fields as $option_field) {
if(isset($options[$option_field['name']])) {
$relation = NewsletterOption::create();
$relation->newsletter_id = $newsletter->id;
$relation->option_field_id = $option_field['id'];
$relation->value = $options[$option_field['name']];
$relation->save();
if(isset($options[$option_field->name])) {
$newsletter_option = NewsletterOption::createOrUpdate(
array(
'newsletter_id' => $newsletter->id,
'option_field_id' => $option_field->id,
'value' => $options[$option_field->name]
)
);
}
}
// reload newsletter with updated options
$newsletter = Newsletter::filter('filterWithOptions')
->findOne($newsletter->id);
// if this is a post notification, process newsletter options and update its schedule
if($newsletter->type === Newsletter::TYPE_NOTIFICATION) {
// generate the new schedule from options and get the new "next run" date
$newsletter->schedule = Scheduler::processPostNotificationSchedule($newsletter);
$next_run_date = Scheduler::getNextRunDate($newsletter->schedule);
// find previously scheduled jobs and reschedule them using the new "next run" date
SendingQueue::where('newsletter_id', $newsletter->id)
->where('status', SendingQueue::STATUS_SCHEDULED)
->findResultSet()
->set('scheduled_at', $next_run_date)
->save();
}
}
$newsletter = Newsletter::filter('filterWithOptions')->findOne($newsletter->id);
// if this is a post notification, process options and update its schedule
if($newsletter->type === Newsletter::TYPE_NOTIFICATION) {
Scheduler::processPostNotificationSchedule($newsletter);
}
Hooks::doAction('mailpoet_api_newsletters_save_after', $newsletter);
return $this->successResponse($newsletter->asArray());
}
@ -193,6 +209,7 @@ class Newsletters extends APIEndpoint {
if(!empty($errors)) {
return $this->errorResponse($errors);
} else {
Hooks::doAction('mailpoet_api_newsletters_duplicate_after', $newsletter, $duplicate);
return $this->successResponse(
Newsletter::findOne($duplicate->id)->asArray(),
array('count' => 1)
@ -220,7 +237,9 @@ class Newsletters extends APIEndpoint {
$newsletter->save();
$subscriber = Subscriber::getCurrentWPUser();
$preview_url = NewsletterUrl::getViewInBrowserUrl(
$data, $subscriber, $queue = false, $preview = true
NewsletterUrl::TYPE_LISTING_EDITOR,
$newsletter,
$subscriber
);
return $this->successResponse(
@ -245,13 +264,11 @@ class Newsletters extends APIEndpoint {
APIError::NOT_FOUND => __('This newsletter does not exist.', 'mailpoet')
));
} else {
$newsletter = $newsletter->asArray();
$renderer = new Renderer($newsletter, $preview = true);
$rendered_newsletter = $renderer->render();
$divider = '***MailPoet***';
$data_for_shortcodes = array_merge(
array($newsletter['subject']),
array($newsletter->subject),
$rendered_newsletter
);
@ -264,24 +281,27 @@ class Newsletters extends APIEndpoint {
$newsletter,
$subscriber
);
list(
$newsletter['subject'],
$newsletter['body']['html'],
$newsletter['body']['text']
$rendered_newsletter['subject'],
$rendered_newsletter['body']['html'],
$rendered_newsletter['body']['text']
) = explode($divider, $shortcodes->replace($body));
try {
$mailer = new \MailPoet\Mailer\Mailer(
$mailer = false,
$sender = false,
$reply_to = false
$mailer = (!empty($data['mailer'])) ?
$data['mailer'] :
new \MailPoet\Mailer\Mailer(
$mailer = false,
$sender = false,
$reply_to = false
);
$result = $mailer->send($newsletter, $data['subscriber']);
$result = $mailer->send($rendered_newsletter, $data['subscriber']);
if($result['response'] === false) {
$error = sprintf(
__('The email could not be sent: %s', 'mailpoet'),
$result['error']
$result['error_message']
);
return $this->errorResponse(array(APIError::BAD_REQUEST => $error));
} else {
@ -310,7 +330,7 @@ class Newsletters extends APIEndpoint {
if($newsletter->type === Newsletter::TYPE_STANDARD) {
$newsletter
->withSegments()
->withSegments(true)
->withSendingQueue()
->withStatistics();
} else if($newsletter->type === Newsletter::TYPE_WELCOME) {
@ -321,11 +341,11 @@ class Newsletters extends APIEndpoint {
} else if($newsletter->type === Newsletter::TYPE_NOTIFICATION) {
$newsletter
->withOptions()
->withSegments()
->withSegments(true)
->withChildrenCount();
} else if($newsletter->type === Newsletter::TYPE_NOTIFICATION_HISTORY) {
$newsletter
->withSegments()
->withSegments(true)
->withSendingQueue()
->withStatistics();
}
@ -337,9 +357,12 @@ class Newsletters extends APIEndpoint {
}
// get preview url
$subscriber = Subscriber::getCurrentWPUser();
$newsletter->preview_url = NewsletterUrl::getViewInBrowserUrl(
$newsletter, $subscriber, $queue, $preview = true);
NewsletterUrl::TYPE_LISTING_EDITOR,
$newsletter,
$subscriber = null,
$queue
);
$data[] = $newsletter->asArray();
}
@ -349,7 +372,8 @@ class Newsletters extends APIEndpoint {
'filters' => $listing_data['filters'],
'groups' => $listing_data['groups'],
'mta_log' => Setting::getValue('mta_log'),
'mta_method' => Setting::getValue('mta.method')
'mta_method' => Setting::getValue('mta.method'),
'current_time' => current_time('mysql')
));
}
@ -428,4 +452,4 @@ class Newsletters extends APIEndpoint {
);
}
}
}
}

View File

@ -1,13 +1,11 @@
<?php
namespace MailPoet\API\Endpoints;
use \MailPoet\API\Endpoint as APIEndpoint;
use \MailPoet\API\Error as APIError;
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use \MailPoet\Models\Segment;
use \MailPoet\Models\SubscriberSegment;
use \MailPoet\Models\SegmentFilter;
use \MailPoet\Listing;
use \MailPoet\Segments\WP;
use MailPoet\Models\Segment;
use MailPoet\Listing;
use MailPoet\Segments\WP;
if(!defined('ABSPATH')) exit;

View File

@ -1,15 +1,11 @@
<?php
namespace MailPoet\API\Endpoints;
use MailPoet\API\Endpoint as APIEndpoint;
use MailPoet\API\Error as APIError;
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Mailer\Mailer;
use MailPoet\Models\Newsletter;
use MailPoet\Models\NewsletterOption;
use MailPoet\Models\NewsletterOptionField;
use MailPoet\Models\Setting;
use MailPoet\Models\Subscriber;
use MailPoet\Models\SubscriberSegment;
use MailPoet\Newsletter\Scheduler\Scheduler;
use MailPoet\Models\SendingQueue as SendingQueueModel;
use MailPoet\Util\Helpers;
@ -52,7 +48,6 @@ class SendingQueue extends APIEndpoint {
APIError::NOT_FOUND => __('This newsletter is already being sent.', 'mailpoet')
));
}
$queue = SendingQueueModel::where('newsletter_id', $newsletter->id)
->where('status', SendingQueueModel::STATUS_SCHEDULED)
->findOne();
@ -77,10 +72,8 @@ class SendingQueue extends APIEndpoint {
$segment_ids = array_map(function($segment) {
return $segment['id'];
}, $segments);
$subscribers = Subscriber::getSubscribedInSegments($segment_ids)
->findArray();
$subscribers = Helpers::arrayColumn($subscribers, 'subscriber_id');
$subscribers = array_unique($subscribers);
$subscribers = Subscriber::getSubscribedInSegments($segment_ids)->findArray();
$subscribers = Helpers::flattenArray($subscribers);
if(!count($subscribers)) {
return $this->errorResponse(array(
APIError::UNKNOWN => __('There are no subscribers in that list!', 'mailpoet')

View File

@ -0,0 +1,125 @@
<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Config\Installer;
use MailPoet\Services\Bridge;
use MailPoet\Util\License\License;
use MailPoet\WP\DateTime;
if(!defined('ABSPATH')) exit;
class Services extends APIEndpoint {
public $bridge;
public $date_time;
function __construct() {
$this->bridge = new Bridge();
$this->date_time = new DateTime();
}
function checkMSSKey($data = array()) {
$key = isset($data['key']) ? trim($data['key']) : null;
if(!$key) {
return $this->badRequest(array(
APIError::BAD_REQUEST => __('Please specify a key.', 'mailpoet')
));
}
try {
$result = $this->bridge->checkMSSKey($key);
} catch(\Exception $e) {
return $this->errorResponse(array(
$e->getCode() => $e->getMessage()
));
}
$state = !empty($result['state']) ? $result['state'] : null;
$success_message = null;
if($state == Bridge::MAILPOET_KEY_VALID) {
$success_message = __('Your MailPoet Sending Service key has been successfully validated.', 'mailpoet');
} elseif($state == Bridge::MAILPOET_KEY_EXPIRING) {
$success_message = sprintf(
__('Your MailPoet Sending Service key expires on %s!', 'mailpoet'),
$this->date_time->formatDate(strtotime($result['data']['expire_at']))
);
}
if($success_message) {
return $this->successResponse(array('message' => $success_message));
}
switch($state) {
case Bridge::MAILPOET_KEY_INVALID:
$error = __('Your MailPoet Sending Service key is invalid.', 'mailpoet');
break;
default:
$code = !empty($result['code']) ? $result['code'] : Bridge::CHECK_ERROR_UNKNOWN;
$error = sprintf(
__('Error validating MailPoet Sending Service key, please try again later (code: %s)', 'mailpoet'),
$code
);
break;
}
return $this->errorResponse(array(APIError::BAD_REQUEST => $error));
}
function checkPremiumKey($data = array()) {
$key = isset($data['key']) ? trim($data['key']) : null;
if(!$key) {
return $this->badRequest(array(
APIError::BAD_REQUEST => __('Please specify a key.', 'mailpoet')
));
}
try {
$result = $this->bridge->checkPremiumKey($key);
} catch(\Exception $e) {
return $this->errorResponse(array(
$e->getCode() => $e->getMessage()
));
}
$state = !empty($result['state']) ? $result['state'] : null;
$success_message = null;
if($state == Bridge::PREMIUM_KEY_VALID) {
$success_message = __('Your Premium key has been successfully validated.', 'mailpoet');
} elseif($state == Bridge::PREMIUM_KEY_EXPIRING) {
$success_message = sprintf(
__('Your Premium key expires on %s.', 'mailpoet'),
$this->date_time->formatDate(strtotime($result['data']['expire_at']))
);
}
if($success_message) {
return $this->successResponse(
array('message' => $success_message),
Installer::getPremiumStatus()
);
}
switch($state) {
case Bridge::PREMIUM_KEY_INVALID:
$error = __('Your Premium key is invalid.', 'mailpoet');
break;
case Bridge::PREMIUM_KEY_ALREADY_USED:
$error = __('Your Premium key is already used on another site.', 'mailpoet');
break;
default:
$code = !empty($result['code']) ? $result['code'] : Bridge::CHECK_ERROR_UNKNOWN;
$error = sprintf(
__('Error validating Premium key, please try again later (code: %s)', 'mailpoet'),
$code
);
break;
}
return $this->errorResponse(array(APIError::BAD_REQUEST => $error));
}
}

View File

@ -1,8 +1,10 @@
<?php
namespace MailPoet\API\Endpoints;
use \MailPoet\API\Endpoint as APIEndpoint;
use \MailPoet\API\Error as APIError;
use \MailPoet\Models\Setting;
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Models\Setting;
use MailPoet\Services\Bridge;
if(!defined('ABSPATH')) exit;
@ -15,13 +17,15 @@ class Settings extends APIEndpoint {
if(empty($settings)) {
return $this->badRequest(array(
APIError::BAD_REQUEST =>
__("You have not specified any settings to be saved.", 'mailpoet')
__('You have not specified any settings to be saved.', 'mailpoet')
));
} else {
foreach($settings as $name => $value) {
Setting::setValue($name, $value);
}
$bridge = new Bridge();
$bridge->onSettingsSave($settings);
return $this->successResponse(Setting::getAll());
}
}
}
}

View File

@ -1,7 +1,9 @@
<?php
namespace MailPoet\API\Endpoints;
use \MailPoet\API\Endpoint as APIEndpoint;
use \MailPoet\Config\Activator;
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\Config\Activator;
use MailPoet\WP\Hooks;
if(!defined('ABSPATH')) exit;
@ -11,6 +13,7 @@ class Setup extends APIEndpoint {
$activator = new Activator();
$activator->deactivate();
$activator->activate();
Hooks::doAction('mailpoet_setup_reset');
return $this->successResponse();
} catch(\Exception $e) {
return $this->errorResponse(array(

Some files were not shown because too many files have changed in this diff Show More