WP RSS Aggregator - Version 4.6.10

Version Description

(2015-02-10) = * Enhanced: AJAX license activation. * Enhanced: License form more reliable. * Enhanced: license-related UI improvements * New: Markdown library added. Changelog now read from readme. * Fixed bug: Saving license keys not longer triggers error in some cases.

Download this release

Release Info

Developer jeangalea
Plugin Icon 128x128 WP RSS Aggregator
Version 4.6.10
Comparing to
See all releases

Code changes from version 4.6.9 to 4.6.10

changelog.txt DELETED
@@ -1,444 +0,0 @@
1
- 4.6.9 (2015-01-21)
2
- Enhanced: Admin user will now be warned about invalid or expiring licenses.
3
- Enhanced: Admin notices logic centralized in this plugin.
4
- Fixed: Multiple small-scale security vulnerabilities.
5
- Fixed: Ampersand in feed URL no longer causes the product of generated feeds to be invalidated by W3C Validator.
6
-
7
- 4.6.8 (2015-01-07)
8
- Enhanced: Added more logging during feed importing.
9
- Enhanced: Irrelevent metaboxes added by other plugins are now removed from the Add/Edit Feed Source page.
10
- Fixed bug: Valid feed URLS were being invalidated.
11
- Fixed bug: The Blacklist feature was being hidden when the Feed to Post add-on was enabled.
12
- Fixed bug: Patched a vulnerability where any user on the site can issue a feed fetch.
13
- Fixed bug: The "Activate" and "Pause" actions are not shown in the bulk actions dropdown in WordPress v4.1.
14
-
15
- 4.6.7 (2014-12-17)
16
- Enhanced: Some minor interface updates.
17
- Enhanced: Added filters for use by the premium add-ons.
18
-
19
- 4.6.6 (2014-12-06)
20
- Enhanced: Added output layouts for feed sources and feed items.
21
- Enhanced: Updated EDD updater class to version 1.5.
22
- Enhanced: Added time limit extending to prevent script from exhausting its execution time limit while importing.
23
- Fixed bug: The "Delete and Re-import" button was deleting items but not re-importing.
24
- Fixed bug: Non-object errors when a feed source is deleted while importing.
25
-
26
- 4.6.5 (2014-11-17)
27
- Enhanced: Improved the logging.
28
- Enhanced: Improved the licensing fields.
29
- Enhanced: Updated the EDD updater class to the latest version.
30
- Fixed bug: Small random error when viewing the licenses page.
31
-
32
- 4.6.4 (2014-11-10)
33
- Enhanced: Added filters to the custom feed.
34
- Enhanced: Updated some styles to improve the user interface.
35
- Fixed bug: The "Remove selected from Blacklist" button had no nonce associated with it.
36
- Fixed bug: The Blacklist menu entry was not always being shown.
37
-
38
- 4.6.3 (2014-11-3)
39
- Enhanced: Re-added the "Add New" link in the plugin's menu.
40
- Enhanced: Improved error logging.
41
- Enhanced: Bulk actions in the Feed Sources page are now also included in the bottom dropdown menu.
42
- Fixed bug: Add-on updater was prone to conflicts. Now enclosed in an action.
43
- Fixed bug: The Full Text RSS Feeds add-on was not showing as active in the "Add-ons" page.
44
- Fixed bug: Broken links in the "Add-ons" page, to add-on pages on our site.
45
-
46
- 4.6.2 (2014-10-15)
47
- Enhanced: Improved plugin responsiveness.
48
- Enhanced: Updated some help text in tooltips with better explainations and added clarity.
49
- Enhanced: Optimized some old SQL queries.
50
- Enhanced: Added better debug logging.
51
- Enhanced: Added a new filter to modify the text shown before author names.
52
- Fixed bug: Licenses were not showing as active, even though they were activated.
53
-
54
- 4.6.1 (2014-10-06)
55
- Enhanced: Improved internationalization in the plugin, for better translations.
56
- Fixed bug: If the feed source age limit was left empty, the global setting was used instead of ignoring the limit.
57
-
58
- 4.6 (2014-09-22)
59
- Enhanced: Improved the user interface, with better responsiveness and tooltips.
60
- Enhanced: Removes the ID column. The ID is now shown fixed in row actions.
61
- Enhanced: Feed Preview indicates if feed items have no dates.
62
- Fixed bug: If a feed item has no date, the date and time it was imported is used.
63
-
64
- 4.5.3 (2014-09-15)
65
- New Feature: Added filter to allow adding RSS feeds to the head of your site's pages for CPTs.
66
- Enhanced: Columns in the feed sources table are now sortable.
67
- Enhanced: Removed the ID column in the feed sources table. The ID has been moved as a row action.
68
- Enhanced: Improved various interface elements.
69
- Enhanced: Better responsiveness for smaller screen.
70
- Fixed bug: The importing spinning icon would get stuck and spin for a very long time.
71
- Fixed bug: Removed an old description meta field.
72
- Fixed bug: Plugin was not removing all scheduled cron jobs when deactivated.
73
-
74
- 4.5.2 (2014-09-09)
75
- Enhanced: Optimized plugin for WordPress 4.0.
76
- Enhanced: Improved template and added filters for add-on hooking.
77
- Fixed bug: Editor toolbar visible over the WP RSS shortcode dialog.
78
-
79
- 4.5.1 (2014-08-26)
80
- Fixed bug: Last import feed item count stays at zero.
81
- Fixed bug: Datetime::setTimestamp error when using PHP 5.2 or earlier.
82
- Fixed bug: The display limit was not working.
83
- Fixed bug: Minor bug in licensing.
84
-
85
- 4.5 (2014-08-25)
86
- New Feature: Bulk importer allows you to create multiple feed sources at once.
87
- Enhanced: Improved OPML importer with added hooks.
88
- Enhanced: Centralized add-on licensing, fixing multiple bugs.
89
- Fixed bug: Undefined `feed_limit` errors when using the shortcode.
90
-
91
- 4.4.4 (2014-08-19)
92
- Fixed bug: Errors when using older PHP versions 5.3 or lower.
93
-
94
- 4.4.3 (2014-08-19)
95
- Fixed bug: Errors when using older PHP versions 5.3 or lower.
96
-
97
- 4.4.2 (2014-08-19)
98
- Fixed bug: Errors when using older PHP versions 5.3 or lower.
99
-
100
- 4.4.1 (2014-08-18)
101
- Enhanced: Various improvements to the plugin interface and texts.
102
- Enhanced: Moved the restore default settings button farther down the Debugging page, to avoid confusion with the delete button.
103
- Fixed bug: Feed item dates were not being adjusted to the timezone when using a GMT offset.
104
- Fixed bug: Feed item dates are now adjusted according to daylight savings time.
105
-
106
- 4.4 (2014-08-11)
107
- New Feature: Blacklist - delete items and blacklist them to never import them again.
108
- Enhanced: Added a button in the Debugging page to reset the plugin settings to default.
109
- Enhanced: WordPress Yoast SEO metaboxes and custom columns will no longer appear.
110
-
111
- 4.3.1 (2014-08-08)
112
- Enhanced: Better wording on settings page.
113
- Fixed bug: The Links Behaviour option in the settings was not working.
114
- Fixed bug: The wrong feed items were being shown for some sources when using the "View Items" row action.
115
-
116
- 4.3 (2014-08-04)
117
- New Feature: Feed items now also import authors.
118
- Enhanced: Custom feed is now in RSS 2.0 format.
119
- Enhanced: Improved the display template for feed items.
120
- Fixed bug: Custom feed was not working in Firefox.
121
- Fixed bug: Some feed items were showing items from another feed source.
122
- Fixed bug: The feed limit in the global settings was not working.
123
-
124
- 4.2.3 (2014-07-29)
125
- Enhanced: Added an option to choose between the current pagination type, and numbered pagination.
126
- Enhanced: The Feed Preview now also shows the total number of items in the feed.
127
- Fixed bug: A PHP warning error was being shown in the System Info.
128
- Fixed bug: Language files were not always being referenced correctly.
129
- Fixed bug: Manually fetching a feed fails if the feed is scheduled to update in the next 10 minutes.
130
- Fixed bug: Bing RSS feeds were importing duplicates on every update.
131
-
132
- 4.2.2 (2014-07-23)
133
- Enhanced: Improved live updating performace on the Feed Sources page.
134
- Enhanced: Facebook page feeds are now changed into RSS 2.0 feeds, rather than Atom 1.0 feeds.
135
-
136
- 4.2.1 (2014-07-17)
137
- Enhanced: Feed Sources page is now more responsive.
138
-
139
- 4.2 (2014-07-17)
140
- New Feature: Can now view each feed source's imported feed items separate from other feed sources' feed items.
141
- Enhanced: Major visual update to the Feed Sources page with new live updates.
142
- Enhanced: The custom feed now includes the feed source.
143
- Fixed bug: Google News feeds were importing duplicate items on every update.
144
- Fixed bug: Multiple minor bug fixes with old filters.
145
-
146
- 4.1.6 (2014-06-28)
147
- Fixed bug: Results returned by wprss_get_feed_items_for_source() will no longer be affected by filters.
148
- Fixed bug: Charset issue in titles
149
-
150
- 4.1.5 (2014-06-19)
151
- Enhanced: The Feed Sources table now indicates which feed sources encountered errors during the last import.
152
- Fixed bug: Feed titles were not being decoded for HTML entities.
153
-
154
- 4.1.4 (2014-05-16)
155
- Enhanced: Minor improvements to feed importing and handling.
156
- Fixed bug: HTML entities were not being decoded in feed item titles.
157
-
158
- 4.1.3 (2014-04-28)
159
- Enhanced: Added a force feed option, for valid RSS feeds with incorrect header content types.
160
- Fixed bug: HTML entities in feed item titles are now being decoded.
161
-
162
- 4.1.2 (2014-04-22)
163
- Enhanced: Improved the custom feed, by allowing a custom title.
164
- Enhanced: Improved shortcode, by adding the "pagination" parameter.
165
- Enhanced: Modified a filter to fix some bugs in the add-ons.
166
-
167
- 4.1.1 (2014-04-09)
168
- Enhanced: Tracking notices only appear for admin users.
169
- Fixed bug: Auto Feed Discovery was not working.
170
-
171
- 4.1 (2014-04-03)
172
- New Feature: Feed items can now link to enclosure links in the feed.
173
- Enhanced: Added a filter to allow add-ons to modify feed item queries.
174
-
175
- 4.0.9 (2014-03-27)
176
- Enhanced: Added a filter to modify the feeds template.
177
- Fixed bug: Nested lists in feeds template.
178
-
179
- 4.0.8 (2014-03-20)
180
- Enhanced: Fetch feeds row action now registers a cron job.
181
- Enhanced: Increased fetch feed timeout to 30 seconds.
182
- Fixed bug: Using the shortcode makes the comments section always open.
183
-
184
- 4.0.7 (2014-03-08)
185
- Fixed bug: The plugin prevented uploading of header images.
186
-
187
- 4.0.6 (2014-03-05)
188
- Fixed bug: Hook change in last version suspected reason for some installations having non-updated feed items.
189
-
190
- 4.0.5 (2014-03-03)
191
- New Feature: Time ago added as an option.
192
- Enhanced: The plugin now allows the use of RSS and Atom feeds that do not specify the correct MIME type.
193
- Enhanced: Better performance due to better hook usage.
194
- Fixed bug: Facebook page feed URL conversion was not being triggered for new feed sources.
195
- Fixed bug: Styles fix for pagination.
196
- Fixed bug: Removed empty spaces in logging.
197
-
198
- 4.0.4 (2014-02-22)
199
- Enhanced: Added Activate/Pause bulk actions in the Feed Sources page.
200
- Enhanced: Feed Sources page table has been re-designed.
201
- Enhanced: Logging is now site dependant on multisite.
202
- Fixed bug: Undefined display settings where appearing on the front end.
203
-
204
- 4.0.3 (2014-02-12)
205
- Fixed bug: The general setting for deleting feed items by age was not working.
206
-
207
- 4.0.2 (2014-02-10)
208
- Enhanced: Added a filter to change the html tags allowed in feed item content.
209
-
210
- 4.0.1 (2014-02-08)
211
- Fixed bug: Empty array of feed items bug caused importing problems.
212
-
213
- 4.0 (2014-02-04)
214
- Enhanced: Improved some internal queries, for better performance.
215
- Fixed bug: Feed limits were not working properly.
216
-
217
- 3.9.9 (2014-02-03)
218
- Enhanced: The custom feed can now be extended by add-ons.
219
-
220
- 3.9.8 (2014-01-20)
221
- Fixed bug: Removed excessive logging from Debugging Error Log.
222
-
223
- 3.9.7 (2014-01-17)
224
- Fixed bug: Bug in admin-debugging.php causing trouble with admin login
225
-
226
- 3.9.6 (2014-01-17)
227
- Enhanced: Added error logging.
228
-
229
- 3.9.5 (2014-01-02)
230
- Enhanced: Added a feed validator link in the New/Edit Feed Sources page.
231
- Enhanced: The Next Update column also shows the time remaining for next update, for feed source on the global update interval.
232
- Enhanced: The custom feed has been improved, and is now identical to the feeds displayed with the shortcode.
233
- Enhanced: License notifications only appear on the main site when using WordPress multisite.
234
- Enhanced: Updated Colorbox script to 1.4.33
235
- Fixed bug: The Imported Items column was always showing zero.
236
- Fixed bug: Feed items not being imported with limit set to zero. Should be unlimited.
237
- Fixed bug: Broken display template if titles are not linked and no source and date are displayed.
238
- Fixed bug: Fat header in Feed Sources page
239
-
240
- 3.9.4 (2013-12-24)
241
- Enhanced: Added a column in the Feed Sources page that shows the number of feed items imported for each feed source.
242
- Fixed bug: Leaving the delete old feed items empty did not ignore the delete.
243
-
244
- 3.9.3 (2013-12-23)
245
- Fixed bug: Fixed tracking pointer appearing on saving settings.
246
-
247
- 3.9.2 (2013-12-21)
248
- Fixed bug: Incorrect file include call.
249
-
250
- 3.9.1 (2013-12-21)
251
- Enhanced: Improved date and time handling for imported feed items.
252
- Fixed bug: Incorrect values being shown in the Feed Processing metabox.
253
- Fixed bug: Feed limits set to zero were causing feeds to not be imported.
254
-
255
- 3.9 (2013-12-12)
256
- New Feature: Feed sources can have their own update interval.
257
- New Feature: The time remaining until the next update has been added to the Feed Source table.
258
-
259
- 3.8 (2013-12-05)
260
- New Feature: Feed items can be limited and deleted by their age.
261
- Enhanced: Added utility functions for shorter filters.
262
- Fixed bug: License codes were being erased when add-ons were deactivated.
263
- Fixed bug: Some feed sources could not be set to active from the table controls.
264
- Fixed bug: str_pos errors appear when custom feed url is left empty.
265
- Fixed bug: Some options were producing undefined index errors.
266
-
267
- 3.7 (2013-11-28)
268
- New Feature: State system - Feed sources can be activated/paused.
269
- New Feature: State system - Feed sources can be set to activate or pause themselves at a specific date and time.
270
- Enhanced: Added compatibility with nested outline elements in OPML files.
271
- Enhanced: Admin menu icon image will change into a Dashicon, when WordPress is updated to 3.8 (Decemeber 2013).
272
- Fixed bug: Custom Post types were breaking when the plugin is activated.
273
-
274
- 3.6.1 (2013-11-17)
275
- Fixed bug: Missing 2nd argument for wprss_shorten_title()
276
-
277
- 3.6 (2013-11-16)
278
- New Feature: Can set the maximum length for titles. Long titles get trimmed.
279
- Fixed bug: Fixed errors with undefined indexes for unchecked checkboxes in the settings page.
280
- Fixed bug: Pagination on front static page was not working.
281
-
282
- 3.5.2 (2013-11-11)
283
- Fixed bug: Invalid feed source url was producing an Undefined method notice.
284
- Fixed bug: Custom feed was producing a 404 page.
285
- Fixed bug: Presstrends code firing on admin_init, opt-in implementation coming soon
286
-
287
- 3.5.1 (2013-11-09)
288
- Enhanced: Increased compatibility with RSS sources.
289
- Fixed bug: Pagination not working on home page
290
-
291
- 3.5 (2013-11-6)
292
- New Feature: Can delete feed items for a particular source
293
- Enhanced: the 'Fetch feed items' row action for feed sources resets itself after 3.5 seconds.
294
- Enhanced: The feed image is saved for each url.
295
- Fixed bug: Link to source now links to correct url. Previously linked to site's feed.
296
-
297
- 3.4.6 (2013-11-1)
298
- Enhanced: Added more hooks to debugging page for the Feed to Post add-on.
299
- Fixed bug: Uninitialized loop index
300
-
301
- 3.4.5 (2013-10-30)
302
- Bug Fix: Feed items were not being imported while the WPML plugin was active.
303
-
304
- 3.4.4 (2013-10-26)
305
- New feature: Pagination
306
- New feature: First implementation of editor button for easy shortcode creation
307
- Enhanced: Feed items and sources don't show up in link manager
308
- Enhanced: Included Presstrends code for plugin usage monitoring
309
-
310
- 3.4.3 (2013-10-20)
311
- Fixed bug: Removed anonymous functions for backwards PHP compatibility
312
- Bug fix: Added suppress_filters in feed-display.php to prevent a user reported error
313
- Bug fix: Missing <li> in certain feed displays
314
-
315
- 3.4.2 (2013-9-19)
316
- Enhanced: Added some hooks for Feed to Post compatibility
317
- Enhanced: Moved date settings to a more appropriate location
318
-
319
- 3.4.1 (2013-9-16)
320
- Fixed Bug: Minor issue with options page - PHP notice
321
-
322
- 3.4 (2013-9-15)
323
- New Feature: Saving/Updating a feed source triggers an update for that source's feed items.
324
- New Feature: Option to change Youtube, Vimeo and Dailymotion feed item URLs to embedded video players URLs
325
- New Feature: Facebook Pages URLs are automatically detected and changed into Atom Feed URLs using FB's Graph
326
- Enhanced: Updated jQuery Colorbox library to 1.4.29
327
- Fixed Bug: Some settings did not have a default value set, and were throwing an 'Undefined Index' error
328
- Fixed Bug: Admin notices do not disappear immediately when dismissed.
329
-
330
- 3.3.3 (2013-09-08)
331
- Fixed bug: Better function handling on uninstall, should remove uninstall issues
332
-
333
- 3.3.2 (2013-09-07)
334
- New feature: Added exclude parameter to shortcode
335
- Enhanced: Added metabox links to documentation and add-ons
336
- Fixed bug: Custom feed linking to post on user site rather than original source
337
- Fixed bug: Custom post types issues when activitating the plugin
338
-
339
- 3.3.1 (2013-08-09)
340
- Fixed bug: Roles and Capabilities file had not been included
341
- Fixed bug: Error on install, function not found
342
-
343
- 3.3 (2013-08-08)
344
- New feature: OPML importer
345
- New feature: Feed item limits for individual Feed Sources
346
- New feature: Custom feed URL
347
- New feature: Feed limit on custom feed
348
- New feature: New 'Fetch feed items' action for each Feed Source in listing display
349
- New feature: Option to enable link to source
350
- Enhanced: Date strings now change according to locale being used (i.e. compatible with WPML)
351
- Enhanced: Capabilities implemented
352
- Enhanced: Feed Sources row action 'View' removed
353
- Fixed Bug: Proxy feed URLs resulting in the permalink: example.com/url
354
-
355
- 3.2 (2013-07-06)
356
- New feature: Parameter to limit number of feeds displayed
357
- New feature: Paramter to limit feeds displayed to particular sources (via ID)
358
- New feature: Now handles licensing for add-ons
359
- Enhanced: Better feed import handling to handle large number of feed sources
360
-
361
- 3.1.1 (2013-06-06)
362
- Fixed bug: Incompatibility with some other plugins due to function missing namespace
363
-
364
- 3.1 (2013-06-06)
365
- New feature: Option to set the number of feed items imported from every feed (default 5)
366
- New feature: Import and Export aggregator settings and feed sources
367
- New feature: Debugging page allowing manual feed refresh and feed reset
368
- Enhanced: Faster handling of restoring sources from trash when feed limit is 0
369
- Fixed bug: Limiter on number of overall feeds stored not working
370
- Fixed bug: Incompatibility issue with Foobox plugin fixed
371
- Fixed bug: Duplicate feeds sometimes imported
372
-
373
- 3.0 (2013-03-16)
374
- New feature: Option to select cron frequency
375
- New feature: Code extensibility added to be compatible with add-ons
376
- New feature: Option to set a limit to the number of feeds stored (previously 50, hard coded)
377
- New feature: Option to define the format of the date shown below each feed item
378
- New feature: Option to show or hide source of feed item
379
- New feature: Option to show or hide publish date of feed item
380
- New feature: Option to set text preceding publish date
381
- New feature: Option to set text preceding source of feed item
382
- New feature: Option to link title or not
383
- New feature: Limit of 5 items imported for each source instead of 10
384
- Enhanced: Performance improvement when publishing new feeds in admin
385
- Enhanced: Query tuning for better performance
386
- Enhanced: Major code rewrite, refactoring and inclusion of hooks
387
- Enhanced: Updated Colorbox to v1.4.1
388
- Enhanced: Better security implementations
389
- Enhanced: Better feed preview display
390
- Fixed bug: Deletion of items upon source deletion not working properly
391
- Requires: WordPress 3.3
392
-
393
- 2.2.3 (2012-11-01)
394
- Fixed bug: Tab navigation preventing typing in input boxes
395
- Removed: Feeds showing up in internal linking pop up
396
-
397
- 2.2.2 (2012-10-30)
398
- Removed: Feeds showing up in site search results
399
- Enhanced: Better tab button navigation when adding a new feed
400
- Enhanced: Better guidance when a feed URL is invalid
401
-
402
- 2.2.1 (2012-10-17)
403
- Fixed bug: wprss_feed_source_order assumes everyone is an admin
404
-
405
- 2.2 (2012-10-01)
406
- New feature: Italian translation added
407
- Enhanced: Feed source order changed to alphabetical
408
- Fixed bug: repeated entries when having a non-valid feed source
409
- Fixed bug: all imported feeds deleted upon trashing a single feed source
410
-
411
- 2.1 (2012-09-27)
412
- New feature: Now localised for translations
413
- Fixed bug: with date string
414
- Fixed bug: $link_before and $link_after, now working
415
- Enhanced: Added backwards compatibility for wp_rss_aggregator() function
416
-
417
- 2.0 (2012-09-21)
418
- Bulk of code rewritten and refactored
419
- Added install and upgrade functions
420
- Added DB version setting
421
- Feed sources now stored as Custom Post Types
422
- Feed source list sortable ascending or descending by name
423
- Removed days subsections in feed display
424
- Ability to limit total number of feeds displayed
425
- Feeds now fetched via Cron
426
- Cron job to delete old feed items, keeps max of 50 items in DB
427
- Now requires WordPress 3.2
428
- updated colorbox to v1.3.20.1
429
- Limit of 15 items max imported for each source
430
- Fixed issue of page content displaying incorrectly after feeds
431
-
432
- 1.1 (2012-08-13)
433
- Now requires WordPress 3.0
434
- More flexible fetching of images directory
435
- Has its own top level menu item
436
- Added settings section
437
- Ability to open in lightbox, new window or default browser behaviour
438
- Ability to set links as follow or no follow
439
- Using constants for oftenly used locations
440
- Code refactoring
441
- Changes in file and folder structure
442
-
443
- 1.0 (2012-01-06)
444
- First release
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/admin-addons.php CHANGED
@@ -41,7 +41,7 @@
41
  'title' => __( "Full Text RSS Feeds", WPRSS_TEXT_DOMAIN ),
42
  'description' => __( "This add-ons provides the connectivity to our Full Text Premium service, which gives you unlimited feed items returned per feed source.", WPRSS_TEXT_DOMAIN ),
43
  'thumbnail' => WPRSS_IMG . 'add-ons/wprss.jpg',
44
- 'active' => is_plugin_active( 'wp-rss-full-text/wp-rss-full-text.php' ),
45
  'url' => 'http://www.wprssaggregator.com/extension/full-text-rss-feeds/'
46
  );
47
  $premium[] = array(
41
  'title' => __( "Full Text RSS Feeds", WPRSS_TEXT_DOMAIN ),
42
  'description' => __( "This add-ons provides the connectivity to our Full Text Premium service, which gives you unlimited feed items returned per feed source.", WPRSS_TEXT_DOMAIN ),
43
  'thumbnail' => WPRSS_IMG . 'add-ons/wprss.jpg',
44
+ 'active' => is_plugin_active( 'wp-rss-full-text-feeds/wp-rss-full-text.php' ),
45
  'url' => 'http://www.wprssaggregator.com/extension/full-text-rss-feeds/'
46
  );
47
  $premium[] = array(
includes/admin-metaboxes.php CHANGED
@@ -239,7 +239,8 @@
239
  */
240
  function wprss_validate_feed_link() {
241
  ?>
242
- <br/>
 
243
  <a href="#" id="validate-feed-link">Validate feed</a>
244
  <script type="text/javascript">
245
  (function($){
239
  */
240
  function wprss_validate_feed_link() {
241
  ?>
242
+ <i id="wprss-url-spinner" class="fa fa-fw fa-refresh fa-spin wprss-updating-feed-icon" title="<?php _e( 'Updating feed source', WPRSS_TEXT_DOMAIN ) ?>"></i>
243
+ <div id="wprss-url-error" style="color:red"></div>
244
  <a href="#" id="validate-feed-link">Validate feed</a>
245
  <script type="text/javascript">
246
  (function($){
includes/admin-options.php CHANGED
@@ -1042,11 +1042,19 @@
1042
  }
1043
  // For each entry in the received input
1044
  foreach ( $input as $addon => $license_code ) {
1045
- // If the entry does not exist OR the code is different
1046
- if ( !array_key_exists( $addon, $licenses ) || $license_code !== $licenses[ $addon ] ) {
1047
- // Save it to the licenses option
1048
- $licenses[ $addon ] = $license_code;
1049
- }
 
 
 
 
 
 
 
 
1050
  }
1051
  wprss_check_license_statuses();
1052
  // Return the new licenses
1042
  }
1043
  // For each entry in the received input
1044
  foreach ( $input as $addon => $license_code ) {
1045
+ $addon_code = explode( '_', $addon );
1046
+ $addon_code = isset( $addon_code[0] ) ? $addon_code[0] : null;
1047
+ // Only save if the entry does not exist OR the code is different
1048
+ if ( array_key_exists( $addon, $licenses ) && $license_code === $licenses[ $addon ] )
1049
+ continue;
1050
+
1051
+ $is_valid = apply_filters( 'wprss_settings_license_key_is_valid', true, $license_code );
1052
+ if( $addon_code )
1053
+ $is_valid = apply_filters( "wprss_settings_license_key_{$addon_code}_is_valid", $is_valid, $license_code );
1054
+ if( !$is_valid ) continue;
1055
+
1056
+ // Save it to the licenses option
1057
+ $licenses[ $addon ] = $license_code;
1058
  }
1059
  wprss_check_license_statuses();
1060
  // Return the new licenses
includes/admin-welcome.php CHANGED
@@ -6,52 +6,9 @@
6
 
7
  // Exit if the page is accessed directly
8
  if ( ! defined( 'ABSPATH' ) ) exit;
9
-
10
-
11
- /**
12
- * Parses the changelog, and returns an array of the last version entry.
13
- *
14
- * @since 4.4
15
- * @return array
16
- */
17
- function wprss_parse_changelog() {
18
- // Read changelog file
19
- $contents = file_get_contents( WPRSS_DIR . 'changelog.txt' );
20
- // Split into lines and remove first line
21
- $lines = explode( "\n", $contents );
22
- unset($lines[0]);
23
-
24
- // Lines chosen for last changelog entry i.e. lines until an empty line is encountered
25
- $chosen = array();
26
- // Iterate the lines
27
- foreach( $lines as $line ) {
28
- // if the line is empty, stop iterating
29
- if ( trim($line) == '' ) {
30
- break;
31
- }
32
- // otherwise, add it to chosen
33
- $chosen[] = $line;
34
- }
35
-
36
- $final = array();
37
- // Iterate lines
38
- foreach( $chosen as $line ) {
39
- // Split by colon
40
- $colon = strpos( $line, ":" );
41
- // Get the type (New Feature, Enhanced, Fixed Bug)
42
- $type = trim( substr( $line, 0, $colon ) );
43
- // Get the description
44
- $desc = trim( substr( $line, $colon + 1 ) );
45
- // Add it to the final array
46
- $final[] = array(
47
- 'type' => $type,
48
- 'desc' => $desc
49
- );
50
- }
51
-
52
- // Return the final array
53
- return $final;
54
- }
55
 
56
 
57
  // The tabs to be shown
@@ -155,14 +112,13 @@
155
 
156
  <hr/>
157
 
158
- <h3><?php printf( __( 'Changelog for v%1$s', WPRSS_TEXT_DOMAIN ), WPRSS_VERSION ) ?></h3>
159
- <ul>
160
- <?php // CHANGELOG
161
- $changelog = wprss_parse_changelog();
162
- foreach( $changelog as $entry ): ?>
163
- <li><strong><?php _e( $entry['type'], WPRSS_TEXT_DOMAIN ) ?></strong>: <?php _e( $entry['desc'], WPRSS_TEXT_DOMAIN ) ?></li>
164
- <?php endforeach; ?>
165
- </ul>
166
 
167
  <?php echo wpautop( sprintf( __( 'Need functionality not already available in core or the add-ons? You can <a href="%1$s">suggest new features</a>!', WPRSS_TEXT_DOMAIN ), 'http://www.wprssaggregator.com/feature-requests/' ) ) ?>
168
 
6
 
7
  // Exit if the page is accessed directly
8
  if ( ! defined( 'ABSPATH' ) ) exit;
9
+
10
+ // The readme lib
11
+ require_once( WPRSS_INC . '/readme.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
 
14
  // The tabs to be shown
112
 
113
  <hr/>
114
 
115
+ <?php $changelog = wprss_parse_changelog() ?>
116
+ <?php if ( count( $changelog ) ): foreach( $changelog as $_version => $_changes_html ): ?>
117
+ <h3><?php printf( __( 'Changelog for v%1$s', WPRSS_TEXT_DOMAIN ), $_version ) ?></h3>
118
+ <div class="changelog-changeset" >
119
+ <?php echo $_changes_html ?>
120
+ </div>
121
+ <?php break; endforeach; endif; ?>
 
122
 
123
  <?php echo wpautop( sprintf( __( 'Need functionality not already available in core or the add-ons? You can <a href="%1$s">suggest new features</a>!', WPRSS_TEXT_DOMAIN ), 'http://www.wprssaggregator.com/feature-requests/' ) ) ?>
124
 
includes/admin.php CHANGED
@@ -135,7 +135,7 @@
135
  delete_transient( 'wprss_notify_inactive_licenses' );
136
 
137
  // Show the notice ?>
138
- <div class="updated">
139
  <?php echo wpautop( sprintf( __('<b>WP RSS Aggregator</b>:'
140
  . ' There are saved licenses that have not yet been activated. Go to the'
141
  . ' <a href="%1$s">License page</a> to activate them.', WPRSS_TEXT_DOMAIN ), admin_url() . 'edit.php?post_type=wprss_feed&page=wprss-aggregator-settings&tab=licenses_settings' ) ) ?>
135
  delete_transient( 'wprss_notify_inactive_licenses' );
136
 
137
  // Show the notice ?>
138
+ <div class="wprss-license-notice updated">
139
  <?php echo wpautop( sprintf( __('<b>WP RSS Aggregator</b>:'
140
  . ' There are saved licenses that have not yet been activated. Go to the'
141
  . ' <a href="%1$s">License page</a> to activate them.', WPRSS_TEXT_DOMAIN ), admin_url() . 'edit.php?post_type=wprss_feed&page=wprss-aggregator-settings&tab=licenses_settings' ) ) ?>
includes/feed-importing.php CHANGED
@@ -132,7 +132,10 @@
132
  // Get the number of feed items we can store until we reach the limit
133
  $num_can_insert = $feed_limit - $num_db_feed_items;
134
  // Calculate how many feed items we must delete before importing, to keep to the limit
135
- $num_feed_items_to_delete = count( $new_items ) - $num_can_insert;
 
 
 
136
 
137
  // Get an array with the DB feed items in reverse order (oldest first)
138
  $db_feed_items_reversed = array_reverse( $db_feed_items->posts );
132
  // Get the number of feed items we can store until we reach the limit
133
  $num_can_insert = $feed_limit - $num_db_feed_items;
134
  // Calculate how many feed items we must delete before importing, to keep to the limit
135
+ $num_new_items = count( $new_items );
136
+ $num_feed_items_to_delete = $num_can_insert > $num_new_items
137
+ ? 0
138
+ : $num_new_items - $num_can_insert;
139
 
140
  // Get an array with the DB feed items in reverse order (oldest first)
141
  $db_feed_items_reversed = array_reverse( $db_feed_items->posts );
includes/image-caching.php ADDED
@@ -0,0 +1,290 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WPRSS_Image_Cache {
4
+
5
+ protected $_download_request_timeout = 300;
6
+
7
+ protected $_image_class_name = 'WPRSS_Image_Cache_Image';
8
+ protected $_images = array();
9
+
10
+ public function __construct() {
11
+ }
12
+
13
+ public function set_image_class_name( $class_name ) {
14
+ $this->_image_class_name = $class_name;
15
+ return $this;
16
+ }
17
+
18
+ public function get_image_class_name() {
19
+ return trim($this->_image_class_name);
20
+ }
21
+
22
+ public function set_download_request_timeout( $timeout ) {
23
+ $this->_download_request_timeout = intval( $timeout );
24
+ return $this;
25
+ }
26
+
27
+ public function get_download_request_timeout() {
28
+ return $this->_download_request_timeout;
29
+ }
30
+
31
+ /**
32
+ * @param string $url
33
+ * @return \WPRSS_Image_Cache_Image
34
+ * @throws Exception If class invalid, or not found
35
+ */
36
+ public function get_new_image( $url = null ) {
37
+ $error_caption = 'Could not create new cache image';
38
+ $class_name = $this->get_image_class_name();
39
+ if ( empty( $class_name ) ) throw new Exception( sprintf( '%1$s: class name must not be empty' ) );
40
+ if ( !class_exists( $class_name ) ) throw new Exception( sprintf( '%1$s: class "%2$s" does not exist', $class_name ) );
41
+
42
+ $image = new $class_name();
43
+ $this->_prepare_image( $image );
44
+ /* @var $image WPRSS_Image_Cache_Image */
45
+ if ( !is_null( $url ) ) $image->set_url( $url );
46
+
47
+ return $image;
48
+ }
49
+
50
+ /**
51
+ *
52
+ * @param WPRSS_Image_Cache_Image $image
53
+ */
54
+ protected function _prepare_image( $image ) {
55
+ $image->set_download_request_timeout( $this->get_download_request_timeout() );
56
+ }
57
+
58
+ public function get_images( $url = null ) {
59
+ if ( is_null( $url ) ) return $this->_images;
60
+
61
+ // Gotta cache one
62
+ if ( !isset( $this->_images[ $url ] ) ) {
63
+ try {
64
+ $image = $this->_download_image($url);
65
+ } catch ( Exception $e ) {
66
+ return new WP_Error( 'image_cache_cannot_download', $e->getMessage() );
67
+ }
68
+
69
+ $this->_images[ $url ] = $image;
70
+ }
71
+
72
+ return $this->_images[ $url ];
73
+ }
74
+
75
+ public function purge() {
76
+ $image_class_name = $this->get_image_class_name();
77
+ foreach( $this->get_images() as $_url => $_image ) {
78
+ /* @var $_image WPRSS_Image_Cache_Image */
79
+ if ( is_a( $_image, $image_class_name ) )
80
+ $_image->delete();
81
+ }
82
+
83
+ $this->_images = array();
84
+ return $this;
85
+ }
86
+
87
+ /**
88
+ * @param string $url
89
+ * @return WPRSS_Image_Cache_Image
90
+ */
91
+ protected function _download_image( $url ) {
92
+ $image = $this->get_new_image( $url );
93
+ $image->download();
94
+
95
+ return $image;
96
+ }
97
+ }
98
+
99
+ class WPRSS_Image_Cache_Image {
100
+
101
+ protected $_url;
102
+ protected $_local_path;
103
+ protected $_unique_name;
104
+ protected $_size;
105
+ protected $_download_request_timeout;
106
+ protected $_is_attempted;
107
+ protected $_is_fall_back_to_unsecure;
108
+
109
+ public function __construct( $data = null ) {
110
+ $this->reset();
111
+
112
+ if ( is_string( $data ) && !empty( $data ) )
113
+ $this->_set_url( $data );
114
+ }
115
+
116
+ public function reset() {
117
+ $this->_url = null;
118
+ $this->_local_path = null;
119
+ $this->_unique_name = null;
120
+ $this->_size = null;
121
+ $this->_download_request_timeout = 300;
122
+ $this->_is_attempted = false;
123
+ $this->_is_fall_back_to_unsecure = true;
124
+
125
+ return $this;
126
+ }
127
+
128
+ protected function _set_url( $url ) {
129
+ $this->_url = $url;
130
+ return $this;
131
+ }
132
+
133
+ public function set_url( $url ) {
134
+ $this->reset();
135
+ $this->_set_url($url);
136
+
137
+ return $this;
138
+ }
139
+
140
+ public function get_url() {
141
+ return $this->_url;
142
+ }
143
+
144
+ public function has_url() {
145
+ return isset( $this->_url );
146
+ }
147
+
148
+ protected function _set_local_path( $path ) {
149
+ $this->_local_path = $path;
150
+ return $this;
151
+ }
152
+
153
+ public function get_local_path() {
154
+ return $this->_local_path;
155
+ }
156
+
157
+ public function has_local_path() {
158
+ return isset( $this->_local_path );
159
+ }
160
+
161
+ public function set_download_request_timeout( $timeout ) {
162
+ $this->_download_request_timeout = intval( $timeout );
163
+ return $this;
164
+ }
165
+
166
+ public function get_download_request_timeout() {
167
+ return $this->_download_request_timeout;
168
+ }
169
+
170
+ protected function _is_attempted( $is_attempted = null ) {
171
+ if ( is_null( $is_attempted ) )
172
+ return (bool)$this->_is_attempted;
173
+
174
+ $this->_is_attempted = (bool) $is_attempted;
175
+ return $this;
176
+ }
177
+
178
+ public function is_attempted() {
179
+ return $this->_is_attempted();
180
+ }
181
+
182
+ public function is_fall_back_to_unsecure( $is_fall_back = null ) {
183
+ if ( is_null( $is_fall_back ) )
184
+ return (bool) $this->_is_fall_back_to_unsecure;
185
+
186
+ $this->_is_fall_back_to_unsecure = (bool) $is_fall_back;
187
+ return $this;
188
+ }
189
+
190
+ public function download() {
191
+ $error_caption = 'Could not download image';
192
+ if ( !$this->has_url() ) throw new Exception ( sprintf( '%1$s: a URL must be supplied' ) );
193
+
194
+ // Getting file download lib
195
+ $file_lib_path = ABSPATH . 'wp-admin/includes/file.php';
196
+ if ( !is_readable( $file_lib_path ) ) throw new Exception( sprintf( '%1$s: the file library cannot be read from %2$s', $error_caption, $file_lib_path ) );
197
+ require_once( $file_lib_path );
198
+
199
+ // Downloading the image
200
+ $url = $this->get_url();
201
+ $timeout = $this->get_download_request_timeout();
202
+ $tmp_path = $this->_download( $url, $timeout );
203
+ if ( is_wp_error( $tmp_path ) ) throw new Exception ( sprintf( '%1$s: %2$s', $error_caption, $tmp_path->get_error_message() ) );
204
+ // wprss_log( sprintf( 'Image saved to "%1$s"', $tmp_path ), null, WPRSS_LOG_LEVEL_SYSTEM );
205
+ $this->_set_local_path( $tmp_path );
206
+
207
+ return $this->get_local_path();
208
+ }
209
+
210
+ protected function _download( $url, $timeout ) {
211
+ // wprss_log( sprintf( 'Downloading from "%1$s"', $url ), null, WPRSS_LOG_LEVEL_SYSTEM );
212
+ $tmp_path = download_url( $url, $timeout );
213
+ if ( is_wp_error( $tmp_path ) ) {
214
+ $https = 'https';
215
+ if ( $this->is_fall_back_to_unsecure() && (stripos( $url, $https ) === 0) ) {
216
+ $url = 'http' . substr( $url, strlen( $https ) );
217
+ // wprss_log( sprintf( 'Downloading from "%1$s"', $url ), null, WPRSS_LOG_LEVEL_SYSTEM );
218
+ $tmp_path = $this->_download( $url, $timeout );
219
+ }
220
+ }
221
+
222
+ return $tmp_path;
223
+ }
224
+
225
+ public function delete() {
226
+ if ( $path = $this->get_local_path() )
227
+ unlink( $path );
228
+
229
+ return $this;
230
+ }
231
+
232
+ public function get_unique_name() {
233
+ if( !isset($this->_unique_name) ) {
234
+ $url = $this->get_url();
235
+ // Extract filename from url for title (ignoring query string)
236
+ // One of more character that is not a '?', followed by an image extension
237
+ preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches );
238
+ $url_filename = basename( urldecode( $matches[0] ) );
239
+ // Check for extension. If not found, use last component of the URL
240
+ if ( !isset( $matches[1] ) ) {
241
+ $matches = array();
242
+ // Get the path to the image, without the domain. ex. /news/132456/image
243
+ preg_match_all( '/[^:]+:\/\/[^\/]+\/(.+)/', $url, $matches );
244
+ // If found
245
+ if ( isset( $matches[1][0] ) ) {
246
+ // Replace all '/' into '.' for the filename
247
+ $url_filename = str_replace( '/', '-', $matches[1][0] );
248
+ }
249
+ // If not found
250
+ else {
251
+ // Use a random string as a fallback, with length of 16 characters
252
+ $url_filename = wprss_ftp_generate_random_string( 16 );
253
+ }
254
+ }
255
+ // determine file type (ext and mime/type)
256
+ $url_type = wp_check_filetype($url_filename);
257
+ }
258
+
259
+ return $this->_unique_name;
260
+ }
261
+
262
+ public function get_size() {
263
+ if ( !isset( $this->_size ) ) {
264
+ $error_caption = 'Could not get image size';
265
+ if ( !$this->is_readable() ) throw new Exception( sprintf( '%1$s: image file is not readable' ) );
266
+ $path = $this->get_local_path();
267
+
268
+ // Trying simplest way
269
+ if ( $size = getimagesize( $path ) )
270
+ $this->_size = array( 0 => $size[0], 1 => $size[1] );
271
+
272
+ wprss_log( sprintf( 'Tried `getimagesize()`: %1$s', empty($this->_size) ? 'failure' : 'success' ), __METHOD__, WPRSS_LOG_LEVEL_SYSTEM );
273
+
274
+ if( !$this->_size && function_exists( 'gd_info' ) ) {
275
+ $image = file_get_contents( $path );
276
+ $image = imagecreatefromstring( $image );
277
+ $width = imagesx( $image );
278
+ $height = imagesy( $image );
279
+ $this->_size = array( 0 => $width, 1 => $height );
280
+ wprss_log( sprintf( 'Tried GD: %1$s', empty($this->_size) ? 'failure' : 'success' ), __METHOD__, WPRSS_LOG_LEVEL_SYSTEM );
281
+ }
282
+ }
283
+
284
+ return $this->_size;
285
+ }
286
+
287
+ public function is_readable() {
288
+ return is_readable( $this->get_local_path() );
289
+ }
290
+ }
includes/libraries/WordPress-Readme-Parser/ReadmeParser.php ADDED
@@ -0,0 +1,329 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Custom readme parser
4
+ *
5
+ * Based on Automattic_Readme from http://code.google.com/p/wordpress-plugin-readme-parser/
6
+ *
7
+ * Relies on Markdown_Extra
8
+ *
9
+ * @todo Handle screenshots section properly
10
+ * @todo Create validator for this based on http://code.google.com/p/wordpress-plugin-readme-parser/source/browse/trunk/validator.php
11
+ */
12
+ class Baikonur_ReadmeParser {
13
+
14
+ public static function parse_readme($file) {
15
+ $contents = file($file);
16
+ return self::parse_readme_contents($contents);
17
+ }
18
+
19
+ public static function parse_readme_contents($contents) {
20
+ if (is_string($contents)) {
21
+ $contents = explode("\n", $contents);
22
+ }
23
+
24
+ $this_class = __CLASS__;
25
+ if (function_exists('get_called_class')) {
26
+ $this_class = get_called_class();
27
+ }
28
+
29
+ $contents = array_map(array($this_class, 'strip_newlines'), $contents);
30
+
31
+ // Strip BOM
32
+ if (strpos($contents[0], "\xEF\xBB\xBF") === 0) {
33
+ $contents[0] = substr($contents[0], 3);
34
+ }
35
+
36
+ $data = new stdClass;
37
+
38
+ // Defaults
39
+ $data->is_excerpt = false;
40
+ $data->is_truncated = false;
41
+ $data->tags = array();
42
+ $data->requires = '';
43
+ $data->tested = '';
44
+ $data->contributors = array();
45
+ $data->stable_tag = '';
46
+ $data->version = '';
47
+ $data->donate_link = '';
48
+ $data->short_description = '';
49
+ $data->sections = array();
50
+ $data->changelog = array();
51
+ $data->upgrade_notice = array();
52
+ $data->screenshots = array();
53
+ $data->remaining_content = array();
54
+
55
+ $line = call_user_func_array(array($this_class, 'get_first_nonwhitespace'), array(&$contents));
56
+ $data->name = $line;
57
+ $data->name = trim($data->name, "#= ");
58
+
59
+ // Parse headers
60
+ $headers = array();
61
+
62
+ $line = call_user_func_array(array($this_class, 'get_first_nonwhitespace'), array(&$contents));
63
+ do {
64
+ $key = $value = null;
65
+ if (strpos($line, ':') === false) {
66
+ break;
67
+ }
68
+ $bits = explode(':', $line, 2);
69
+ list($key, $value) = $bits;
70
+ $key = strtolower(str_replace(array(' ', "\t"), '_', trim($key)));
71
+ if ($key === 'tags' && isset($headers['tags'])) {
72
+ $headers[$key] .= ',' . trim($value);
73
+ }
74
+ else {
75
+ $headers[$key] = trim($value);
76
+ }
77
+ }
78
+ while (($line = array_shift($contents)) !== null && ($line = trim($line)) && !empty($line));
79
+ array_unshift($contents, $line);
80
+
81
+ if (!empty($headers['tags'])) {
82
+ $data->tags = explode(',', $headers['tags']);
83
+ $data->tags = array_map('trim', $data->tags);
84
+ }
85
+ if (!empty($headers['requires'])) {
86
+ $data->requires = $headers['requires'];
87
+ }
88
+ if (!empty($headers['requires_at_least'])) {
89
+ $data->requires = $headers['requires_at_least'];
90
+ }
91
+ if (!empty($headers['tested'])) {
92
+ $data->tested = $headers['tested'];
93
+ }
94
+ if (!empty($headers['tested_up_to'])) {
95
+ $data->tested = $headers['tested_up_to'];
96
+ }
97
+ if (!empty($headers['contributors'])) {
98
+ $data->contributors = explode(',', $headers['contributors']);
99
+ $data->contributors = array_map('trim', $data->contributors);
100
+ }
101
+ if (!empty($headers['stable_tag'])) {
102
+ $data->stable_tag = $headers['stable_tag'];
103
+ }
104
+ if (!empty($headers['donate_link'])) {
105
+ $data->donate_link = $headers['donate_link'];
106
+ }
107
+ if (!empty($headers['version'])) {
108
+ $data->version = $headers['version'];
109
+ }
110
+ else {
111
+ $data->version = $data->stable_tag;
112
+ }
113
+
114
+ // Parse the short description
115
+ while (($line = array_shift($contents)) !== null) {
116
+ $trimmed = trim($line);
117
+ if (empty($trimmed)) {
118
+ $data->short_description .= "\n";
119
+ continue;
120
+ }
121
+ if ($trimmed[0] === '=' && isset($trimmed[1]) && $trimmed[1] === '=') {
122
+ array_unshift($contents, $line);
123
+ break;
124
+ }
125
+
126
+ $data->short_description .= $line . "\n";
127
+ }
128
+ $data->short_description = trim($data->short_description);
129
+
130
+ $data->is_truncated = call_user_func_array(array($this_class, 'trim_short_desc'), array(&$data->short_description));
131
+
132
+ // Parse the rest of the body
133
+ $current = '';
134
+ $special = array('description', 'installation', 'faq', 'frequently_asked_questions', 'screenshots', 'changelog', 'upgrade_notice');
135
+
136
+ while (($line = array_shift($contents)) !== null) {
137
+ $trimmed = trim($line);
138
+ if (empty($trimmed)) {
139
+ $current .= "\n";
140
+ continue;
141
+ }
142
+
143
+ if ($trimmed[0] === '=' && isset($trimmed[1]) && $trimmed[1] === '=') {
144
+ if (!empty($title)) {
145
+ $data->sections[$title] = trim($current);
146
+ }
147
+
148
+ $current = '';
149
+ $real_title = trim($line, "#= \t");
150
+ $title = strtolower(str_replace(' ', '_', $real_title));
151
+ if ($title === 'faq') {
152
+ $title = 'frequently_asked_questions';
153
+ }
154
+ elseif ($title === 'change_log') {
155
+ $title = 'changelog';
156
+ }
157
+ if (!in_array($title, $special)) {
158
+ $current .= '<h3>' . $real_title . "</h3>";
159
+ }
160
+ continue;
161
+ }
162
+
163
+ $current .= $line . "\n";
164
+ }
165
+
166
+ if (!empty($title)) {
167
+ $data->sections[$title] = trim($current);
168
+ }
169
+ $title = null;
170
+ $current = null;
171
+
172
+ if (empty($data->sections['description'])) {
173
+ $data->sections['description'] = call_user_func(array($this_class, 'parse_markdown'), $data->short_description);
174
+ }
175
+
176
+ // Parse changelog
177
+ if (!empty($data->sections['changelog'])) {
178
+ $lines = explode("\n", $data->sections['changelog']);
179
+ while (($line = array_shift($lines)) !== null) {
180
+ $trimmed = trim($line);
181
+ if (empty($trimmed)) {
182
+ continue;
183
+ }
184
+
185
+ if ($trimmed[0] === '=') {
186
+ if (!empty($current)) {
187
+ $data->changelog[$title] = trim($current);
188
+ }
189
+
190
+ $current = '';
191
+ $title = trim($line, "#= \t");
192
+ continue;
193
+ }
194
+
195
+ $current .= $line . "\n";
196
+ }
197
+
198
+ $data->changelog[$title] = trim($current);
199
+ }
200
+ $title = null;
201
+ $current = null;
202
+
203
+ if (isset($data->sections['upgrade_notice'])) {
204
+ $lines = explode("\n", $data->sections['upgrade_notice']);
205
+ while (($line = array_shift($lines)) !== null) {
206
+ $trimmed = trim($line);
207
+ if (empty($trimmed)) {
208
+ continue;
209
+ }
210
+
211
+ if ($trimmed[0] === '=') {
212
+ if (!empty($current)) {
213
+ $data->upgrade_notice[$title] = trim($current);
214
+ }
215
+
216
+ $current = '';
217
+ $title = trim($line, "#= \t");
218
+ continue;
219
+ }
220
+
221
+ $current .= $line . "\n";
222
+ }
223
+
224
+ if (!empty($title) && !empty($current)) {
225
+ $data->upgrade_notice[$title] = trim($current);
226
+ }
227
+ unset($data->sections['upgrade_notice']);
228
+ }
229
+
230
+ // Markdownify!
231
+
232
+ $data->sections = array_map(array($this_class, 'parse_markdown'), $data->sections);
233
+ $data->changelog = array_map(array($this_class, 'parse_markdown'), $data->changelog);
234
+ $data->upgrade_notice = array_map(array($this_class, 'parse_markdown'), $data->upgrade_notice);
235
+
236
+ if (isset($data->sections['screenshots'])) {
237
+ preg_match_all('#<li>(.*?)</li>#is', $data->sections['screenshots'], $screenshots, PREG_SET_ORDER);
238
+ if ($screenshots) {
239
+ foreach ((array) $screenshots as $ss) {
240
+ $data->screenshots[] = trim($ss[1]);
241
+ }
242
+ }
243
+ }
244
+
245
+ // Rearrange stuff
246
+
247
+ $data->remaining_content = $data->sections;
248
+ $data->sections = array();
249
+
250
+ foreach ($special as $spec) {
251
+ if (isset($data->remaining_content[$spec])) {
252
+ $data->sections[$spec] = $data->remaining_content[$spec];
253
+ unset($data->remaining_content[$spec]);
254
+ }
255
+ }
256
+
257
+ return $data;
258
+ }
259
+
260
+ protected static function get_first_nonwhitespace(&$contents) {
261
+ while (($line = array_shift($contents)) !== null) {
262
+ $trimmed = trim($line);
263
+ if (!empty($line)) {
264
+ break;
265
+ }
266
+ }
267
+
268
+ return $line;
269
+ }
270
+
271
+ protected static function strip_newlines($line) {
272
+ return rtrim($line, "\r\n");
273
+ }
274
+
275
+ protected static function trim_short_desc(&$desc) {
276
+ if (function_exists('mb_strlen') && function_exists('mb_substr')) {
277
+ if (mb_strlen($desc) > 150) {
278
+ $desc = mb_substr($desc, 0, 150);
279
+ $desc = trim($desc);
280
+ return true;
281
+ }
282
+ }
283
+ else {
284
+ if (strlen($desc) > 150) {
285
+ $desc = substr($desc, 0, 150);
286
+ $desc = trim($desc);
287
+ return true;
288
+ }
289
+ }
290
+
291
+ return false;
292
+ }
293
+
294
+ protected static function parse_markdown($text) {
295
+ $text = self::code_trick($text);
296
+ $text = preg_replace('/^[\s]*=[\s]+(.+?)[\s]+=/m', "\n" . '<h4>$1</h4>' . "\n", $text);
297
+ $text = Markdown(trim($text));
298
+ return trim($text);
299
+ }
300
+
301
+ protected static function code_trick($text) {
302
+ // If doing markdown, first take any user formatted code blocks and turn them into backticks so that
303
+ // markdown will preserve things like underscores in code blocks
304
+ $text = preg_replace_callback("!(<pre><code>|<code>)(.*?)(</code></pre>|</code>)!s", array(__CLASS__, 'decodeit'), $text);
305
+
306
+ $text = str_replace(array("\r\n", "\r"), "\n", $text);
307
+ // Markdown can do inline code, we convert bbPress style block level code to Markdown style
308
+ $text = preg_replace_callback("!(^|\n)([ \t]*?)`(.*?)`!s", array(__CLASS__, 'indent'), $text);
309
+ return $text;
310
+ }
311
+
312
+ protected static function indent($matches) {
313
+ $text = $matches[3];
314
+ $text = preg_replace('|^|m', $matches[2] . ' ', $text);
315
+ return $matches[1] . $text;
316
+ }
317
+
318
+ protected static function decodeit($matches) {
319
+ $text = $matches[2];
320
+ $trans_table = array_flip(get_html_translation_table(HTML_ENTITIES));
321
+ $text = strtr($text, $trans_table);
322
+ $text = str_replace('<br />', '', $text);
323
+ $text = str_replace('&#38;', '&', $text);
324
+ $text = str_replace('&#39;', "'", $text);
325
+ if ( '<pre><code>' == $matches[1] )
326
+ $text = "\n$text\n";
327
+ return "`$text`";
328
+ }
329
+ }
includes/libraries/php-markdown/markdown.php ADDED
@@ -0,0 +1,2932 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ #
3
+ # Markdown Extra - A text-to-HTML conversion tool for web writers
4
+ #
5
+ # PHP Markdown & Extra
6
+ # Copyright (c) 2004-2009 Michel Fortin
7
+ # <http://michelf.com/projects/php-markdown/>
8
+ #
9
+ # Original Markdown
10
+ # Copyright (c) 2004-2006 John Gruber
11
+ # <http://daringfireball.net/projects/markdown/>
12
+ #
13
+
14
+
15
+ define( 'MARKDOWN_VERSION', "1.0.1n" ); # Sat 10 Oct 2009
16
+ define( 'MARKDOWNEXTRA_VERSION', "1.2.4" ); # Sat 10 Oct 2009
17
+
18
+
19
+ #
20
+ # Global default settings:
21
+ #
22
+
23
+ # Change to ">" for HTML output
24
+ @define( 'MARKDOWN_EMPTY_ELEMENT_SUFFIX', " />");
25
+
26
+ # Define the width of a tab for code blocks.
27
+ @define( 'MARKDOWN_TAB_WIDTH', 4 );
28
+
29
+ # Optional title attribute for footnote links and backlinks.
30
+ @define( 'MARKDOWN_FN_LINK_TITLE', "" );
31
+ @define( 'MARKDOWN_FN_BACKLINK_TITLE', "" );
32
+
33
+ # Optional class attribute for footnote links and backlinks.
34
+ @define( 'MARKDOWN_FN_LINK_CLASS', "" );
35
+ @define( 'MARKDOWN_FN_BACKLINK_CLASS', "" );
36
+
37
+
38
+ #
39
+ # WordPress settings:
40
+ #
41
+
42
+ # Change to false to remove Markdown from posts and/or comments.
43
+ @define( 'MARKDOWN_WP_POSTS', true );
44
+ @define( 'MARKDOWN_WP_COMMENTS', true );
45
+
46
+
47
+
48
+ ### Standard Function Interface ###
49
+
50
+ @define( 'MARKDOWN_PARSER_CLASS', 'MarkdownExtra_Parser' );
51
+
52
+ function Markdown($text) {
53
+ #
54
+ # Initialize the parser and return the result of its transform method.
55
+ #
56
+ # Setup static parser variable.
57
+ static $parser;
58
+ if (!isset($parser)) {
59
+ $parser_class = MARKDOWN_PARSER_CLASS;
60
+ $parser = new $parser_class;
61
+ }
62
+
63
+ # Transform text using parser.
64
+ return $parser->transform($text);
65
+ }
66
+
67
+
68
+ ### WordPress Plugin Interface ###
69
+
70
+ /*
71
+ Plugin Name: Markdown Extra
72
+ Plugin URI: http://michelf.com/projects/php-markdown/
73
+ Description: <a href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a> allows you to write using an easy-to-read, easy-to-write plain text format. Based on the original Perl version by <a href="http://daringfireball.net/">John Gruber</a>. <a href="http://michelf.com/projects/php-markdown/">More...</a>
74
+ Version: 1.2.4
75
+ Author: Michel Fortin
76
+ Author URI: http://michelf.com/
77
+ */
78
+
79
+ if (isset($wp_version)) {
80
+ # More details about how it works here:
81
+ # <http://michelf.com/weblog/2005/wordpress-text-flow-vs-markdown/>
82
+
83
+ # Post content and excerpts
84
+ # - Remove WordPress paragraph generator.
85
+ # - Run Markdown on excerpt, then remove all tags.
86
+ # - Add paragraph tag around the excerpt, but remove it for the excerpt rss.
87
+ if (MARKDOWN_WP_POSTS) {
88
+ remove_filter('the_content', 'wpautop');
89
+ remove_filter('the_content_rss', 'wpautop');
90
+ remove_filter('the_excerpt', 'wpautop');
91
+ add_filter('the_content', 'mdwp_MarkdownPost', 6);
92
+ add_filter('the_content_rss', 'mdwp_MarkdownPost', 6);
93
+ add_filter('get_the_excerpt', 'mdwp_MarkdownPost', 6);
94
+ add_filter('get_the_excerpt', 'trim', 7);
95
+ add_filter('the_excerpt', 'mdwp_add_p');
96
+ add_filter('the_excerpt_rss', 'mdwp_strip_p');
97
+
98
+ remove_filter('content_save_pre', 'balanceTags', 50);
99
+ remove_filter('excerpt_save_pre', 'balanceTags', 50);
100
+ add_filter('the_content', 'balanceTags', 50);
101
+ add_filter('get_the_excerpt', 'balanceTags', 9);
102
+ }
103
+
104
+ # Add a footnote id prefix to posts when inside a loop.
105
+ function mdwp_MarkdownPost($text) {
106
+ static $parser;
107
+ if (!$parser) {
108
+ $parser_class = MARKDOWN_PARSER_CLASS;
109
+ $parser = new $parser_class;
110
+ }
111
+ if (is_single() || is_page() || is_feed()) {
112
+ $parser->fn_id_prefix = "";
113
+ } else {
114
+ $parser->fn_id_prefix = get_the_ID() . ".";
115
+ }
116
+ return $parser->transform($text);
117
+ }
118
+
119
+ # Comments
120
+ # - Remove WordPress paragraph generator.
121
+ # - Remove WordPress auto-link generator.
122
+ # - Scramble important tags before passing them to the kses filter.
123
+ # - Run Markdown on excerpt then remove paragraph tags.
124
+ if (MARKDOWN_WP_COMMENTS) {
125
+ remove_filter('comment_text', 'wpautop', 30);
126
+ remove_filter('comment_text', 'make_clickable');
127
+ add_filter('pre_comment_content', 'Markdown', 6);
128
+ add_filter('pre_comment_content', 'mdwp_hide_tags', 8);
129
+ add_filter('pre_comment_content', 'mdwp_show_tags', 12);
130
+ add_filter('get_comment_text', 'Markdown', 6);
131
+ add_filter('get_comment_excerpt', 'Markdown', 6);
132
+ add_filter('get_comment_excerpt', 'mdwp_strip_p', 7);
133
+
134
+ global $mdwp_hidden_tags, $mdwp_placeholders;
135
+ $mdwp_hidden_tags = explode(' ',
136
+ '<p> </p> <pre> </pre> <ol> </ol> <ul> </ul> <li> </li>');
137
+ $mdwp_placeholders = explode(' ', str_rot13(
138
+ 'pEj07ZbbBZ U1kqgh4w4p pre2zmeN6K QTi31t9pre ol0MP1jzJR '.
139
+ 'ML5IjmbRol ulANi1NsGY J7zRLJqPul liA8ctl16T K9nhooUHli'));
140
+ }
141
+
142
+ function mdwp_add_p($text) {
143
+ if (!preg_match('{^$|^<(p|ul|ol|dl|pre|blockquote)>}i', $text)) {
144
+ $text = '<p>'.$text.'</p>';
145
+ $text = preg_replace('{\n{2,}}', "</p>\n\n<p>", $text);
146
+ }
147
+ return $text;
148
+ }
149
+
150
+ function mdwp_strip_p($t) { return preg_replace('{</?p>}i', '', $t); }
151
+
152
+ function mdwp_hide_tags($text) {
153
+ global $mdwp_hidden_tags, $mdwp_placeholders;
154
+ return str_replace($mdwp_hidden_tags, $mdwp_placeholders, $text);
155
+ }
156
+ function mdwp_show_tags($text) {
157
+ global $mdwp_hidden_tags, $mdwp_placeholders;
158
+ return str_replace($mdwp_placeholders, $mdwp_hidden_tags, $text);
159
+ }
160
+ }
161
+
162
+
163
+ ### bBlog Plugin Info ###
164
+
165
+ function identify_modifier_markdown() {
166
+ return array(
167
+ 'name' => 'markdown',
168
+ 'type' => 'modifier',
169
+ 'nicename' => 'PHP Markdown Extra',
170
+ 'description' => 'A text-to-HTML conversion tool for web writers',
171
+ 'authors' => 'Michel Fortin and John Gruber',
172
+ 'licence' => 'GPL',
173
+ 'version' => MARKDOWNEXTRA_VERSION,
174
+ 'help' => '<a href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a> allows you to write using an easy-to-read, easy-to-write plain text format. Based on the original Perl version by <a href="http://daringfireball.net/">John Gruber</a>. <a href="http://michelf.com/projects/php-markdown/">More...</a>',
175
+ );
176
+ }
177
+
178
+
179
+ ### Smarty Modifier Interface ###
180
+
181
+ function smarty_modifier_markdown($text) {
182
+ return Markdown($text);
183
+ }
184
+
185
+
186
+ ### Textile Compatibility Mode ###
187
+
188
+ # Rename this file to "classTextile.php" and it can replace Textile everywhere.
189
+
190
+ if (strcasecmp(substr(__FILE__, -16), "classTextile.php") == 0) {
191
+ # Try to include PHP SmartyPants. Should be in the same directory.
192
+ @include_once 'smartypants.php';
193
+ # Fake Textile class. It calls Markdown instead.
194
+ class Textile {
195
+ function TextileThis($text, $lite='', $encode='') {
196
+ if ($lite == '' && $encode == '') $text = Markdown($text);
197
+ if (function_exists('SmartyPants')) $text = SmartyPants($text);
198
+ return $text;
199
+ }
200
+ # Fake restricted version: restrictions are not supported for now.
201
+ function TextileRestricted($text, $lite='', $noimage='') {
202
+ return $this->TextileThis($text, $lite);
203
+ }
204
+ # Workaround to ensure compatibility with TextPattern 4.0.3.
205
+ function blockLite($text) { return $text; }
206
+ }
207
+ }
208
+
209
+
210
+
211
+ #
212
+ # Markdown Parser Class
213
+ #
214
+
215
+ class Markdown_Parser {
216
+
217
+ # Regex to match balanced [brackets].
218
+ # Needed to insert a maximum bracked depth while converting to PHP.
219
+ var $nested_brackets_depth = 6;
220
+ var $nested_brackets_re;
221
+
222
+ var $nested_url_parenthesis_depth = 4;
223
+ var $nested_url_parenthesis_re;
224
+
225
+ # Table of hash values for escaped characters:
226
+ var $escape_chars = '\`*_{}[]()>#+-.!';
227
+ var $escape_chars_re;
228
+
229
+ # Change to ">" for HTML output.
230
+ var $empty_element_suffix = MARKDOWN_EMPTY_ELEMENT_SUFFIX;
231
+ var $tab_width = MARKDOWN_TAB_WIDTH;
232
+
233
+ # Change to `true` to disallow markup or entities.
234
+ var $no_markup = false;
235
+ var $no_entities = false;
236
+
237
+ # Predefined urls and titles for reference links and images.
238
+ var $predef_urls = array();
239
+ var $predef_titles = array();
240
+
241
+
242
+ function Markdown_Parser() {
243
+ #
244
+ # Constructor function. Initialize appropriate member variables.
245
+ #
246
+ $this->_initDetab();
247
+ $this->prepareItalicsAndBold();
248
+
249
+ $this->nested_brackets_re =
250
+ str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth).
251
+ str_repeat('\])*', $this->nested_brackets_depth);
252
+
253
+ $this->nested_url_parenthesis_re =
254
+ str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth).
255
+ str_repeat('(?>\)))*', $this->nested_url_parenthesis_depth);
256
+
257
+ $this->escape_chars_re = '['.preg_quote($this->escape_chars).']';
258
+
259
+ # Sort document, block, and span gamut in ascendent priority order.
260
+ asort($this->document_gamut);
261
+ asort($this->block_gamut);
262
+ asort($this->span_gamut);
263
+ }
264
+
265
+
266
+ # Internal hashes used during transformation.
267
+ var $urls = array();
268
+ var $titles = array();
269
+ var $html_hashes = array();
270
+
271
+ # Status flag to avoid invalid nesting.
272
+ var $in_anchor = false;
273
+
274
+
275
+ function setup() {
276
+ #
277
+ # Called before the transformation process starts to setup parser
278
+ # states.
279
+ #
280
+ # Clear global hashes.
281
+ $this->urls = $this->predef_urls;
282
+ $this->titles = $this->predef_titles;
283
+ $this->html_hashes = array();
284
+
285
+ $in_anchor = false;
286
+ }
287
+
288
+ function teardown() {
289
+ #
290
+ # Called after the transformation process to clear any variable
291
+ # which may be taking up memory unnecessarly.
292
+ #
293
+ $this->urls = array();
294
+ $this->titles = array();
295
+ $this->html_hashes = array();
296
+ }
297
+
298
+
299
+ function transform($text) {
300
+ #
301
+ # Main function. Performs some preprocessing on the input text
302
+ # and pass it through the document gamut.
303
+ #
304
+ $this->setup();
305
+
306
+ # Remove UTF-8 BOM and marker character in input, if present.
307
+ $text = preg_replace('{^\xEF\xBB\xBF|\x1A}', '', $text);
308
+
309
+ # Standardize line endings:
310
+ # DOS to Unix and Mac to Unix
311
+ $text = preg_replace('{\r\n?}', "\n", $text);
312
+
313
+ # Make sure $text ends with a couple of newlines:
314
+ $text .= "\n\n";
315
+
316
+ # Convert all tabs to spaces.
317
+ $text = $this->detab($text);
318
+
319
+ # Turn block-level HTML blocks into hash entries
320
+ $text = $this->hashHTMLBlocks($text);
321
+
322
+ # Strip any lines consisting only of spaces and tabs.
323
+ # This makes subsequent regexen easier to write, because we can
324
+ # match consecutive blank lines with /\n+/ instead of something
325
+ # contorted like /[ ]*\n+/ .
326
+ $text = preg_replace('/^[ ]+$/m', '', $text);
327
+
328
+ # Run document gamut methods.
329
+ foreach ($this->document_gamut as $method => $priority) {
330
+ $text = $this->$method($text);
331
+ }
332
+
333
+ $this->teardown();
334
+
335
+ return $text . "\n";
336
+ }
337
+
338
+ var $document_gamut = array(
339
+ # Strip link definitions, store in hashes.
340
+ "stripLinkDefinitions" => 20,
341
+
342
+ "runBasicBlockGamut" => 30,
343
+ );
344
+
345
+
346
+ function stripLinkDefinitions($text) {
347
+ #
348
+ # Strips link definitions from text, stores the URLs and titles in
349
+ # hash references.
350
+ #
351
+ $less_than_tab = $this->tab_width - 1;
352
+
353
+ # Link defs are in the form: ^[id]: url "optional title"
354
+ $text = preg_replace_callback('{
355
+ ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1
356
+ [ ]*
357
+ \n? # maybe *one* newline
358
+ [ ]*
359
+ (?:
360
+ <(.+?)> # url = $2
361
+ |
362
+ (\S+?) # url = $3
363
+ )
364
+ [ ]*
365
+ \n? # maybe one newline
366
+ [ ]*
367
+ (?:
368
+ (?<=\s) # lookbehind for whitespace
369
+ ["(]
370
+ (.*?) # title = $4
371
+ [")]
372
+ [ ]*
373
+ )? # title is optional
374
+ (?:\n+|\Z)
375
+ }xm',
376
+ array(&$this, '_stripLinkDefinitions_callback'),
377
+ $text);
378
+ return $text;
379
+ }
380
+ function _stripLinkDefinitions_callback($matches) {
381
+ $link_id = strtolower($matches[1]);
382
+ $url = $matches[2] == '' ? $matches[3] : $matches[2];
383
+ $this->urls[$link_id] = $url;
384
+ $this->titles[$link_id] =& $matches[4];
385
+ return ''; # String that will replace the block
386
+ }
387
+
388
+
389
+ function hashHTMLBlocks($text) {
390
+ if ($this->no_markup) return $text;
391
+
392
+ $less_than_tab = $this->tab_width - 1;
393
+
394
+ # Hashify HTML blocks:
395
+ # We only want to do this for block-level HTML tags, such as headers,
396
+ # lists, and tables. That's because we still want to wrap <p>s around
397
+ # "paragraphs" that are wrapped in non-block-level tags, such as anchors,
398
+ # phrase emphasis, and spans. The list of tags we're looking for is
399
+ # hard-coded:
400
+ #
401
+ # * List "a" is made of tags which can be both inline or block-level.
402
+ # These will be treated block-level when the start tag is alone on
403
+ # its line, otherwise they're not matched here and will be taken as
404
+ # inline later.
405
+ # * List "b" is made of tags which are always block-level;
406
+ #
407
+ $block_tags_a_re = 'ins|del';
408
+ $block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|'.
409
+ 'script|noscript|form|fieldset|iframe|math';
410
+
411
+ # Regular expression for the content of a block tag.
412
+ $nested_tags_level = 4;
413
+ $attr = '
414
+ (?> # optional tag attributes
415
+ \s # starts with whitespace
416
+ (?>
417
+ [^>"/]+ # text outside quotes
418
+ |
419
+ /+(?!>) # slash not followed by ">"
420
+ |
421
+ "[^"]*" # text inside double quotes (tolerate ">")
422
+ |
423
+ \'[^\']*\' # text inside single quotes (tolerate ">")
424
+ )*
425
+ )?
426
+ ';
427
+ $content =
428
+ str_repeat('
429
+ (?>
430
+ [^<]+ # content without tag
431
+ |
432
+ <\2 # nested opening tag
433
+ '.$attr.' # attributes
434
+ (?>
435
+ />
436
+ |
437
+ >', $nested_tags_level). # end of opening tag
438
+ '.*?'. # last level nested tag content
439
+ str_repeat('
440
+ </\2\s*> # closing nested tag
441
+ )
442
+ |
443
+ <(?!/\2\s*> # other tags with a different name
444
+ )
445
+ )*',
446
+ $nested_tags_level);
447
+ $content2 = str_replace('\2', '\3', $content);
448
+
449
+ # First, look for nested blocks, e.g.:
450
+ # <div>
451
+ # <div>
452
+ # tags for inner block must be indented.
453
+ # </div>
454
+ # </div>
455
+ #
456
+ # The outermost tags must start at the left margin for this to match, and
457
+ # the inner nested divs must be indented.
458
+ # We need to do this before the next, more liberal match, because the next
459
+ # match will start at the first `<div>` and stop at the first `</div>`.
460
+ $text = preg_replace_callback('{(?>
461
+ (?>
462
+ (?<=\n\n) # Starting after a blank line
463
+ | # or
464
+ \A\n? # the beginning of the doc
465
+ )
466
+ ( # save in $1
467
+
468
+ # Match from `\n<tag>` to `</tag>\n`, handling nested tags
469
+ # in between.
470
+
471
+ [ ]{0,'.$less_than_tab.'}
472
+ <('.$block_tags_b_re.')# start tag = $2
473
+ '.$attr.'> # attributes followed by > and \n
474
+ '.$content.' # content, support nesting
475
+ </\2> # the matching end tag
476
+ [ ]* # trailing spaces/tabs
477
+ (?=\n+|\Z) # followed by a newline or end of document
478
+
479
+ | # Special version for tags of group a.
480
+
481
+ [ ]{0,'.$less_than_tab.'}
482
+ <('.$block_tags_a_re.')# start tag = $3
483
+ '.$attr.'>[ ]*\n # attributes followed by >
484
+ '.$content2.' # content, support nesting
485
+ </\3> # the matching end tag
486
+ [ ]* # trailing spaces/tabs
487
+ (?=\n+|\Z) # followed by a newline or end of document
488
+
489
+ | # Special case just for <hr />. It was easier to make a special
490
+ # case than to make the other regex more complicated.
491
+
492
+ [ ]{0,'.$less_than_tab.'}
493
+ <(hr) # start tag = $2
494
+ '.$attr.' # attributes
495
+ /?> # the matching end tag
496
+ [ ]*
497
+ (?=\n{2,}|\Z) # followed by a blank line or end of document
498
+
499
+ | # Special case for standalone HTML comments:
500
+
501
+ [ ]{0,'.$less_than_tab.'}
502
+ (?s:
503
+ <!-- .*? -->
504
+ )
505
+ [ ]*
506
+ (?=\n{2,}|\Z) # followed by a blank line or end of document
507
+
508
+ | # PHP and ASP-style processor instructions (<? and <%)
509
+
510
+ [ ]{0,'.$less_than_tab.'}
511
+ (?s:
512
+ <([?%]) # $2
513
+ .*?
514
+ \2>
515
+ )
516
+ [ ]*
517
+ (?=\n{2,}|\Z) # followed by a blank line or end of document
518
+
519
+ )
520
+ )}Sxmi',
521
+ array(&$this, '_hashHTMLBlocks_callback'),
522
+ $text);
523
+
524
+ return $text;
525
+ }
526
+ function _hashHTMLBlocks_callback($matches) {
527
+ $text = $matches[1];
528
+ $key = $this->hashBlock($text);
529
+ return "\n\n$key\n\n";
530
+ }
531
+
532
+
533
+ function hashPart($text, $boundary = 'X') {
534
+ #
535
+ # Called whenever a tag must be hashed when a function insert an atomic
536
+ # element in the text stream. Passing $text to through this function gives
537
+ # a unique text-token which will be reverted back when calling unhash.
538
+ #
539
+ # The $boundary argument specify what character should be used to surround
540
+ # the token. By convension, "B" is used for block elements that needs not
541
+ # to be wrapped into paragraph tags at the end, ":" is used for elements
542
+ # that are word separators and "X" is used in the general case.
543
+ #
544
+ # Swap back any tag hash found in $text so we do not have to `unhash`
545
+ # multiple times at the end.
546
+ $text = $this->unhash($text);
547
+
548
+ # Then hash the block.
549
+ static $i = 0;
550
+ $key = "$boundary\x1A" . ++$i . $boundary;
551
+ $this->html_hashes[$key] = $text;
552
+ return $key; # String that will replace the tag.
553
+ }
554
+
555
+
556
+ function hashBlock($text) {
557
+ #
558
+ # Shortcut function for hashPart with block-level boundaries.
559
+ #
560
+ return $this->hashPart($text, 'B');
561
+ }
562
+
563
+
564
+ var $block_gamut = array(
565
+ #
566
+ # These are all the transformations that form block-level
567
+ # tags like paragraphs, headers, and list items.
568
+ #
569
+ "doHeaders" => 10,
570
+ "doHorizontalRules" => 20,
571
+
572
+ "doLists" => 40,
573
+ "doCodeBlocks" => 50,
574
+ "doBlockQuotes" => 60,
575
+ );
576
+
577
+ function runBlockGamut($text) {
578
+ #
579
+ # Run block gamut tranformations.
580
+ #
581
+ # We need to escape raw HTML in Markdown source before doing anything
582
+ # else. This need to be done for each block, and not only at the
583
+ # begining in the Markdown function since hashed blocks can be part of
584
+ # list items and could have been indented. Indented blocks would have
585
+ # been seen as a code block in a previous pass of hashHTMLBlocks.
586
+ $text = $this->hashHTMLBlocks($text);
587
+
588
+ return $this->runBasicBlockGamut($text);
589
+ }
590
+
591
+ function runBasicBlockGamut($text) {
592
+ #
593
+ # Run block gamut tranformations, without hashing HTML blocks. This is
594
+ # useful when HTML blocks are known to be already hashed, like in the first
595
+ # whole-document pass.
596
+ #
597
+ foreach ($this->block_gamut as $method => $priority) {
598
+ $text = $this->$method($text);
599
+ }
600
+
601
+ # Finally form paragraph and restore hashed blocks.
602
+ $text = $this->formParagraphs($text);
603
+
604
+ return $text;
605
+ }
606
+
607
+
608
+ function doHorizontalRules($text) {
609
+ # Do Horizontal Rules:
610
+ return preg_replace(
611
+ '{
612
+ ^[ ]{0,3} # Leading space
613
+ ([-*_]) # $1: First marker
614
+ (?> # Repeated marker group
615
+ [ ]{0,2} # Zero, one, or two spaces.
616
+ \1 # Marker character
617
+ ){2,} # Group repeated at least twice
618
+ [ ]* # Tailing spaces
619
+ $ # End of line.
620
+ }mx',
621
+ "\n".$this->hashBlock("<hr$this->empty_element_suffix")."\n",
622
+ $text);
623
+ }
624
+
625
+
626
+ var $span_gamut = array(
627
+ #
628
+ # These are all the transformations that occur *within* block-level
629
+ # tags like paragraphs, headers, and list items.
630
+ #
631
+ # Process character escapes, code spans, and inline HTML
632
+ # in one shot.
633
+ "parseSpan" => -30,
634
+
635
+ # Process anchor and image tags. Images must come first,
636
+ # because ![foo][f] looks like an anchor.
637
+ "doImages" => 10,
638
+ "doAnchors" => 20,
639
+
640
+ # Make links out of things like `<http://example.com/>`
641
+ # Must come after doAnchors, because you can use < and >
642
+ # delimiters in inline links like [this](<url>).
643
+ "doAutoLinks" => 30,
644
+ "encodeAmpsAndAngles" => 40,
645
+
646
+ "doItalicsAndBold" => 50,
647
+ "doHardBreaks" => 60,
648
+ );
649
+
650
+ function runSpanGamut($text) {
651
+ #
652
+ # Run span gamut tranformations.
653
+ #
654
+ foreach ($this->span_gamut as $method => $priority) {
655
+ $text = $this->$method($text);
656
+ }
657
+
658
+ return $text;
659
+ }
660
+
661
+
662
+ function doHardBreaks($text) {
663
+ # Do hard breaks:
664
+ return preg_replace_callback('/ {2,}\n/',
665
+ array(&$this, '_doHardBreaks_callback'), $text);
666
+ }
667
+ function _doHardBreaks_callback($matches) {
668
+ return $this->hashPart("<br$this->empty_element_suffix\n");
669
+ }
670
+
671
+
672
+ function doAnchors($text) {
673
+ #
674
+ # Turn Markdown link shortcuts into XHTML <a> tags.
675
+ #
676
+ if ($this->in_anchor) return $text;
677
+ $this->in_anchor = true;
678
+
679
+ #
680
+ # First, handle reference-style links: [link text] [id]
681
+ #
682
+ $text = preg_replace_callback('{
683
+ ( # wrap whole match in $1
684
+ \[
685
+ ('.$this->nested_brackets_re.') # link text = $2
686
+ \]
687
+
688
+ [ ]? # one optional space
689
+ (?:\n[ ]*)? # one optional newline followed by spaces
690
+
691
+ \[
692
+ (.*?) # id = $3
693
+ \]
694
+ )
695
+ }xs',
696
+ array(&$this, '_doAnchors_reference_callback'), $text);
697
+
698
+ #
699
+ # Next, inline-style links: [link text](url "optional title")
700
+ #
701
+ $text = preg_replace_callback('{
702
+ ( # wrap whole match in $1
703
+ \[
704
+ ('.$this->nested_brackets_re.') # link text = $2
705
+ \]
706
+ \( # literal paren
707
+ [ \n]*
708
+ (?:
709
+ <(.+?)> # href = $3
710
+ |
711
+ ('.$this->nested_url_parenthesis_re.') # href = $4
712
+ )
713
+ [ \n]*
714
+ ( # $5
715
+ ([\'"]) # quote char = $6
716
+ (.*?) # Title = $7
717
+ \6 # matching quote
718
+ [ \n]* # ignore any spaces/tabs between closing quote and )
719
+ )? # title is optional
720
+ \)
721
+ )
722
+ }xs',
723
+ array(&$this, '_doAnchors_inline_callback'), $text);
724
+
725
+ #
726
+ # Last, handle reference-style shortcuts: [link text]
727
+ # These must come last in case you've also got [link text][1]
728
+ # or [link text](/foo)
729
+ #
730
+ $text = preg_replace_callback('{
731
+ ( # wrap whole match in $1
732
+ \[
733
+ ([^\[\]]+) # link text = $2; can\'t contain [ or ]
734
+ \]
735
+ )
736
+ }xs',
737
+ array(&$this, '_doAnchors_reference_callback'), $text);
738
+
739
+ $this->in_anchor = false;
740
+ return $text;
741
+ }
742
+ function _doAnchors_reference_callback($matches) {
743
+ $whole_match = $matches[1];
744
+ $link_text = $matches[2];
745
+ $link_id =& $matches[3];
746
+
747
+ if ($link_id == "") {
748
+ # for shortcut links like [this][] or [this].
749
+ $link_id = $link_text;
750
+ }
751
+
752
+ # lower-case and turn embedded newlines into spaces
753
+ $link_id = strtolower($link_id);
754
+ $link_id = preg_replace('{[ ]?\n}', ' ', $link_id);
755
+
756
+ if (isset($this->urls[$link_id])) {
757
+ $url = $this->urls[$link_id];
758
+ $url = $this->encodeAttribute($url);
759
+
760
+ $result = "<a href=\"$url\"";
761
+ if ( isset( $this->titles[$link_id] ) ) {
762
+ $title = $this->titles[$link_id];
763
+ $title = $this->encodeAttribute($title);
764
+ $result .= " title=\"$title\"";
765
+ }
766
+
767
+ $link_text = $this->runSpanGamut($link_text);
768
+ $result .= ">$link_text</a>";
769
+ $result = $this->hashPart($result);
770
+ }
771
+ else {
772
+ $result = $whole_match;
773
+ }
774
+ return $result;
775
+ }
776
+ function _doAnchors_inline_callback($matches) {
777
+ $whole_match = $matches[1];
778
+ $link_text = $this->runSpanGamut($matches[2]);
779
+ $url = $matches[3] == '' ? $matches[4] : $matches[3];
780
+ $title =& $matches[7];
781
+
782
+ $url = $this->encodeAttribute($url);
783
+
784
+ $result = "<a href=\"$url\"";
785
+ if (isset($title)) {
786
+ $title = $this->encodeAttribute($title);
787
+ $result .= " title=\"$title\"";
788
+ }
789
+
790
+ $link_text = $this->runSpanGamut($link_text);
791
+ $result .= ">$link_text</a>";
792
+
793
+ return $this->hashPart($result);
794
+ }
795
+
796
+
797
+ function doImages($text) {
798
+ #
799
+ # Turn Markdown image shortcuts into <img> tags.
800
+ #
801
+ #
802
+ # First, handle reference-style labeled images: ![alt text][id]
803
+ #
804
+ $text = preg_replace_callback('{
805
+ ( # wrap whole match in $1
806
+ !\[
807
+ ('.$this->nested_brackets_re.') # alt text = $2
808
+ \]
809
+
810
+ [ ]? # one optional space
811
+ (?:\n[ ]*)? # one optional newline followed by spaces
812
+
813
+ \[
814
+ (.*?) # id = $3
815
+ \]
816
+
817
+ )
818
+ }xs',
819
+ array(&$this, '_doImages_reference_callback'), $text);
820
+
821
+ #
822
+ # Next, handle inline images: ![alt text](url "optional title")
823
+ # Don't forget: encode * and _
824
+ #
825
+ $text = preg_replace_callback('{
826
+ ( # wrap whole match in $1
827
+ !\[
828
+ ('.$this->nested_brackets_re.') # alt text = $2
829
+ \]
830
+ \s? # One optional whitespace character
831
+ \( # literal paren
832
+ [ \n]*
833
+ (?:
834
+ <(\S*)> # src url = $3
835
+ |
836
+ ('.$this->nested_url_parenthesis_re.') # src url = $4
837
+ )
838
+ [ \n]*
839
+ ( # $5
840
+ ([\'"]) # quote char = $6
841
+ (.*?) # title = $7
842
+ \6 # matching quote
843
+ [ \n]*
844
+ )? # title is optional
845
+ \)
846
+ )
847
+ }xs',
848
+ array(&$this, '_doImages_inline_callback'), $text);
849
+
850
+ return $text;
851
+ }
852
+ function _doImages_reference_callback($matches) {
853
+ $whole_match = $matches[1];
854
+ $alt_text = $matches[2];
855
+ $link_id = strtolower($matches[3]);
856
+
857
+ if ($link_id == "") {
858
+ $link_id = strtolower($alt_text); # for shortcut links like ![this][].
859
+ }
860
+
861
+ $alt_text = $this->encodeAttribute($alt_text);
862
+ if (isset($this->urls[$link_id])) {
863
+ $url = $this->encodeAttribute($this->urls[$link_id]);
864
+ $result = "<img src=\"$url\" alt=\"$alt_text\"";
865
+ if (isset($this->titles[$link_id])) {
866
+ $title = $this->titles[$link_id];
867
+ $title = $this->encodeAttribute($title);
868
+ $result .= " title=\"$title\"";
869
+ }
870
+ $result .= $this->empty_element_suffix;
871
+ $result = $this->hashPart($result);
872
+ }
873
+ else {
874
+ # If there's no such link ID, leave intact:
875
+ $result = $whole_match;
876
+ }
877
+
878
+ return $result;
879
+ }
880
+ function _doImages_inline_callback($matches) {
881
+ $whole_match = $matches[1];
882
+ $alt_text = $matches[2];
883
+ $url = $matches[3] == '' ? $matches[4] : $matches[3];
884
+ $title =& $matches[7];
885
+
886
+ $alt_text = $this->encodeAttribute($alt_text);
887
+ $url = $this->encodeAttribute($url);
888
+ $result = "<img src=\"$url\" alt=\"$alt_text\"";
889
+ if (isset($title)) {
890
+ $title = $this->encodeAttribute($title);
891
+ $result .= " title=\"$title\""; # $title already quoted
892
+ }
893
+ $result .= $this->empty_element_suffix;
894
+
895
+ return $this->hashPart($result);
896
+ }
897
+
898
+
899
+ function doHeaders($text) {
900
+ # Setext-style headers:
901
+ # Header 1
902
+ # ========
903
+ #
904
+ # Header 2
905
+ # --------
906
+ #
907
+ $text = preg_replace_callback('{ ^(.+?)[ ]*\n(=+|-+)[ ]*\n+ }mx',
908
+ array(&$this, '_doHeaders_callback_setext'), $text);
909
+
910
+ # atx-style headers:
911
+ # # Header 1
912
+ # ## Header 2
913
+ # ## Header 2 with closing hashes ##
914
+ # ...
915
+ # ###### Header 6
916
+ #
917
+ $text = preg_replace_callback('{
918
+ ^(\#{1,6}) # $1 = string of #\'s
919
+ [ ]*
920
+ (.+?) # $2 = Header text
921
+ [ ]*
922
+ \#* # optional closing #\'s (not counted)
923
+ \n+
924
+ }xm',
925
+ array(&$this, '_doHeaders_callback_atx'), $text);
926
+
927
+ return $text;
928
+ }
929
+ function _doHeaders_callback_setext($matches) {
930
+ # Terrible hack to check we haven't found an empty list item.
931
+ if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1]))
932
+ return $matches[0];
933
+
934
+ $level = $matches[2]{0} == '=' ? 1 : 2;
935
+ $block = "<h$level>".$this->runSpanGamut($matches[1])."</h$level>";
936
+ return "\n" . $this->hashBlock($block) . "\n\n";
937
+ }
938
+ function _doHeaders_callback_atx($matches) {
939
+ $level = strlen($matches[1]);
940
+ $block = "<h$level>".$this->runSpanGamut($matches[2])."</h$level>";
941
+ return "\n" . $this->hashBlock($block) . "\n\n";
942
+ }
943
+
944
+
945
+ function doLists($text) {
946
+ #
947
+ # Form HTML ordered (numbered) and unordered (bulleted) lists.
948
+ #
949
+ $less_than_tab = $this->tab_width - 1;
950
+
951
+ # Re-usable patterns to match list item bullets and number markers:
952
+ $marker_ul_re = '[*+-]';
953
+ $marker_ol_re = '\d+[.]';
954
+ $marker_any_re = "(?:$marker_ul_re|$marker_ol_re)";
955
+
956
+ $markers_relist = array(
957
+ $marker_ul_re => $marker_ol_re,
958
+ $marker_ol_re => $marker_ul_re,
959
+ );
960
+
961
+ foreach ($markers_relist as $marker_re => $other_marker_re) {
962
+ # Re-usable pattern to match any entirel ul or ol list:
963
+ $whole_list_re = '
964
+ ( # $1 = whole list
965
+ ( # $2
966
+ ([ ]{0,'.$less_than_tab.'}) # $3 = number of spaces
967
+ ('.$marker_re.') # $4 = first list item marker
968
+ [ ]+
969
+ )
970
+ (?s:.+?)
971
+ ( # $5
972
+ \z
973
+ |
974
+ \n{2,}
975
+ (?=\S)
976
+ (?! # Negative lookahead for another list item marker
977
+ [ ]*
978
+ '.$marker_re.'[ ]+
979
+ )
980
+ |
981
+ (?= # Lookahead for another kind of list
982
+ \n
983
+ \3 # Must have the same indentation
984
+ '.$other_marker_re.'[ ]+
985
+ )
986
+ )
987
+ )
988
+ '; // mx
989
+
990
+ # We use a different prefix before nested lists than top-level lists.
991
+ # See extended comment in _ProcessListItems().
992
+
993
+ if ($this->list_level) {
994
+ $text = preg_replace_callback('{
995
+ ^
996
+ '.$whole_list_re.'
997
+ }mx',
998
+ array(&$this, '_doLists_callback'), $text);
999
+ }
1000
+ else {
1001
+ $text = preg_replace_callback('{
1002
+ (?:(?<=\n)\n|\A\n?) # Must eat the newline
1003
+ '.$whole_list_re.'
1004
+ }mx',
1005
+ array(&$this, '_doLists_callback'), $text);
1006
+ }
1007
+ }
1008
+
1009
+ return $text;
1010
+ }
1011
+ function _doLists_callback($matches) {
1012
+ # Re-usable patterns to match list item bullets and number markers:
1013
+ $marker_ul_re = '[*+-]';
1014
+ $marker_ol_re = '\d+[.]';
1015
+ $marker_any_re = "(?:$marker_ul_re|$marker_ol_re)";
1016
+
1017
+ $list = $matches[1];
1018
+ $list_type = preg_match("/$marker_ul_re/", $matches[4]) ? "ul" : "ol";
1019
+
1020
+ $marker_any_re = ( $list_type == "ul" ? $marker_ul_re : $marker_ol_re );
1021
+
1022
+ $list .= "\n";
1023
+ $result = $this->processListItems($list, $marker_any_re);
1024
+
1025
+ $result = $this->hashBlock("<$list_type>\n" . $result . "</$list_type>");
1026
+ return "\n". $result ."\n\n";
1027
+ }
1028
+
1029
+ var $list_level = 0;
1030
+
1031
+ function processListItems($list_str, $marker_any_re) {
1032
+ #
1033
+ # Process the contents of a single ordered or unordered list, splitting it
1034
+ # into individual list items.
1035
+ #
1036
+ # The $this->list_level global keeps track of when we're inside a list.
1037
+ # Each time we enter a list, we increment it; when we leave a list,
1038
+ # we decrement. If it's zero, we're not in a list anymore.
1039
+ #
1040
+ # We do this because when we're not inside a list, we want to treat
1041
+ # something like this:
1042
+ #
1043
+ # I recommend upgrading to version
1044
+ # 8. Oops, now this line is treated
1045
+ # as a sub-list.
1046
+ #
1047
+ # As a single paragraph, despite the fact that the second line starts
1048
+ # with a digit-period-space sequence.
1049
+ #
1050
+ # Whereas when we're inside a list (or sub-list), that line will be
1051
+ # treated as the start of a sub-list. What a kludge, huh? This is
1052
+ # an aspect of Markdown's syntax that's hard to parse perfectly
1053
+ # without resorting to mind-reading. Perhaps the solution is to
1054
+ # change the syntax rules such that sub-lists must start with a
1055
+ # starting cardinal number; e.g. "1." or "a.".
1056
+
1057
+ $this->list_level++;
1058
+
1059
+ # trim trailing blank lines:
1060
+ $list_str = preg_replace("/\n{2,}\\z/", "\n", $list_str);
1061
+
1062
+ $list_str = preg_replace_callback('{
1063
+ (\n)? # leading line = $1
1064
+ (^[ ]*) # leading whitespace = $2
1065
+ ('.$marker_any_re.' # list marker and space = $3
1066
+ (?:[ ]+|(?=\n)) # space only required if item is not empty
1067
+ )
1068
+ ((?s:.*?)) # list item text = $4
1069
+ (?:(\n+(?=\n))|\n) # tailing blank line = $5
1070
+ (?= \n* (\z | \2 ('.$marker_any_re.') (?:[ ]+|(?=\n))))
1071
+ }xm',
1072
+ array(&$this, '_processListItems_callback'), $list_str);
1073
+
1074
+ $this->list_level--;
1075
+ return $list_str;
1076
+ }
1077
+ function _processListItems_callback($matches) {
1078
+ $item = $matches[4];
1079
+ $leading_line =& $matches[1];
1080
+ $leading_space =& $matches[2];
1081
+ $marker_space = $matches[3];
1082
+ $tailing_blank_line =& $matches[5];
1083
+
1084
+ if ($leading_line || $tailing_blank_line ||
1085
+ preg_match('/\n{2,}/', $item))
1086
+ {
1087
+ # Replace marker with the appropriate whitespace indentation
1088
+ $item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item;
1089
+ $item = $this->runBlockGamut($this->outdent($item)."\n");
1090
+ }
1091
+ else {
1092
+ # Recursion for sub-lists:
1093
+ $item = $this->doLists($this->outdent($item));
1094
+ $item = preg_replace('/\n+$/', '', $item);
1095
+ $item = $this->runSpanGamut($item);
1096
+ }
1097
+
1098
+ return "<li>" . $item . "</li>\n";
1099
+ }
1100
+
1101
+
1102
+ function doCodeBlocks($text) {
1103
+ #
1104
+ # Process Markdown `<pre><code>` blocks.
1105
+ #
1106
+ $text = preg_replace_callback('{
1107
+ (?:\n\n|\A\n?)
1108
+ ( # $1 = the code block -- one or more lines, starting with a space/tab
1109
+ (?>
1110
+ [ ]{'.$this->tab_width.'} # Lines must start with a tab or a tab-width of spaces
1111
+ .*\n+
1112
+ )+
1113
+ )
1114
+ ((?=^[ ]{0,'.$this->tab_width.'}\S)|\Z) # Lookahead for non-space at line-start, or end of doc
1115
+ }xm',
1116
+ array(&$this, '_doCodeBlocks_callback'), $text);
1117
+
1118
+ return $text;
1119
+ }
1120
+ function _doCodeBlocks_callback($matches) {
1121
+ $codeblock = $matches[1];
1122
+
1123
+ $codeblock = $this->outdent($codeblock);
1124
+ $codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
1125
+
1126
+ # trim leading newlines and trailing newlines
1127
+ $codeblock = preg_replace('/\A\n+|\n+\z/', '', $codeblock);
1128
+
1129
+ $codeblock = "<pre><code>$codeblock\n</code></pre>";
1130
+ return "\n\n".$this->hashBlock($codeblock)."\n\n";
1131
+ }
1132
+
1133
+
1134
+ function makeCodeSpan($code) {
1135
+ #
1136
+ # Create a code span markup for $code. Called from handleSpanToken.
1137
+ #
1138
+ $code = htmlspecialchars(trim($code), ENT_NOQUOTES);
1139
+ return $this->hashPart("<code>$code</code>");
1140
+ }
1141
+
1142
+
1143
+ var $em_relist = array(
1144
+ '' => '(?:(?<!\*)\*(?!\*)|(?<!_)_(?!_))(?=\S|$)(?![.,:;]\s)',
1145
+ '*' => '(?<=\S|^)(?<!\*)\*(?!\*)',
1146
+ '_' => '(?<=\S|^)(?<!_)_(?!_)',
1147
+ );
1148
+ var $strong_relist = array(
1149
+ '' => '(?:(?<!\*)\*\*(?!\*)|(?<!_)__(?!_))(?=\S|$)(?![.,:;]\s)',
1150
+ '**' => '(?<=\S|^)(?<!\*)\*\*(?!\*)',
1151
+ '__' => '(?<=\S|^)(?<!_)__(?!_)',
1152
+ );
1153
+ var $em_strong_relist = array(
1154
+ '' => '(?:(?<!\*)\*\*\*(?!\*)|(?<!_)___(?!_))(?=\S|$)(?![.,:;]\s)',
1155
+ '***' => '(?<=\S|^)(?<!\*)\*\*\*(?!\*)',
1156
+ '___' => '(?<=\S|^)(?<!_)___(?!_)',
1157
+ );
1158
+ var $em_strong_prepared_relist;
1159
+
1160
+ function prepareItalicsAndBold() {
1161
+ #
1162
+ # Prepare regular expressions for searching emphasis tokens in any
1163
+ # context.
1164
+ #
1165
+ foreach ($this->em_relist as $em => $em_re) {
1166
+ foreach ($this->strong_relist as $strong => $strong_re) {
1167
+ # Construct list of allowed token expressions.
1168
+ $token_relist = array();
1169
+ if (isset($this->em_strong_relist["$em$strong"])) {
1170
+ $token_relist[] = $this->em_strong_relist["$em$strong"];
1171
+ }
1172
+ $token_relist[] = $em_re;
1173
+ $token_relist[] = $strong_re;
1174
+
1175
+ # Construct master expression from list.
1176
+ $token_re = '{('. implode('|', $token_relist) .')}';
1177
+ $this->em_strong_prepared_relist["$em$strong"] = $token_re;
1178
+ }
1179
+ }
1180
+ }
1181
+
1182
+ function doItalicsAndBold($text) {
1183
+ $token_stack = array('');
1184
+ $text_stack = array('');
1185
+ $em = '';
1186
+ $strong = '';
1187
+ $tree_char_em = false;
1188
+
1189
+ while (1) {
1190
+ #
1191
+ # Get prepared regular expression for seraching emphasis tokens
1192
+ # in current context.
1193
+ #
1194
+ $token_re = $this->em_strong_prepared_relist["$em$strong"];
1195
+
1196
+ #
1197
+ # Each loop iteration search for the next emphasis token.
1198
+ # Each token is then passed to handleSpanToken.
1199
+ #
1200
+ $parts = preg_split($token_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE);
1201
+ $text_stack[0] .= $parts[0];
1202
+ $token =& $parts[1];
1203
+ $text =& $parts[2];
1204
+
1205
+ if (empty($token)) {
1206
+ # Reached end of text span: empty stack without emitting.
1207
+ # any more emphasis.
1208
+ while ($token_stack[0]) {
1209
+ $text_stack[1] .= array_shift($token_stack);
1210
+ $text_stack[0] .= array_shift($text_stack);
1211
+ }
1212
+ break;
1213
+ }
1214
+
1215
+ $token_len = strlen($token);
1216
+ if ($tree_char_em) {
1217
+ # Reached closing marker while inside a three-char emphasis.
1218
+ if ($token_len == 3) {
1219
+ # Three-char closing marker, close em and strong.
1220
+ array_shift($token_stack);
1221
+ $span = array_shift($text_stack);
1222
+ $span = $this->runSpanGamut($span);
1223
+ $span = "<strong><em>$span</em></strong>";
1224
+ $text_stack[0] .= $this->hashPart($span);
1225
+ $em = '';
1226
+ $strong = '';
1227
+ } else {
1228
+ # Other closing marker: close one em or strong and
1229
+ # change current token state to match the other
1230
+ $token_stack[0] = str_repeat($token{0}, 3-$token_len);
1231
+ $tag = $token_len == 2 ? "strong" : "em";
1232
+ $span = $text_stack[0];
1233
+ $span = $this->runSpanGamut($span);
1234
+ $span = "<$tag>$span</$tag>";
1235
+ $text_stack[0] = $this->hashPart($span);
1236
+ $$tag = ''; # $$tag stands for $em or $strong
1237
+ }
1238
+ $tree_char_em = false;
1239
+ } else if ($token_len == 3) {
1240
+ if ($em) {
1241
+ # Reached closing marker for both em and strong.
1242
+ # Closing strong marker:
1243
+ for ($i = 0; $i < 2; ++$i) {
1244
+ $shifted_token = array_shift($token_stack);
1245
+ $tag = strlen($shifted_token) == 2 ? "strong" : "em";
1246
+ $span = array_shift($text_stack);
1247
+ $span = $this->runSpanGamut($span);
1248
+ $span = "<$tag>$span</$tag>";
1249
+ $text_stack[0] .= $this->hashPart($span);
1250
+ $$tag = ''; # $$tag stands for $em or $strong
1251
+ }
1252
+ } else {
1253
+ # Reached opening three-char emphasis marker. Push on token
1254
+ # stack; will be handled by the special condition above.
1255
+ $em = $token{0};
1256
+ $strong = "$em$em";
1257
+ array_unshift($token_stack, $token);
1258
+ array_unshift($text_stack, '');
1259
+ $tree_char_em = true;
1260
+ }
1261
+ } else if ($token_len == 2) {
1262
+ if ($strong) {
1263
+ # Unwind any dangling emphasis marker:
1264
+ if (strlen($token_stack[0]) == 1) {
1265
+ $text_stack[1] .= array_shift($token_stack);
1266
+ $text_stack[0] .= array_shift($text_stack);
1267
+ }
1268
+ # Closing strong marker:
1269
+ array_shift($token_stack);
1270
+ $span = array_shift($text_stack);
1271
+ $span = $this->runSpanGamut($span);
1272
+ $span = "<strong>$span</strong>";
1273
+ $text_stack[0] .= $this->hashPart($span);
1274
+ $strong = '';
1275
+ } else {
1276
+ array_unshift($token_stack, $token);
1277
+ array_unshift($text_stack, '');
1278
+ $strong = $token;
1279
+ }
1280
+ } else {
1281
+ # Here $token_len == 1
1282
+ if ($em) {
1283
+ if (strlen($token_stack[0]) == 1) {
1284
+ # Closing emphasis marker:
1285
+ array_shift($token_stack);
1286
+ $span = array_shift($text_stack);
1287
+ $span = $this->runSpanGamut($span);
1288
+ $span = "<em>$span</em>";
1289
+ $text_stack[0] .= $this->hashPart($span);
1290
+ $em = '';
1291
+ } else {
1292
+ $text_stack[0] .= $token;
1293
+ }
1294
+ } else {
1295
+ array_unshift($token_stack, $token);
1296
+ array_unshift($text_stack, '');
1297
+ $em = $token;
1298
+ }
1299
+ }
1300
+ }
1301
+ return $text_stack[0];
1302
+ }
1303
+
1304
+
1305
+ function doBlockQuotes($text) {
1306
+ $text = preg_replace_callback('/
1307
+ ( # Wrap whole match in $1
1308
+ (?>
1309
+ ^[ ]*>[ ]? # ">" at the start of a line
1310
+ .+\n # rest of the first line
1311
+ (.+\n)* # subsequent consecutive lines
1312
+ \n* # blanks
1313
+ )+
1314
+ )
1315
+ /xm',
1316
+ array(&$this, '_doBlockQuotes_callback'), $text);
1317
+
1318
+ return $text;
1319
+ }
1320
+ function _doBlockQuotes_callback($matches) {
1321
+ $bq = $matches[1];
1322
+ # trim one level of quoting - trim whitespace-only lines
1323
+ $bq = preg_replace('/^[ ]*>[ ]?|^[ ]+$/m', '', $bq);
1324
+ $bq = $this->runBlockGamut($bq); # recurse
1325
+
1326
+ $bq = preg_replace('/^/m', " ", $bq);
1327
+ # These leading spaces cause problem with <pre> content,
1328
+ # so we need to fix that:
1329
+ $bq = preg_replace_callback('{(\s*<pre>.+?</pre>)}sx',
1330
+ array(&$this, '_doBlockQuotes_callback2'), $bq);
1331
+
1332
+ return "\n". $this->hashBlock("<blockquote>\n$bq\n</blockquote>")."\n\n";
1333
+ }
1334
+ function _doBlockQuotes_callback2($matches) {
1335
+ $pre = $matches[1];
1336
+ $pre = preg_replace('/^ /m', '', $pre);
1337
+ return $pre;
1338
+ }
1339
+
1340
+
1341
+ function formParagraphs($text) {
1342
+ #
1343
+ # Params:
1344
+ # $text - string to process with html <p> tags
1345
+ #
1346
+ # Strip leading and trailing lines:
1347
+ $text = preg_replace('/\A\n+|\n+\z/', '', $text);
1348
+
1349
+ $grafs = preg_split('/\n{2,}/', $text, -1, PREG_SPLIT_NO_EMPTY);
1350
+
1351
+ #
1352
+ # Wrap <p> tags and unhashify HTML blocks
1353
+ #
1354
+ foreach ($grafs as $key => $value) {
1355
+ if (!preg_match('/^B\x1A[0-9]+B$/', $value)) {
1356
+ # Is a paragraph.
1357
+ $value = $this->runSpanGamut($value);
1358
+ $value = preg_replace('/^([ ]*)/', "<p>", $value);
1359
+ $value .= "</p>";
1360
+ $grafs[$key] = $this->unhash($value);
1361
+ }
1362
+ else {
1363
+ # Is a block.
1364
+ # Modify elements of @grafs in-place...
1365
+ $graf = $value;
1366
+ $block = $this->html_hashes[$graf];
1367
+ $graf = $block;
1368
+ // if (preg_match('{
1369
+ // \A
1370
+ // ( # $1 = <div> tag
1371
+ // <div \s+
1372
+ // [^>]*
1373
+ // \b
1374
+ // markdown\s*=\s* ([\'"]) # $2 = attr quote char
1375
+ // 1
1376
+ // \2
1377
+ // [^>]*
1378
+ // >
1379
+ // )
1380
+ // ( # $3 = contents
1381
+ // .*
1382
+ // )
1383
+ // (</div>) # $4 = closing tag
1384
+ // \z
1385
+ // }xs', $block, $matches))
1386
+ // {
1387
+ // list(, $div_open, , $div_content, $div_close) = $matches;
1388
+ //
1389
+ // # We can't call Markdown(), because that resets the hash;
1390
+ // # that initialization code should be pulled into its own sub, though.
1391
+ // $div_content = $this->hashHTMLBlocks($div_content);
1392
+ //
1393
+ // # Run document gamut methods on the content.
1394
+ // foreach ($this->document_gamut as $method => $priority) {
1395
+ // $div_content = $this->$method($div_content);
1396
+ // }
1397
+ //
1398
+ // $div_open = preg_replace(
1399
+ // '{\smarkdown\s*=\s*([\'"]).+?\1}', '', $div_open);
1400
+ //
1401
+ // $graf = $div_open . "\n" . $div_content . "\n" . $div_close;
1402
+ // }
1403
+ $grafs[$key] = $graf;
1404
+ }
1405
+ }
1406
+
1407
+ return implode("\n\n", $grafs);
1408
+ }
1409
+
1410
+
1411
+ function encodeAttribute($text) {
1412
+ #
1413
+ # Encode text for a double-quoted HTML attribute. This function
1414
+ # is *not* suitable for attributes enclosed in single quotes.
1415
+ #
1416
+ $text = $this->encodeAmpsAndAngles($text);
1417
+ $text = str_replace('"', '&quot;', $text);
1418
+ return $text;
1419
+ }
1420
+
1421
+
1422
+ function encodeAmpsAndAngles($text) {
1423
+ #
1424
+ # Smart processing for ampersands and angle brackets that need to
1425
+ # be encoded. Valid character entities are left alone unless the
1426
+ # no-entities mode is set.
1427
+ #
1428
+ if ($this->no_entities) {
1429
+ $text = str_replace('&', '&amp;', $text);
1430
+ } else {
1431
+ # Ampersand-encoding based entirely on Nat Irons's Amputator
1432
+ # MT plugin: <http://bumppo.net/projects/amputator/>
1433
+ $text = preg_replace('/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/',
1434
+ '&amp;', $text);;
1435
+ }
1436
+ # Encode remaining <'s
1437
+ $text = str_replace('<', '&lt;', $text);
1438
+
1439
+ return $text;
1440
+ }
1441
+
1442
+
1443
+ function doAutoLinks($text) {
1444
+ $text = preg_replace_callback('{<((https?|ftp|dict):[^\'">\s]+)>}i',
1445
+ array(&$this, '_doAutoLinks_url_callback'), $text);
1446
+
1447
+ # Email addresses: <address@domain.foo>
1448
+ $text = preg_replace_callback('{
1449
+ <
1450
+ (?:mailto:)?
1451
+ (
1452
+ (?:
1453
+ [-!#$%&\'*+/=?^_`.{|}~\w\x80-\xFF]+
1454
+ |
1455
+ ".*?"
1456
+ )
1457
+ \@
1458
+ (?:
1459
+ [-a-z0-9\x80-\xFF]+(\.[-a-z0-9\x80-\xFF]+)*\.[a-z]+
1460
+ |
1461
+ \[[\d.a-fA-F:]+\] # IPv4 & IPv6
1462
+ )
1463
+ )
1464
+ >
1465
+ }xi',
1466
+ array(&$this, '_doAutoLinks_email_callback'), $text);
1467
+
1468
+ return $text;
1469
+ }
1470
+ function _doAutoLinks_url_callback($matches) {
1471
+ $url = $this->encodeAttribute($matches[1]);
1472
+ $link = "<a href=\"$url\">$url</a>";
1473
+ return $this->hashPart($link);
1474
+ }
1475
+ function _doAutoLinks_email_callback($matches) {
1476
+ $address = $matches[1];
1477
+ $link = $this->encodeEmailAddress($address);
1478
+ return $this->hashPart($link);
1479
+ }
1480
+
1481
+
1482
+ function encodeEmailAddress($addr) {
1483
+ #
1484
+ # Input: an email address, e.g. "foo@example.com"
1485
+ #
1486
+ # Output: the email address as a mailto link, with each character
1487
+ # of the address encoded as either a decimal or hex entity, in
1488
+ # the hopes of foiling most address harvesting spam bots. E.g.:
1489
+ #
1490
+ # <p><a href="&#109;&#x61;&#105;&#x6c;&#116;&#x6f;&#58;&#x66;o&#111;
1491
+ # &#x40;&#101;&#x78;&#97;&#x6d;&#112;&#x6c;&#101;&#46;&#x63;&#111;
1492
+ # &#x6d;">&#x66;o&#111;&#x40;&#101;&#x78;&#97;&#x6d;&#112;&#x6c;
1493
+ # &#101;&#46;&#x63;&#111;&#x6d;</a></p>
1494
+ #
1495
+ # Based by a filter by Matthew Wickline, posted to BBEdit-Talk.
1496
+ # With some optimizations by Milian Wolff.
1497
+ #
1498
+ $addr = "mailto:" . $addr;
1499
+ $chars = preg_split('/(?<!^)(?!$)/', $addr);
1500
+ $seed = (int)abs(crc32($addr) / strlen($addr)); # Deterministic seed.
1501
+
1502
+ foreach ($chars as $key => $char) {
1503
+ $ord = ord($char);
1504
+ # Ignore non-ascii chars.
1505
+ if ($ord < 128) {
1506
+ $r = ($seed * (1 + $key)) % 100; # Pseudo-random function.
1507
+ # roughly 10% raw, 45% hex, 45% dec
1508
+ # '@' *must* be encoded. I insist.
1509
+ if ($r > 90 && $char != '@') /* do nothing */;
1510
+ else if ($r < 45) $chars[$key] = '&#x'.dechex($ord).';';
1511
+ else $chars[$key] = '&#'.$ord.';';
1512
+ }
1513
+ }
1514
+
1515
+ $addr = implode('', $chars);
1516
+ $text = implode('', array_slice($chars, 7)); # text without `mailto:`
1517
+ $addr = "<a href=\"$addr\">$text</a>";
1518
+
1519
+ return $addr;
1520
+ }
1521
+
1522
+
1523
+ function parseSpan($str) {
1524
+ #
1525
+ # Take the string $str and parse it into tokens, hashing embeded HTML,
1526
+ # escaped characters and handling code spans.
1527
+ #
1528
+ $output = '';
1529
+
1530
+ $span_re = '{
1531
+ (
1532
+ \\\\'.$this->escape_chars_re.'
1533
+ |
1534
+ (?<![`\\\\])
1535
+ `+ # code span marker
1536
+ '.( $this->no_markup ? '' : '
1537
+ |
1538
+ <!-- .*? --> # comment
1539
+ |
1540
+ <\?.*?\?> | <%.*?%> # processing instruction
1541
+ |
1542
+ <[/!$]?[-a-zA-Z0-9:_]+ # regular tags
1543
+ (?>
1544
+ \s
1545
+ (?>[^"\'>]+|"[^"]*"|\'[^\']*\')*
1546
+ )?
1547
+ >
1548
+ ').'
1549
+ )
1550
+ }xs';
1551
+
1552
+ while (1) {
1553
+ #
1554
+ # Each loop iteration seach for either the next tag, the next
1555
+ # openning code span marker, or the next escaped character.
1556
+ # Each token is then passed to handleSpanToken.
1557
+ #
1558
+ $parts = preg_split($span_re, $str, 2, PREG_SPLIT_DELIM_CAPTURE);
1559
+
1560
+ # Create token from text preceding tag.
1561
+ if ($parts[0] != "") {
1562
+ $output .= $parts[0];
1563
+ }
1564
+
1565
+ # Check if we reach the end.
1566
+ if (isset($parts[1])) {
1567
+ $output .= $this->handleSpanToken($parts[1], $parts[2]);
1568
+ $str = $parts[2];
1569
+ }
1570
+ else {
1571
+ break;
1572
+ }
1573
+ }
1574
+
1575
+ return $output;
1576
+ }
1577
+
1578
+
1579
+ function handleSpanToken($token, &$str) {
1580
+ #
1581
+ # Handle $token provided by parseSpan by determining its nature and
1582
+ # returning the corresponding value that should replace it.
1583
+ #
1584
+ switch ($token{0}) {
1585
+ case "\\":
1586
+ return $this->hashPart("&#". ord($token{1}). ";");
1587
+ case "`":
1588
+ # Search for end marker in remaining text.
1589
+ if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm',
1590
+ $str, $matches))
1591
+ {
1592
+ $str = $matches[2];
1593
+ $codespan = $this->makeCodeSpan($matches[1]);
1594
+ return $this->hashPart($codespan);
1595
+ }
1596
+ return $token; // return as text since no ending marker found.
1597
+ default:
1598
+ return $this->hashPart($token);
1599
+ }
1600
+ }
1601
+
1602
+
1603
+ function outdent($text) {
1604
+ #
1605
+ # Remove one level of line-leading tabs or spaces
1606
+ #
1607
+ return preg_replace('/^(\t|[ ]{1,'.$this->tab_width.'})/m', '', $text);
1608
+ }
1609
+
1610
+
1611
+ # String length function for detab. `_initDetab` will create a function to
1612
+ # hanlde UTF-8 if the default function does not exist.
1613
+ var $utf8_strlen = 'mb_strlen';
1614
+
1615
+ function detab($text) {
1616
+ #
1617
+ # Replace tabs with the appropriate amount of space.
1618
+ #
1619
+ # For each line we separate the line in blocks delemited by
1620
+ # tab characters. Then we reconstruct every line by adding the
1621
+ # appropriate number of space between each blocks.
1622
+
1623
+ $text = preg_replace_callback('/^.*\t.*$/m',
1624
+ array(&$this, '_detab_callback'), $text);
1625
+
1626
+ return $text;
1627
+ }
1628
+ function _detab_callback($matches) {
1629
+ $line = $matches[0];
1630
+ $strlen = $this->utf8_strlen; # strlen function for UTF-8.
1631
+
1632
+ # Split in blocks.
1633
+ $blocks = explode("\t", $line);
1634
+ # Add each blocks to the line.
1635
+ $line = $blocks[0];
1636
+ unset($blocks[0]); # Do not add first block twice.
1637
+ foreach ($blocks as $block) {
1638
+ # Calculate amount of space, insert spaces, insert block.
1639
+ $amount = $this->tab_width -
1640
+ $strlen($line, 'UTF-8') % $this->tab_width;
1641
+ $line .= str_repeat(" ", $amount) . $block;
1642
+ }
1643
+ return $line;
1644
+ }
1645
+ function _initDetab() {
1646
+ #
1647
+ # Check for the availability of the function in the `utf8_strlen` property
1648
+ # (initially `mb_strlen`). If the function is not available, create a
1649
+ # function that will loosely count the number of UTF-8 characters with a
1650
+ # regular expression.
1651
+ #
1652
+ if (function_exists($this->utf8_strlen)) return;
1653
+ $this->utf8_strlen = create_function('$text', 'return preg_match_all(
1654
+ "/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/",
1655
+ $text, $m);');
1656
+ }
1657
+
1658
+
1659
+ function unhash($text) {
1660
+ #
1661
+ # Swap back in all the tags hashed by _HashHTMLBlocks.
1662
+ #
1663
+ return preg_replace_callback('/(.)\x1A[0-9]+\1/',
1664
+ array(&$this, '_unhash_callback'), $text);
1665
+ }
1666
+ function _unhash_callback($matches) {
1667
+ return $this->html_hashes[$matches[0]];
1668
+ }
1669
+
1670
+ }
1671
+
1672
+
1673
+ #
1674
+ # Markdown Extra Parser Class
1675
+ #
1676
+
1677
+ class MarkdownExtra_Parser extends Markdown_Parser {
1678
+
1679
+ # Prefix for footnote ids.
1680
+ var $fn_id_prefix = "";
1681
+
1682
+ # Optional title attribute for footnote links and backlinks.
1683
+ var $fn_link_title = MARKDOWN_FN_LINK_TITLE;
1684
+ var $fn_backlink_title = MARKDOWN_FN_BACKLINK_TITLE;
1685
+
1686
+ # Optional class attribute for footnote links and backlinks.
1687
+ var $fn_link_class = MARKDOWN_FN_LINK_CLASS;
1688
+ var $fn_backlink_class = MARKDOWN_FN_BACKLINK_CLASS;
1689
+
1690
+ # Predefined abbreviations.
1691
+ var $predef_abbr = array();
1692
+
1693
+
1694
+ function MarkdownExtra_Parser() {
1695
+ #
1696
+ # Constructor function. Initialize the parser object.
1697
+ #
1698
+ # Add extra escapable characters before parent constructor
1699
+ # initialize the table.
1700
+ $this->escape_chars .= ':|';
1701
+
1702
+ # Insert extra document, block, and span transformations.
1703
+ # Parent constructor will do the sorting.
1704
+ $this->document_gamut += array(
1705
+ "doFencedCodeBlocks" => 5,
1706
+ "stripFootnotes" => 15,
1707
+ "stripAbbreviations" => 25,
1708
+ "appendFootnotes" => 50,
1709
+ );
1710
+ $this->block_gamut += array(
1711
+ "doFencedCodeBlocks" => 5,
1712
+ "doTables" => 15,
1713
+ "doDefLists" => 45,
1714
+ );
1715
+ $this->span_gamut += array(
1716
+ "doFootnotes" => 5,
1717
+ "doAbbreviations" => 70,
1718
+ );
1719
+
1720
+ parent::Markdown_Parser();
1721
+ }
1722
+
1723
+
1724
+ # Extra variables used during extra transformations.
1725
+ var $footnotes = array();
1726
+ var $footnotes_ordered = array();
1727
+ var $abbr_desciptions = array();
1728
+ var $abbr_word_re = '';
1729
+
1730
+ # Give the current footnote number.
1731
+ var $footnote_counter = 1;
1732
+
1733
+
1734
+ function setup() {
1735
+ #
1736
+ # Setting up Extra-specific variables.
1737
+ #
1738
+ parent::setup();
1739
+
1740
+ $this->footnotes = array();
1741
+ $this->footnotes_ordered = array();
1742
+ $this->abbr_desciptions = array();
1743
+ $this->abbr_word_re = '';
1744
+ $this->footnote_counter = 1;
1745
+
1746
+ foreach ($this->predef_abbr as $abbr_word => $abbr_desc) {
1747
+ if ($this->abbr_word_re)
1748
+ $this->abbr_word_re .= '|';
1749
+ $this->abbr_word_re .= preg_quote($abbr_word);
1750
+ $this->abbr_desciptions[$abbr_word] = trim($abbr_desc);
1751
+ }
1752
+ }
1753
+
1754
+ function teardown() {
1755
+ #
1756
+ # Clearing Extra-specific variables.
1757
+ #
1758
+ $this->footnotes = array();
1759
+ $this->footnotes_ordered = array();
1760
+ $this->abbr_desciptions = array();
1761
+ $this->abbr_word_re = '';
1762
+
1763
+ parent::teardown();
1764
+ }
1765
+
1766
+
1767
+ ### HTML Block Parser ###
1768
+
1769
+ # Tags that are always treated as block tags:
1770
+ var $block_tags_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|form|fieldset|iframe|hr|legend';
1771
+
1772
+ # Tags treated as block tags only if the opening tag is alone on it's line:
1773
+ var $context_block_tags_re = 'script|noscript|math|ins|del';
1774
+
1775
+ # Tags where markdown="1" default to span mode:
1776
+ var $contain_span_tags_re = 'p|h[1-6]|li|dd|dt|td|th|legend|address';
1777
+
1778
+ # Tags which must not have their contents modified, no matter where
1779
+ # they appear:
1780
+ var $clean_tags_re = 'script|math';
1781
+
1782
+ # Tags that do not need to be closed.
1783
+ var $auto_close_tags_re = 'hr|img';
1784
+
1785
+
1786
+ function hashHTMLBlocks($text) {
1787
+ #
1788
+ # Hashify HTML Blocks and "clean tags".
1789
+ #
1790
+ # We only want to do this for block-level HTML tags, such as headers,
1791
+ # lists, and tables. That's because we still want to wrap <p>s around
1792
+ # "paragraphs" that are wrapped in non-block-level tags, such as anchors,
1793
+ # phrase emphasis, and spans. The list of tags we're looking for is
1794
+ # hard-coded.
1795
+ #
1796
+ # This works by calling _HashHTMLBlocks_InMarkdown, which then calls
1797
+ # _HashHTMLBlocks_InHTML when it encounter block tags. When the markdown="1"
1798
+ # attribute is found whitin a tag, _HashHTMLBlocks_InHTML calls back
1799
+ # _HashHTMLBlocks_InMarkdown to handle the Markdown syntax within the tag.
1800
+ # These two functions are calling each other. It's recursive!
1801
+ #
1802
+ #
1803
+ # Call the HTML-in-Markdown hasher.
1804
+ #
1805
+ list($text, ) = $this->_hashHTMLBlocks_inMarkdown($text);
1806
+
1807
+ return $text;
1808
+ }
1809
+ function _hashHTMLBlocks_inMarkdown($text, $indent = 0,
1810
+ $enclosing_tag_re = '', $span = false)
1811
+ {
1812
+ #
1813
+ # Parse markdown text, calling _HashHTMLBlocks_InHTML for block tags.
1814
+ #
1815
+ # * $indent is the number of space to be ignored when checking for code
1816
+ # blocks. This is important because if we don't take the indent into
1817
+ # account, something like this (which looks right) won't work as expected:
1818
+ #
1819
+ # <div>
1820
+ # <div markdown="1">
1821
+ # Hello World. <-- Is this a Markdown code block or text?
1822
+ # </div> <-- Is this a Markdown code block or a real tag?
1823
+ # <div>
1824
+ #
1825
+ # If you don't like this, just don't indent the tag on which
1826
+ # you apply the markdown="1" attribute.
1827
+ #
1828
+ # * If $enclosing_tag_re is not empty, stops at the first unmatched closing
1829
+ # tag with that name. Nested tags supported.
1830
+ #
1831
+ # * If $span is true, text inside must treated as span. So any double
1832
+ # newline will be replaced by a single newline so that it does not create
1833
+ # paragraphs.
1834
+ #
1835
+ # Returns an array of that form: ( processed text , remaining text )
1836
+ #
1837
+ if ($text === '') return array('', '');
1838
+
1839
+ # Regex to check for the presense of newlines around a block tag.
1840
+ $newline_before_re = '/(?:^\n?|\n\n)*$/';
1841
+ $newline_after_re =
1842
+ '{
1843
+ ^ # Start of text following the tag.
1844
+ (?>[ ]*<!--.*?-->)? # Optional comment.
1845
+ [ ]*\n # Must be followed by newline.
1846
+ }xs';
1847
+
1848
+ # Regex to match any tag.
1849
+ $block_tag_re =
1850
+ '{
1851
+ ( # $2: Capture hole tag.
1852
+ </? # Any opening or closing tag.
1853
+ (?> # Tag name.
1854
+ '.$this->block_tags_re.' |
1855
+ '.$this->context_block_tags_re.' |
1856
+ '.$this->clean_tags_re.' |
1857
+ (?!\s)'.$enclosing_tag_re.'
1858
+ )
1859
+ (?:
1860
+ (?=[\s"\'/a-zA-Z0-9]) # Allowed characters after tag name.
1861
+ (?>
1862
+ ".*?" | # Double quotes (can contain `>`)
1863
+ \'.*?\' | # Single quotes (can contain `>`)
1864
+ .+? # Anything but quotes and `>`.
1865
+ )*?
1866
+ )?
1867
+ > # End of tag.
1868
+ |
1869
+ <!-- .*? --> # HTML Comment
1870
+ |
1871
+ <\?.*?\?> | <%.*?%> # Processing instruction
1872
+ |
1873
+ <!\[CDATA\[.*?\]\]> # CData Block
1874
+ |
1875
+ # Code span marker
1876
+ `+
1877
+ '. ( !$span ? ' # If not in span.
1878
+ |
1879
+ # Indented code block
1880
+ (?: ^[ ]*\n | ^ | \n[ ]*\n )
1881
+ [ ]{'.($indent+4).'}[^\n]* \n
1882
+ (?>
1883
+ (?: [ ]{'.($indent+4).'}[^\n]* | [ ]* ) \n
1884
+ )*
1885
+ |
1886
+ # Fenced code block marker
1887
+ (?> ^ | \n )
1888
+ [ ]{'.($indent).'}~~~+[ ]*\n
1889
+ ' : '' ). ' # End (if not is span).
1890
+ )
1891
+ }xs';
1892
+
1893
+
1894
+ $depth = 0; # Current depth inside the tag tree.
1895
+ $parsed = ""; # Parsed text that will be returned.
1896
+
1897
+ #
1898
+ # Loop through every tag until we find the closing tag of the parent
1899
+ # or loop until reaching the end of text if no parent tag specified.
1900
+ #
1901
+ do {
1902
+ #
1903
+ # Split the text using the first $tag_match pattern found.
1904
+ # Text before pattern will be first in the array, text after
1905
+ # pattern will be at the end, and between will be any catches made
1906
+ # by the pattern.
1907
+ #
1908
+ $parts = preg_split($block_tag_re, $text, 2,
1909
+ PREG_SPLIT_DELIM_CAPTURE);
1910
+
1911
+ # If in Markdown span mode, add a empty-string span-level hash
1912
+ # after each newline to prevent triggering any block element.
1913
+ if ($span) {
1914
+ $void = $this->hashPart("", ':');
1915
+ $newline = "$void\n";
1916
+ $parts[0] = $void . str_replace("\n", $newline, $parts[0]) . $void;
1917
+ }
1918
+
1919
+ $parsed .= $parts[0]; # Text before current tag.
1920
+
1921
+ # If end of $text has been reached. Stop loop.
1922
+ if (count($parts) < 3) {
1923
+ $text = "";
1924
+ break;
1925
+ }
1926
+
1927
+ $tag = $parts[1]; # Tag to handle.
1928
+ $text = $parts[2]; # Remaining text after current tag.
1929
+ $tag_re = preg_quote($tag); # For use in a regular expression.
1930
+
1931
+ #
1932
+ # Check for: Code span marker
1933
+ #
1934
+ if ($tag{0} == "`") {
1935
+ # Find corresponding end marker.
1936
+ $tag_re = preg_quote($tag);
1937
+ if (preg_match('{^(?>.+?|\n(?!\n))*?(?<!`)'.$tag_re.'(?!`)}',
1938
+ $text, $matches))
1939
+ {
1940
+ # End marker found: pass text unchanged until marker.
1941
+ $parsed .= $tag . $matches[0];
1942
+ $text = substr($text, strlen($matches[0]));
1943
+ }
1944
+ else {
1945
+ # Unmatched marker: just skip it.
1946
+ $parsed .= $tag;
1947
+ }
1948
+ }
1949
+ #
1950
+ # Check for: Indented code block.
1951
+ #
1952
+ else if ($tag{0} == "\n" || $tag{0} == " ") {
1953
+ # Indented code block: pass it unchanged, will be handled
1954
+ # later.
1955
+ $parsed .= $tag;
1956
+ }
1957
+ #
1958
+ # Check for: Fenced code block marker.
1959
+ #
1960
+ else if ($tag{0} == "~") {
1961
+ # Fenced code block marker: find matching end marker.
1962
+ $tag_re = preg_quote(trim($tag));
1963
+ if (preg_match('{^(?>.*\n)+?'.$tag_re.' *\n}', $text,
1964
+ $matches))
1965
+ {
1966
+ # End marker found: pass text unchanged until marker.
1967
+ $parsed .= $tag . $matches[0];
1968
+ $text = substr($text, strlen($matches[0]));
1969
+ }
1970
+ else {
1971
+ # No end marker: just skip it.
1972
+ $parsed .= $tag;
1973
+ }
1974
+ }
1975
+ #
1976
+ # Check for: Opening Block level tag or
1977
+ # Opening Context Block tag (like ins and del)
1978
+ # used as a block tag (tag is alone on it's line).
1979
+ #
1980
+ else if (preg_match('{^<(?:'.$this->block_tags_re.')\b}', $tag) ||
1981
+ ( preg_match('{^<(?:'.$this->context_block_tags_re.')\b}', $tag) &&
1982
+ preg_match($newline_before_re, $parsed) &&
1983
+ preg_match($newline_after_re, $text) )
1984
+ )
1985
+ {
1986
+ # Need to parse tag and following text using the HTML parser.
1987
+ list($block_text, $text) =
1988
+ $this->_hashHTMLBlocks_inHTML($tag . $text, "hashBlock", true);
1989
+
1990
+ # Make sure it stays outside of any paragraph by adding newlines.
1991
+ $parsed .= "\n\n$block_text\n\n";
1992
+ }
1993
+ #
1994
+ # Check for: Clean tag (like script, math)
1995
+ # HTML Comments, processing instructions.
1996
+ #
1997
+ else if (preg_match('{^<(?:'.$this->clean_tags_re.')\b}', $tag) ||
1998
+ $tag{1} == '!' || $tag{1} == '?')
1999
+ {
2000
+ # Need to parse tag and following text using the HTML parser.
2001
+ # (don't check for markdown attribute)
2002
+ list($block_text, $text) =
2003
+ $this->_hashHTMLBlocks_inHTML($tag . $text, "hashClean", false);
2004
+
2005
+ $parsed .= $block_text;
2006
+ }
2007
+ #
2008
+ # Check for: Tag with same name as enclosing tag.
2009
+ #
2010
+ else if ($enclosing_tag_re !== '' &&
2011
+ # Same name as enclosing tag.
2012
+ preg_match('{^</?(?:'.$enclosing_tag_re.')\b}', $tag))
2013
+ {
2014
+ #
2015
+ # Increase/decrease nested tag count.
2016
+ #
2017
+ if ($tag{1} == '/') $depth--;
2018
+ else if ($tag{strlen($tag)-2} != '/') $depth++;
2019
+
2020
+ if ($depth < 0) {
2021
+ #
2022
+ # Going out of parent element. Clean up and break so we
2023
+ # return to the calling function.
2024
+ #
2025
+ $text = $tag . $text;
2026
+ break;
2027
+ }
2028
+
2029
+ $parsed .= $tag;
2030
+ }
2031
+ else {
2032
+ $parsed .= $tag;
2033
+ }
2034
+ } while ($depth >= 0);
2035
+
2036
+ return array($parsed, $text);
2037
+ }
2038
+ function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) {
2039
+ #
2040
+ # Parse HTML, calling _HashHTMLBlocks_InMarkdown for block tags.
2041
+ #
2042
+ # * Calls $hash_method to convert any blocks.
2043
+ # * Stops when the first opening tag closes.
2044
+ # * $md_attr indicate if the use of the `markdown="1"` attribute is allowed.
2045
+ # (it is not inside clean tags)
2046
+ #
2047
+ # Returns an array of that form: ( processed text , remaining text )
2048
+ #
2049
+ if ($text === '') return array('', '');
2050
+
2051
+ # Regex to match `markdown` attribute inside of a tag.
2052
+ $markdown_attr_re = '
2053
+ {
2054
+ \s* # Eat whitespace before the `markdown` attribute
2055
+ markdown
2056
+ \s*=\s*
2057
+ (?>
2058
+ (["\']) # $1: quote delimiter
2059
+ (.*?) # $2: attribute value
2060
+ \1 # matching delimiter
2061
+ |
2062
+ ([^\s>]*) # $3: unquoted attribute value
2063
+ )
2064
+ () # $4: make $3 always defined (avoid warnings)
2065
+ }xs';
2066
+
2067
+ # Regex to match any tag.
2068
+ $tag_re = '{
2069
+ ( # $2: Capture hole tag.
2070
+ </? # Any opening or closing tag.
2071
+ [\w:$]+ # Tag name.
2072
+ (?:
2073
+ (?=[\s"\'/a-zA-Z0-9]) # Allowed characters after tag name.
2074
+ (?>
2075
+ ".*?" | # Double quotes (can contain `>`)
2076
+ \'.*?\' | # Single quotes (can contain `>`)
2077
+ .+? # Anything but quotes and `>`.
2078
+ )*?
2079
+ )?
2080
+ > # End of tag.
2081
+ |
2082
+ <!-- .*? --> # HTML Comment
2083
+ |
2084
+ <\?.*?\?> | <%.*?%> # Processing instruction
2085
+ |
2086
+ <!\[CDATA\[.*?\]\]> # CData Block
2087
+ )
2088
+ }xs';
2089
+
2090
+ $original_text = $text; # Save original text in case of faliure.
2091
+
2092
+ $depth = 0; # Current depth inside the tag tree.
2093
+ $block_text = ""; # Temporary text holder for current text.
2094
+ $parsed = ""; # Parsed text that will be returned.
2095
+
2096
+ #
2097
+ # Get the name of the starting tag.
2098
+ # (This pattern makes $base_tag_name_re safe without quoting.)
2099
+ #
2100
+ if (preg_match('/^<([\w:$]*)\b/', $text, $matches))
2101
+ $base_tag_name_re = $matches[1];
2102
+
2103
+ #
2104
+ # Loop through every tag until we find the corresponding closing tag.
2105
+ #
2106
+ do {
2107
+ #
2108
+ # Split the text using the first $tag_match pattern found.
2109
+ # Text before pattern will be first in the array, text after
2110
+ # pattern will be at the end, and between will be any catches made
2111
+ # by the pattern.
2112
+ #
2113
+ $parts = preg_split($tag_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE);
2114
+
2115
+ if (count($parts) < 3) {
2116
+ #
2117
+ # End of $text reached with unbalenced tag(s).
2118
+ # In that case, we return original text unchanged and pass the
2119
+ # first character as filtered to prevent an infinite loop in the
2120
+ # parent function.
2121
+ #
2122
+ return array($original_text{0}, substr($original_text, 1));
2123
+ }
2124
+
2125
+ $block_text .= $parts[0]; # Text before current tag.
2126
+ $tag = $parts[1]; # Tag to handle.
2127
+ $text = $parts[2]; # Remaining text after current tag.
2128
+
2129
+ #
2130
+ # Check for: Auto-close tag (like <hr/>)
2131
+ # Comments and Processing Instructions.
2132
+ #
2133
+ if (preg_match('{^</?(?:'.$this->auto_close_tags_re.')\b}', $tag) ||
2134
+ $tag{1} == '!' || $tag{1} == '?')
2135
+ {
2136
+ # Just add the tag to the block as if it was text.
2137
+ $block_text .= $tag;
2138
+ }
2139
+ else {
2140
+ #
2141
+ # Increase/decrease nested tag count. Only do so if
2142
+ # the tag's name match base tag's.
2143
+ #
2144
+ if (preg_match('{^</?'.$base_tag_name_re.'\b}', $tag)) {
2145
+ if ($tag{1} == '/') $depth--;
2146
+ else if ($tag{strlen($tag)-2} != '/') $depth++;
2147
+ }
2148
+
2149
+ #
2150
+ # Check for `markdown="1"` attribute and handle it.
2151
+ #
2152
+ if ($md_attr &&
2153
+ preg_match($markdown_attr_re, $tag, $attr_m) &&
2154
+ preg_match('/^1|block|span$/', $attr_m[2] . $attr_m[3]))
2155
+ {
2156
+ # Remove `markdown` attribute from opening tag.
2157
+ $tag = preg_replace($markdown_attr_re, '', $tag);
2158
+
2159
+ # Check if text inside this tag must be parsed in span mode.
2160
+ $this->mode = $attr_m[2] . $attr_m[3];
2161
+ $span_mode = $this->mode == 'span' || $this->mode != 'block' &&
2162
+ preg_match('{^<(?:'.$this->contain_span_tags_re.')\b}', $tag);
2163
+
2164
+ # Calculate indent before tag.
2165
+ if (preg_match('/(?:^|\n)( *?)(?! ).*?$/', $block_text, $matches)) {
2166
+ $strlen = $this->utf8_strlen;
2167
+ $indent = $strlen($matches[1], 'UTF-8');
2168
+ } else {
2169
+ $indent = 0;
2170
+ }
2171
+
2172
+ # End preceding block with this tag.
2173
+ $block_text .= $tag;
2174
+ $parsed .= $this->$hash_method($block_text);
2175
+
2176
+ # Get enclosing tag name for the ParseMarkdown function.
2177
+ # (This pattern makes $tag_name_re safe without quoting.)
2178
+ preg_match('/^<([\w:$]*)\b/', $tag, $matches);
2179
+ $tag_name_re = $matches[1];
2180
+
2181
+ # Parse the content using the HTML-in-Markdown parser.
2182
+ list ($block_text, $text)
2183
+ = $this->_hashHTMLBlocks_inMarkdown($text, $indent,
2184
+ $tag_name_re, $span_mode);
2185
+
2186
+ # Outdent markdown text.
2187
+ if ($indent > 0) {
2188
+ $block_text = preg_replace("/^[ ]{1,$indent}/m", "",
2189
+ $block_text);
2190
+ }
2191
+
2192
+ # Append tag content to parsed text.
2193
+ if (!$span_mode) $parsed .= "\n\n$block_text\n\n";
2194
+ else $parsed .= "$block_text";
2195
+
2196
+ # Start over a new block.
2197
+ $block_text = "";
2198
+ }
2199
+ else $block_text .= $tag;
2200
+ }
2201
+
2202
+ } while ($depth > 0);
2203
+
2204
+ #
2205
+ # Hash last block text that wasn't processed inside the loop.
2206
+ #
2207
+ $parsed .= $this->$hash_method($block_text);
2208
+
2209
+ return array($parsed, $text);
2210
+ }
2211
+
2212
+
2213
+ function hashClean($text) {
2214
+ #
2215
+ # Called whenever a tag must be hashed when a function insert a "clean" tag
2216
+ # in $text, it pass through this function and is automaticaly escaped,
2217
+ # blocking invalid nested overlap.
2218
+ #
2219
+ return $this->hashPart($text, 'C');
2220
+ }
2221
+
2222
+
2223
+ function doHeaders($text) {
2224
+ #
2225
+ # Redefined to add id attribute support.
2226
+ #
2227
+ # Setext-style headers:
2228
+ # Header 1 {#header1}
2229
+ # ========
2230
+ #
2231
+ # Header 2 {#header2}
2232
+ # --------
2233
+ #
2234
+ $text = preg_replace_callback(
2235
+ '{
2236
+ (^.+?) # $1: Header text
2237
+ (?:[ ]+\{\#([-_:a-zA-Z0-9]+)\})? # $2: Id attribute
2238
+ [ ]*\n(=+|-+)[ ]*\n+ # $3: Header footer
2239
+ }mx',
2240
+ array(&$this, '_doHeaders_callback_setext'), $text);
2241
+
2242
+ # atx-style headers:
2243
+ # # Header 1 {#header1}
2244
+ # ## Header 2 {#header2}
2245
+ # ## Header 2 with closing hashes ## {#header3}
2246
+ # ...
2247
+ # ###### Header 6 {#header2}
2248
+ #
2249
+ $text = preg_replace_callback('{
2250
+ ^(\#{1,6}) # $1 = string of #\'s
2251
+ [ ]*
2252
+ (.+?) # $2 = Header text
2253
+ [ ]*
2254
+ \#* # optional closing #\'s (not counted)
2255
+ (?:[ ]+\{\#([-_:a-zA-Z0-9]+)\})? # id attribute
2256
+ [ ]*
2257
+ \n+
2258
+ }xm',
2259
+ array(&$this, '_doHeaders_callback_atx'), $text);
2260
+
2261
+ return $text;
2262
+ }
2263
+ function _doHeaders_attr($attr) {
2264
+ if (empty($attr)) return "";
2265
+ return " id=\"$attr\"";
2266
+ }
2267
+ function _doHeaders_callback_setext($matches) {
2268
+ if ($matches[3] == '-' && preg_match('{^- }', $matches[1]))
2269
+ return $matches[0];
2270
+ $level = $matches[3]{0} == '=' ? 1 : 2;
2271
+ $attr = $this->_doHeaders_attr($id =& $matches[2]);
2272
+ $block = "<h$level$attr>".$this->runSpanGamut($matches[1])."</h$level>";
2273
+ return "\n" . $this->hashBlock($block) . "\n\n";
2274
+ }
2275
+ function _doHeaders_callback_atx($matches) {
2276
+ $level = strlen($matches[1]);
2277
+ $attr = $this->_doHeaders_attr($id =& $matches[3]);
2278
+ $block = "<h$level$attr>".$this->runSpanGamut($matches[2])."</h$level>";
2279
+ return "\n" . $this->hashBlock($block) . "\n\n";
2280
+ }
2281
+
2282
+
2283
+ function doTables($text) {
2284
+ #
2285
+ # Form HTML tables.
2286
+ #
2287
+ $less_than_tab = $this->tab_width - 1;
2288
+ #
2289
+ # Find tables with leading pipe.
2290
+ #
2291
+ # | Header 1 | Header 2
2292
+ # | -------- | --------
2293
+ # | Cell 1 | Cell 2
2294
+ # | Cell 3 | Cell 4
2295
+ #
2296
+ $text = preg_replace_callback('
2297
+ {
2298
+ ^ # Start of a line
2299
+ [ ]{0,'.$less_than_tab.'} # Allowed whitespace.
2300
+ [|] # Optional leading pipe (present)
2301
+ (.+) \n # $1: Header row (at least one pipe)
2302
+
2303
+ [ ]{0,'.$less_than_tab.'} # Allowed whitespace.
2304
+ [|] ([ ]*[-:]+[-| :]*) \n # $2: Header underline
2305
+
2306
+ ( # $3: Cells
2307
+ (?>
2308
+ [ ]* # Allowed whitespace.
2309
+ [|] .* \n # Row content.
2310
+ )*
2311
+ )
2312
+ (?=\n|\Z) # Stop at final double newline.
2313
+ }xm',
2314
+ array(&$this, '_doTable_leadingPipe_callback'), $text);
2315
+
2316
+ #
2317
+ # Find tables without leading pipe.
2318
+ #
2319
+ # Header 1 | Header 2
2320
+ # -------- | --------
2321
+ # Cell 1 | Cell 2
2322
+ # Cell 3 | Cell 4
2323
+ #
2324
+ $text = preg_replace_callback('
2325
+ {
2326
+ ^ # Start of a line
2327
+ [ ]{0,'.$less_than_tab.'} # Allowed whitespace.
2328
+ (\S.*[|].*) \n # $1: Header row (at least one pipe)
2329
+
2330
+ [ ]{0,'.$less_than_tab.'} # Allowed whitespace.
2331
+ ([-:]+[ ]*[|][-| :]*) \n # $2: Header underline
2332
+
2333
+ ( # $3: Cells
2334
+ (?>
2335
+ .* [|] .* \n # Row content
2336
+ )*
2337
+ )
2338
+ (?=\n|\Z) # Stop at final double newline.
2339
+ }xm',
2340
+ array(&$this, '_DoTable_callback'), $text);
2341
+
2342
+ return $text;
2343
+ }
2344
+ function _doTable_leadingPipe_callback($matches) {
2345
+ $head = $matches[1];
2346
+ $underline = $matches[2];
2347
+ $content = $matches[3];
2348
+
2349
+ # Remove leading pipe for each row.
2350
+ $content = preg_replace('/^ *[|]/m', '', $content);
2351
+
2352
+ return $this->_doTable_callback(array($matches[0], $head, $underline, $content));
2353
+ }
2354
+ function _doTable_callback($matches) {
2355
+ $head = $matches[1];
2356
+ $underline = $matches[2];
2357
+ $content = $matches[3];
2358
+
2359
+ # Remove any tailing pipes for each line.
2360
+ $head = preg_replace('/[|] *$/m', '', $head);
2361
+ $underline = preg_replace('/[|] *$/m', '', $underline);
2362
+ $content = preg_replace('/[|] *$/m', '', $content);
2363
+
2364
+ # Reading alignement from header underline.
2365
+ $separators = preg_split('/ *[|] */', $underline);
2366
+ foreach ($separators as $n => $s) {
2367
+ if (preg_match('/^ *-+: *$/', $s)) $attr[$n] = ' align="right"';
2368
+ else if (preg_match('/^ *:-+: *$/', $s))$attr[$n] = ' align="center"';
2369
+ else if (preg_match('/^ *:-+ *$/', $s)) $attr[$n] = ' align="left"';
2370
+ else $attr[$n] = '';
2371
+ }
2372
+
2373
+ # Parsing span elements, including code spans, character escapes,
2374
+ # and inline HTML tags, so that pipes inside those gets ignored.
2375
+ $head = $this->parseSpan($head);
2376
+ $headers = preg_split('/ *[|] */', $head);
2377
+ $col_count = count($headers);
2378
+
2379
+ # Write column headers.
2380
+ $text = "<table>\n";
2381
+ $text .= "<thead>\n";
2382
+ $text .= "<tr>\n";
2383
+ foreach ($headers as $n => $header)
2384
+ $text .= " <th$attr[$n]>".$this->runSpanGamut(trim($header))."</th>\n";
2385
+ $text .= "</tr>\n";
2386
+ $text .= "</thead>\n";
2387
+
2388
+ # Split content by row.
2389
+ $rows = explode("\n", trim($content, "\n"));
2390
+
2391
+ $text .= "<tbody>\n";
2392
+ foreach ($rows as $row) {
2393
+ # Parsing span elements, including code spans, character escapes,
2394
+ # and inline HTML tags, so that pipes inside those gets ignored.
2395
+ $row = $this->parseSpan($row);
2396
+
2397
+ # Split row by cell.
2398
+ $row_cells = preg_split('/ *[|] */', $row, $col_count);
2399
+ $row_cells = array_pad($row_cells, $col_count, '');
2400
+
2401
+ $text .= "<tr>\n";
2402
+ foreach ($row_cells as $n => $cell)
2403
+ $text .= " <td$attr[$n]>".$this->runSpanGamut(trim($cell))."</td>\n";
2404
+ $text .= "</tr>\n";
2405
+ }
2406
+ $text .= "</tbody>\n";
2407
+ $text .= "</table>";
2408
+
2409
+ return $this->hashBlock($text) . "\n";
2410
+ }
2411
+
2412
+
2413
+ function doDefLists($text) {
2414
+ #
2415
+ # Form HTML definition lists.
2416
+ #
2417
+ $less_than_tab = $this->tab_width - 1;
2418
+
2419
+ # Re-usable pattern to match any entire dl list:
2420
+ $whole_list_re = '(?>
2421
+ ( # $1 = whole list
2422
+ ( # $2
2423
+ [ ]{0,'.$less_than_tab.'}
2424
+ ((?>.*\S.*\n)+) # $3 = defined term
2425
+ \n?
2426
+ [ ]{0,'.$less_than_tab.'}:[ ]+ # colon starting definition
2427
+ )
2428
+ (?s:.+?)
2429
+ ( # $4
2430
+ \z
2431
+ |
2432
+ \n{2,}
2433
+ (?=\S)
2434
+ (?! # Negative lookahead for another term
2435
+ [ ]{0,'.$less_than_tab.'}
2436
+ (?: \S.*\n )+? # defined term
2437
+ \n?
2438
+ [ ]{0,'.$less_than_tab.'}:[ ]+ # colon starting definition
2439
+ )
2440
+ (?! # Negative lookahead for another definition
2441
+ [ ]{0,'.$less_than_tab.'}:[ ]+ # colon starting definition
2442
+ )
2443
+ )
2444
+ )
2445
+ )'; // mx
2446
+
2447
+ $text = preg_replace_callback('{
2448
+ (?>\A\n?|(?<=\n\n))
2449
+ '.$whole_list_re.'
2450
+ }mx',
2451
+ array(&$this, '_doDefLists_callback'), $text);
2452
+
2453
+ return $text;
2454
+ }
2455
+ function _doDefLists_callback($matches) {
2456
+ # Re-usable patterns to match list item bullets and number markers:
2457
+ $list = $matches[1];
2458
+
2459
+ # Turn double returns into triple returns, so that we can make a
2460
+ # paragraph for the last item in a list, if necessary:
2461
+ $result = trim($this->processDefListItems($list));
2462
+ $result = "<dl>\n" . $result . "\n</dl>";
2463
+ return $this->hashBlock($result) . "\n\n";
2464
+ }
2465
+
2466
+
2467
+ function processDefListItems($list_str) {
2468
+ #
2469
+ # Process the contents of a single definition list, splitting it
2470
+ # into individual term and definition list items.
2471
+ #
2472
+ $less_than_tab = $this->tab_width - 1;
2473
+
2474
+ # trim trailing blank lines:
2475
+ $list_str = preg_replace("/\n{2,}\\z/", "\n", $list_str);
2476
+
2477
+ # Process definition terms.
2478
+ $list_str = preg_replace_callback('{
2479
+ (?>\A\n?|\n\n+) # leading line
2480
+ ( # definition terms = $1
2481
+ [ ]{0,'.$less_than_tab.'} # leading whitespace
2482
+ (?![:][ ]|[ ]) # negative lookahead for a definition
2483
+ # mark (colon) or more whitespace.
2484
+ (?> \S.* \n)+? # actual term (not whitespace).
2485
+ )
2486
+ (?=\n?[ ]{0,3}:[ ]) # lookahead for following line feed
2487
+ # with a definition mark.
2488
+ }xm',
2489
+ array(&$this, '_processDefListItems_callback_dt'), $list_str);
2490
+
2491
+ # Process actual definitions.
2492
+ $list_str = preg_replace_callback('{
2493
+ \n(\n+)? # leading line = $1
2494
+ ( # marker space = $2
2495
+ [ ]{0,'.$less_than_tab.'} # whitespace before colon
2496
+ [:][ ]+ # definition mark (colon)
2497
+ )
2498
+ ((?s:.+?)) # definition text = $3
2499
+ (?= \n+ # stop at next definition mark,
2500
+ (?: # next term or end of text
2501
+ [ ]{0,'.$less_than_tab.'} [:][ ] |
2502
+ <dt> | \z
2503
+ )
2504
+ )
2505
+ }xm',
2506
+ array(&$this, '_processDefListItems_callback_dd'), $list_str);
2507
+
2508
+ return $list_str;
2509
+ }
2510
+ function _processDefListItems_callback_dt($matches) {
2511
+ $terms = explode("\n", trim($matches[1]));
2512
+ $text = '';
2513
+ foreach ($terms as $term) {
2514
+ $term = $this->runSpanGamut(trim($term));
2515
+ $text .= "\n<dt>" . $term . "</dt>";
2516
+ }
2517
+ return $text . "\n";
2518
+ }
2519
+ function _processDefListItems_callback_dd($matches) {
2520
+ $leading_line = $matches[1];
2521
+ $marker_space = $matches[2];
2522
+ $def = $matches[3];
2523
+
2524
+ if ($leading_line || preg_match('/\n{2,}/', $def)) {
2525
+ # Replace marker with the appropriate whitespace indentation
2526
+ $def = str_repeat(' ', strlen($marker_space)) . $def;
2527
+ $def = $this->runBlockGamut($this->outdent($def . "\n\n"));
2528
+ $def = "\n". $def ."\n";
2529
+ }
2530
+ else {
2531
+ $def = rtrim($def);
2532
+ $def = $this->runSpanGamut($this->outdent($def));
2533
+ }
2534
+
2535
+ return "\n<dd>" . $def . "</dd>\n";
2536
+ }
2537
+
2538
+
2539
+ function doFencedCodeBlocks($text) {
2540
+ #
2541
+ # Adding the fenced code block syntax to regular Markdown:
2542
+ #
2543
+ # ~~~
2544
+ # Code block
2545
+ # ~~~
2546
+ #
2547
+ $less_than_tab = $this->tab_width;
2548
+
2549
+ $text = preg_replace_callback('{
2550
+ (?:\n|\A)
2551
+ # 1: Opening marker
2552
+ (
2553
+ ~{3,} # Marker: three tilde or more.
2554
+ )
2555
+ [ ]* \n # Whitespace and newline following marker.
2556
+
2557
+ # 2: Content
2558
+ (
2559
+ (?>
2560
+ (?!\1 [ ]* \n) # Not a closing marker.
2561
+ .*\n+
2562
+ )+
2563
+ )
2564
+
2565
+ # Closing marker.
2566
+ \1 [ ]* \n
2567
+ }xm',
2568
+ array(&$this, '_doFencedCodeBlocks_callback'), $text);
2569
+
2570
+ return $text;
2571
+ }
2572
+ function _doFencedCodeBlocks_callback($matches) {
2573
+ $codeblock = $matches[2];
2574
+ $codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
2575
+ $codeblock = preg_replace_callback('/^\n+/',
2576
+ array(&$this, '_doFencedCodeBlocks_newlines'), $codeblock);
2577
+ $codeblock = "<pre><code>$codeblock</code></pre>";
2578
+ return "\n\n".$this->hashBlock($codeblock)."\n\n";
2579
+ }
2580
+ function _doFencedCodeBlocks_newlines($matches) {
2581
+ return str_repeat("<br$this->empty_element_suffix",
2582
+ strlen($matches[0]));
2583
+ }
2584
+
2585
+
2586
+ #
2587
+ # Redefining emphasis markers so that emphasis by underscore does not
2588
+ # work in the middle of a word.
2589
+ #
2590
+ var $em_relist = array(
2591
+ '' => '(?:(?<!\*)\*(?!\*)|(?<![a-zA-Z0-9_])_(?!_))(?=\S|$)(?![.,:;]\s)',
2592
+ '*' => '(?<=\S|^)(?<!\*)\*(?!\*)',
2593
+ '_' => '(?<=\S|^)(?<!_)_(?![a-zA-Z0-9_])',
2594
+ );
2595
+ var $strong_relist = array(
2596
+ '' => '(?:(?<!\*)\*\*(?!\*)|(?<![a-zA-Z0-9_])__(?!_))(?=\S|$)(?![.,:;]\s)',
2597
+ '**' => '(?<=\S|^)(?<!\*)\*\*(?!\*)',
2598
+ '__' => '(?<=\S|^)(?<!_)__(?![a-zA-Z0-9_])',
2599
+ );
2600
+ var $em_strong_relist = array(
2601
+ '' => '(?:(?<!\*)\*\*\*(?!\*)|(?<![a-zA-Z0-9_])___(?!_))(?=\S|$)(?![.,:;]\s)',
2602
+ '***' => '(?<=\S|^)(?<!\*)\*\*\*(?!\*)',
2603
+ '___' => '(?<=\S|^)(?<!_)___(?![a-zA-Z0-9_])',
2604
+ );
2605
+
2606
+
2607
+ function formParagraphs($text) {
2608
+ #
2609
+ # Params:
2610
+ # $text - string to process with html <p> tags
2611
+ #
2612
+ # Strip leading and trailing lines:
2613
+ $text = preg_replace('/\A\n+|\n+\z/', '', $text);
2614
+
2615
+ $grafs = preg_split('/\n{2,}/', $text, -1, PREG_SPLIT_NO_EMPTY);
2616
+
2617
+ #
2618
+ # Wrap <p> tags and unhashify HTML blocks
2619
+ #
2620
+ foreach ($grafs as $key => $value) {
2621
+ $value = trim($this->runSpanGamut($value));
2622
+
2623
+ # Check if this should be enclosed in a paragraph.
2624
+ # Clean tag hashes & block tag hashes are left alone.
2625
+ $is_p = !preg_match('/^B\x1A[0-9]+B|^C\x1A[0-9]+C$/', $value);
2626
+
2627
+ if ($is_p) {
2628
+ $value = "<p>$value</p>";
2629
+ }
2630
+ $grafs[$key] = $value;
2631
+ }
2632
+
2633
+ # Join grafs in one text, then unhash HTML tags.
2634
+ $text = implode("\n\n", $grafs);
2635
+
2636
+ # Finish by removing any tag hashes still present in $text.
2637
+ $text = $this->unhash($text);
2638
+
2639
+ return $text;
2640
+ }
2641
+
2642
+
2643
+ ### Footnotes
2644
+
2645
+ function stripFootnotes($text) {
2646
+ #
2647
+ # Strips link definitions from text, stores the URLs and titles in
2648
+ # hash references.
2649
+ #
2650
+ $less_than_tab = $this->tab_width - 1;
2651
+
2652
+ # Link defs are in the form: [^id]: url "optional title"
2653
+ $text = preg_replace_callback('{
2654
+ ^[ ]{0,'.$less_than_tab.'}\[\^(.+?)\][ ]?: # note_id = $1
2655
+ [ ]*
2656
+ \n? # maybe *one* newline
2657
+ ( # text = $2 (no blank lines allowed)
2658
+ (?:
2659
+ .+ # actual text
2660
+ |
2661
+ \n # newlines but
2662
+ (?!\[\^.+?\]:\s)# negative lookahead for footnote marker.
2663
+ (?!\n+[ ]{0,3}\S)# ensure line is not blank and followed
2664
+ # by non-indented content
2665
+ )*
2666
+ )
2667
+ }xm',
2668
+ array(&$this, '_stripFootnotes_callback'),
2669
+ $text);
2670
+ return $text;
2671
+ }
2672
+ function _stripFootnotes_callback($matches) {
2673
+ $note_id = $this->fn_id_prefix . $matches[1];
2674
+ $this->footnotes[$note_id] = $this->outdent($matches[2]);
2675
+ return ''; # String that will replace the block
2676
+ }
2677
+
2678
+
2679
+ function doFootnotes($text) {
2680
+ #
2681
+ # Replace footnote references in $text [^id] with a special text-token
2682
+ # which will be replaced by the actual footnote marker in appendFootnotes.
2683
+ #
2684
+ if (!$this->in_anchor) {
2685
+ $text = preg_replace('{\[\^(.+?)\]}', "F\x1Afn:\\1\x1A:", $text);
2686
+ }
2687
+ return $text;
2688
+ }
2689
+
2690
+
2691
+ function appendFootnotes($text) {
2692
+ #
2693
+ # Append footnote list to text.
2694
+ #
2695
+ $text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}',
2696
+ array(&$this, '_appendFootnotes_callback'), $text);
2697
+
2698
+ if (!empty($this->footnotes_ordered)) {
2699
+ $text .= "\n\n";
2700
+ $text .= "<div class=\"footnotes\">\n";
2701
+ $text .= "<hr". $this->empty_element_suffix ."\n";
2702
+ $text .= "<ol>\n\n";
2703
+
2704
+ $attr = " rev=\"footnote\"";
2705
+ if ($this->fn_backlink_class != "") {
2706
+ $class = $this->fn_backlink_class;
2707
+ $class = $this->encodeAttribute($class);
2708
+ $attr .= " class=\"$class\"";
2709
+ }
2710
+ if ($this->fn_backlink_title != "") {
2711
+ $title = $this->fn_backlink_title;
2712
+ $title = $this->encodeAttribute($title);
2713
+ $attr .= " title=\"$title\"";
2714
+ }
2715
+ $num = 0;
2716
+
2717
+ while (!empty($this->footnotes_ordered)) {
2718
+ $footnote = reset($this->footnotes_ordered);
2719
+ $note_id = key($this->footnotes_ordered);
2720
+ unset($this->footnotes_ordered[$note_id]);
2721
+
2722
+ $footnote .= "\n"; # Need to append newline before parsing.
2723
+ $footnote = $this->runBlockGamut("$footnote\n");
2724
+ $footnote = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}',
2725
+ array(&$this, '_appendFootnotes_callback'), $footnote);
2726
+
2727
+ $attr = str_replace("%%", ++$num, $attr);
2728
+ $note_id = $this->encodeAttribute($note_id);
2729
+
2730
+ # Add backlink to last paragraph; create new paragraph if needed.
2731
+ $backlink = "<a href=\"#fnref:$note_id\"$attr>&#8617;</a>";
2732
+ if (preg_match('{</p>$}', $footnote)) {
2733
+ $footnote = substr($footnote, 0, -4) . "&#160;$backlink</p>";
2734
+ } else {
2735
+ $footnote .= "\n\n<p>$backlink</p>";
2736
+ }
2737
+
2738
+ $text .= "<li id=\"fn:$note_id\">\n";
2739
+ $text .= $footnote . "\n";
2740
+ $text .= "</li>\n\n";
2741
+ }
2742
+
2743
+ $text .= "</ol>\n";
2744
+ $text .= "</div>";
2745
+ }
2746
+ return $text;
2747
+ }
2748
+ function _appendFootnotes_callback($matches) {
2749
+ $node_id = $this->fn_id_prefix . $matches[1];
2750
+
2751
+ # Create footnote marker only if it has a corresponding footnote *and*
2752
+ # the footnote hasn't been used by another marker.
2753
+ if (isset($this->footnotes[$node_id])) {
2754
+ # Transfert footnote content to the ordered list.
2755
+ $this->footnotes_ordered[$node_id] = $this->footnotes[$node_id];
2756
+ unset($this->footnotes[$node_id]);
2757
+
2758
+ $num = $this->footnote_counter++;
2759
+ $attr = " rel=\"footnote\"";
2760
+ if ($this->fn_link_class != "") {
2761
+ $class = $this->fn_link_class;
2762
+ $class = $this->encodeAttribute($class);
2763
+ $attr .= " class=\"$class\"";
2764
+ }
2765
+ if ($this->fn_link_title != "") {
2766
+ $title = $this->fn_link_title;
2767
+ $title = $this->encodeAttribute($title);
2768
+ $attr .= " title=\"$title\"";
2769
+ }
2770
+
2771
+ $attr = str_replace("%%", $num, $attr);
2772
+ $node_id = $this->encodeAttribute($node_id);
2773
+
2774
+ return
2775
+ "<sup id=\"fnref:$node_id\">".
2776
+ "<a href=\"#fn:$node_id\"$attr>$num</a>".
2777
+ "</sup>";
2778
+ }
2779
+
2780
+ return "[^".$matches[1]."]";
2781
+ }
2782
+
2783
+
2784
+ ### Abbreviations ###
2785
+
2786
+ function stripAbbreviations($text) {
2787
+ #
2788
+ # Strips abbreviations from text, stores titles in hash references.
2789
+ #
2790
+ $less_than_tab = $this->tab_width - 1;
2791
+
2792
+ # Link defs are in the form: [id]*: url "optional title"
2793
+ $text = preg_replace_callback('{
2794
+ ^[ ]{0,'.$less_than_tab.'}\*\[(.+?)\][ ]?: # abbr_id = $1
2795
+ (.*) # text = $2 (no blank lines allowed)
2796
+ }xm',
2797
+ array(&$this, '_stripAbbreviations_callback'),
2798
+ $text);
2799
+ return $text;
2800
+ }
2801
+ function _stripAbbreviations_callback($matches) {
2802
+ $abbr_word = $matches[1];
2803
+ $abbr_desc = $matches[2];
2804
+ if ($this->abbr_word_re)
2805
+ $this->abbr_word_re .= '|';
2806
+ $this->abbr_word_re .= preg_quote($abbr_word);
2807
+ $this->abbr_desciptions[$abbr_word] = trim($abbr_desc);
2808
+ return ''; # String that will replace the block
2809
+ }
2810
+
2811
+
2812
+ function doAbbreviations($text) {
2813
+ #
2814
+ # Find defined abbreviations in text and wrap them in <abbr> elements.
2815
+ #
2816
+ if ($this->abbr_word_re) {
2817
+ // cannot use the /x modifier because abbr_word_re may
2818
+ // contain significant spaces:
2819
+ $text = preg_replace_callback('{'.
2820
+ '(?<![\w\x1A])'.
2821
+ '(?:'.$this->abbr_word_re.')'.
2822
+ '(?![\w\x1A])'.
2823
+ '}',
2824
+ array(&$this, '_doAbbreviations_callback'), $text);
2825
+ }
2826
+ return $text;
2827
+ }
2828
+ function _doAbbreviations_callback($matches) {
2829
+ $abbr = $matches[0];
2830
+ if (isset($this->abbr_desciptions[$abbr])) {
2831
+ $desc = $this->abbr_desciptions[$abbr];
2832
+ if (empty($desc)) {
2833
+ return $this->hashPart("<abbr>$abbr</abbr>");
2834
+ } else {
2835
+ $desc = $this->encodeAttribute($desc);
2836
+ return $this->hashPart("<abbr title=\"$desc\">$abbr</abbr>");
2837
+ }
2838
+ } else {
2839
+ return $matches[0];
2840
+ }
2841
+ }
2842
+
2843
+ }
2844
+
2845
+
2846
+ /*
2847
+
2848
+ PHP Markdown Extra
2849
+ ==================
2850
+
2851
+ Description
2852
+ -----------
2853
+
2854
+ This is a PHP port of the original Markdown formatter written in Perl
2855
+ by John Gruber. This special "Extra" version of PHP Markdown features
2856
+ further enhancements to the syntax for making additional constructs
2857
+ such as tables and definition list.
2858
+
2859
+ Markdown is a text-to-HTML filter; it translates an easy-to-read /
2860
+ easy-to-write structured text format into HTML. Markdown's text format
2861
+ is most similar to that of plain text email, and supports features such
2862
+ as headers, *emphasis*, code blocks, blockquotes, and links.
2863
+
2864
+ Markdown's syntax is designed not as a generic markup language, but
2865
+ specifically to serve as a front-end to (X)HTML. You can use span-level
2866
+ HTML tags anywhere in a Markdown document, and you can use block level
2867
+ HTML tags (like <div> and <table> as well).
2868
+
2869
+ For more information about Markdown's syntax, see:
2870
+
2871
+ <http://daringfireball.net/projects/markdown/>
2872
+
2873
+
2874
+ Bugs
2875
+ ----
2876
+
2877
+ To file bug reports please send email to:
2878
+
2879
+ <michel.fortin@michelf.com>
2880
+
2881
+ Please include with your report: (1) the example input; (2) the output you
2882
+ expected; (3) the output Markdown actually produced.
2883
+
2884
+
2885
+ Version History
2886
+ ---------------
2887
+
2888
+ See the readme file for detailed release notes for this version.
2889
+
2890
+
2891
+ Copyright and License
2892
+ ---------------------
2893
+
2894
+ PHP Markdown & Extra
2895
+ Copyright (c) 2004-2009 Michel Fortin
2896
+ <http://michelf.com/>
2897
+ All rights reserved.
2898
+
2899
+ Based on Markdown
2900
+ Copyright (c) 2003-2006 John Gruber
2901
+ <http://daringfireball.net/>
2902
+ All rights reserved.
2903
+
2904
+ Redistribution and use in source and binary forms, with or without
2905
+ modification, are permitted provided that the following conditions are
2906
+ met:
2907
+
2908
+ * Redistributions of source code must retain the above copyright notice,
2909
+ this list of conditions and the following disclaimer.
2910
+
2911
+ * Redistributions in binary form must reproduce the above copyright
2912
+ notice, this list of conditions and the following disclaimer in the
2913
+ documentation and/or other materials provided with the distribution.
2914
+
2915
+ * Neither the name "Markdown" nor the names of its contributors may
2916
+ be used to endorse or promote products derived from this software
2917
+ without specific prior written permission.
2918
+
2919
+ This software is provided by the copyright holders and contributors "as
2920
+ is" and any express or implied warranties, including, but not limited
2921
+ to, the implied warranties of merchantability and fitness for a
2922
+ particular purpose are disclaimed. In no event shall the copyright owner
2923
+ or contributors be liable for any direct, indirect, incidental, special,
2924
+ exemplary, or consequential damages (including, but not limited to,
2925
+ procurement of substitute goods or services; loss of use, data, or
2926
+ profits; or business interruption) however caused and on any theory of
2927
+ liability, whether in contract, strict liability, or tort (including
2928
+ negligence or otherwise) arising in any way out of the use of this
2929
+ software, even if advised of the possibility of such damage.
2930
+
2931
+ */
2932
+ ?>
includes/licensing.php CHANGED
@@ -1,5 +1,19 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  /**
5
  * Returns all registered addons.
@@ -165,36 +179,69 @@ function wprss_get_license_expiry( $addon ) {
165
  }
166
 
167
 
168
- add_action( 'admin_init', 'wprss_check_for_expired_licenses');
169
  /**
170
  * Checks whether there are any invalid or expired licenses.
171
  *
172
- * @since 4.6.9
 
173
  */
174
- function wprss_check_for_expired_licenses() {
175
- $show_notice = FALSE;
176
  // Get the license statuses including expiry dates.
177
  $statuses = get_option( 'wprss_settings_license_statuses', array() );
178
 
179
  foreach ($statuses as $key => $value) {
180
  if ( strpos($key, '_license_status') > 0 ) {
181
  if ( $value !== 'valid') {
182
- $show_notice = TRUE;
183
  }
184
  } else if ( strpos($key, '_license_expires') > 0 ) {
185
  // Check invalid expiry dates.
186
  $expires = strtotime( substr( $value, 0, strpos( $value, " " ) ) );
187
 
188
  if ( $expires == 0 || ( $expires < strtotime("+2 weeks") ) ) {
189
- $show_notice = TRUE;
190
- break;
191
  }
192
  }
193
  }
194
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  // Check if we found any of the licenses to be invalid, expiring or expired
196
  // so that we can show the appropriate license nag.
197
- if ($show_notice) {
198
  add_action( 'all_admin_notices', 'wprss_show_license_notice' );
199
  }
200
  }
@@ -238,7 +285,7 @@ function wprss_show_license_notice() {
238
  );
239
 
240
  // Save the notice we're going to display
241
- $notices[$uid] = '<div class="error"><p>' . $msg . '</p></div>';
242
  }
243
  } else if ( strpos($key, '_license_expires') > 0 ) {
244
  // Check for expired licenses
@@ -269,7 +316,7 @@ function wprss_show_license_notice() {
269
 
270
  // Only show this notice if there isn't already a notice to show for this add-on.
271
  if ( !isset($notices[$uid]) ) {
272
- $notices[$uid] = '<div class="error"><p>' . $msg . $hide . '</p></div>';
273
  }
274
  }
275
  }
@@ -326,6 +373,17 @@ function wprss_ajax_manage_license() {
326
  wprss_echo_error_and_die( __('No nonce', WPRSS_TEXT_DOMAIN), $addon);
327
  }
328
 
 
 
 
 
 
 
 
 
 
 
 
329
  // Call the appropriate EDD licensing function.
330
  if ($event === 'activate') {
331
  $status = wprss_edd_activate_license($addon, $license);
@@ -335,11 +393,6 @@ function wprss_ajax_manage_license() {
335
  wprss_echo_error_and_die( __('Invalid event specified', WPRSS_TEXT_DOMAIN), $addon);
336
  }
337
 
338
- // Update the license key stored in the DB.
339
- $license_keys = get_option('wprss_settings_license_keys', array());
340
- $license_keys[$addon . '_license_key'] = $license;
341
- update_option('wprss_settings_license_keys', $license_keys);
342
-
343
  // Assemble the JSON data to return.
344
  $ret = array();
345
 
@@ -354,6 +407,8 @@ function wprss_ajax_manage_license() {
354
  // Set the HTML markup for the new button and validity display.
355
  $ret['html'] = wprss_get_activate_license_button($addon);
356
 
 
 
357
  // Return the JSON data.
358
  echo json_encode($ret);
359
  die();
@@ -444,12 +499,24 @@ function wprss_license_settings() {
444
  */
445
  function wprss_license_key_field( $args ) {
446
  $addon_id = $args[0];
447
- $license = wprss_get_license_key( $addon_id ); ?>
448
- <input id="wprss-<?php echo $addon_id; ?>-license-key" name="wprss_settings_license_keys[<?php echo $addon_id; ?>_license_key]"
449
- type="text" value="<?php echo esc_attr( $license ); ?>" style="width: 300px;"
 
 
 
 
 
 
 
 
 
 
 
 
450
  />
451
- <label class="description" for="wprss-<?php echo $addon_id; ?>-license-key">
452
- <?php _e( 'Enter your license key', WPRSS_TEXT_DOMAIN ); ?>
453
  </label><?php
454
  }
455
 
@@ -470,7 +537,7 @@ function wprss_activate_license_button( $args ) {
470
  $btn_text = $valid ? 'Deactivate License' : 'Activate License';
471
  $btn_name = "wprss_{$addon_id}_license_" . ( $valid? 'deactivate' : 'activate' );
472
  $btn_class = "button-" . ( $valid ? 'deactivate' : 'activate' ) . "-license";
473
- wp_nonce_field( "wprss_{$addon_id}_license_nonce", "wprss_{$addon_id}_license_nonce" ); ?>
474
 
475
  <input type="button" class="<?php echo $btn_class; ?> button-process-license button-secondary" name="<?php echo $btn_name; ?>" value="<?php _e( $btn_text, WPRSS_TEXT_DOMAIN ); ?>" />
476
  <span id="wprss-<?php echo $addon_id; ?>-license-status-text">
@@ -498,12 +565,20 @@ function wprss_activate_license_button( $args ) {
498
  $acts_limit = $data->license_limit;
499
  $expires = $data->expires;
500
  $expires = substr( $expires, 0, strpos( $expires, " " ) );
 
 
 
501
  ?>
502
  <small>
 
 
 
 
 
503
  <?php if ( strtotime($expires) < strtotime("+2 weeks") ) : ?>
504
- <?php $renewal_url = esc_attr(WPRSS_SL_STORE_URL . '/checkout/?edd_license_key=' . $license_key); ?>
505
- <a href="<?php echo $renewal_url; ?>"><?php _e('Renew your license to continue receiving updates and support.', WPRSS_TEXT_DOMAIN); ?></a>
506
- <br/>
507
  <?php endif; ?>
508
  <strong><?php _e('Activations', WPRSS_TEXT_DOMAIN); ?>:</strong>
509
  <?php echo $acts_current.'/'.$acts_limit; ?> (<?php echo $acts_left; ?> left)
@@ -514,6 +589,7 @@ function wprss_activate_license_button( $args ) {
514
  <strong><?php _e('Registered to', WPRSS_TEXT_DOMAIN); ?>:</strong>
515
  <?php echo $data->customer_name; ?> (<code><?php echo $data->customer_email; ?></code>)
516
  </small>
 
517
  <?php else: ?>
518
  <small><?php _e('Failed to get license information. This is a temporary problem. Check your internet connection and try again later.', WPRSS_TEXT_DOMAIN); ?></small>
519
  <?php endif; ?>
@@ -637,3 +713,38 @@ function wprss_setup_edd_updater() {
637
  ));
638
  }
639
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
+ /**
4
+ * What to print in place of license code chars.
5
+ * This must not be a symbol that is considered to be a valid license key char.
6
+ *
7
+ * @since 4.6.10
8
+ */
9
+ define( 'WPRSS_LICENSE_KEY_MASK_CHAR', '•' );
10
+ /**
11
+ * How many characters of the license code to print as is.
12
+ * Use negative value to indicate that characters at the end of the key are excluded.
13
+ *
14
+ * @since 4.6.10
15
+ */
16
+ define( 'WPRSS_LICENSE_KEY_MASK_EXCLUDE_AMOUNT', -4 );
17
 
18
  /**
19
  * Returns all registered addons.
179
  }
180
 
181
 
182
+ add_action( 'admin_init', 'wprss_check_to_show_license_notice');
183
  /**
184
  * Checks whether there are any invalid or expired licenses.
185
  *
186
+ * @since 4.6.10
187
+ * @return BOOL which is TRUE if any addons are unlicensed, FALSE otherwise.
188
  */
189
+ function wprss_unlicensed_addons_exist() {
 
190
  // Get the license statuses including expiry dates.
191
  $statuses = get_option( 'wprss_settings_license_statuses', array() );
192
 
193
  foreach ($statuses as $key => $value) {
194
  if ( strpos($key, '_license_status') > 0 ) {
195
  if ( $value !== 'valid') {
196
+ return TRUE;
197
  }
198
  } else if ( strpos($key, '_license_expires') > 0 ) {
199
  // Check invalid expiry dates.
200
  $expires = strtotime( substr( $value, 0, strpos( $value, " " ) ) );
201
 
202
  if ( $expires == 0 || ( $expires < strtotime("+2 weeks") ) ) {
203
+ return TRUE;
 
204
  }
205
  }
206
  }
207
 
208
+ return FALSE;
209
+ }
210
+
211
+ /**
212
+ * Returns an array of addon IDs that are licensed.
213
+ *
214
+ * @since 4.6.10
215
+ * @return Array of addon ID strings that have a valid license status.
216
+ */
217
+ function wprss_get_licensed_addons() {
218
+ $addons = array();
219
+
220
+ // Get the license statuses.
221
+ $statuses = get_option( 'wprss_settings_license_statuses', array() );
222
+
223
+ foreach ($statuses as $key => $value) {
224
+ if ( strpos($key, '_license_status') > 0 ) {
225
+ if ( $value === 'valid') {
226
+ $addons[] = strtoupper( substr( $key, 0, strpos( $key, "_" ) ) );
227
+ }
228
+ }
229
+ }
230
+
231
+ return $addons;
232
+
233
+ }
234
+
235
+
236
+ /**
237
+ * Checks whether we should show the invalid/expired license notices.
238
+ *
239
+ * @since 4.6.10
240
+ */
241
+ function wprss_check_to_show_license_notice() {
242
  // Check if we found any of the licenses to be invalid, expiring or expired
243
  // so that we can show the appropriate license nag.
244
+ if (wprss_unlicensed_addons_exist()) {
245
  add_action( 'all_admin_notices', 'wprss_show_license_notice' );
246
  }
247
  }
285
  );
286
 
287
  // Save the notice we're going to display
288
+ $notices[$uid] = '<div id="wprss-license-notice-' . $uid . '" class="error wprss-license-notice"><p>' . $msg . '</p></div>';
289
  }
290
  } else if ( strpos($key, '_license_expires') > 0 ) {
291
  // Check for expired licenses
316
 
317
  // Only show this notice if there isn't already a notice to show for this add-on.
318
  if ( !isset($notices[$uid]) ) {
319
+ $notices[$uid] = '<div class="error wprss-license-notice"><p>' . $msg . $hide . '</p></div>';
320
  }
321
  }
322
  }
373
  wprss_echo_error_and_die( __('No nonce', WPRSS_TEXT_DOMAIN), $addon);
374
  }
375
 
376
+ $license_keys = get_option('wprss_settings_license_keys', array());
377
+ // Check if the license key was obfuscated on the client's end.
378
+ if ( wprss_license_key_is_obfuscated( $license ) ) {
379
+ // If so, use the stored license key for de/activation.
380
+ $license = $license_keys[$addon . '_license_key'];
381
+ } else {
382
+ // Otherwise, update the license key stored in the DB.
383
+ $license_keys[$addon . '_license_key'] = $license;
384
+ update_option('wprss_settings_license_keys', $license_keys);
385
+ }
386
+
387
  // Call the appropriate EDD licensing function.
388
  if ($event === 'activate') {
389
  $status = wprss_edd_activate_license($addon, $license);
393
  wprss_echo_error_and_die( __('Invalid event specified', WPRSS_TEXT_DOMAIN), $addon);
394
  }
395
 
 
 
 
 
 
396
  // Assemble the JSON data to return.
397
  $ret = array();
398
 
407
  // Set the HTML markup for the new button and validity display.
408
  $ret['html'] = wprss_get_activate_license_button($addon);
409
 
410
+ $ret['licensedAddons'] = wprss_get_licensed_addons();
411
+
412
  // Return the JSON data.
413
  echo json_encode($ret);
414
  die();
499
  */
500
  function wprss_license_key_field( $args ) {
501
  $addon_id = $args[0];
502
+ $license_key = wprss_get_license_key( $addon_id );
503
+ $license_key_length = strlen( $license_key );
504
+ $mask_char = WPRSS_LICENSE_KEY_MASK_CHAR;
505
+ // How many chars to show
506
+ $mask_exclude_amount = WPRSS_LICENSE_KEY_MASK_EXCLUDE_AMOUNT;
507
+ $mask_exclude_amount = abs( $mask_exclude_amount ) > ($license_key_length - 1)
508
+ ? ($license_key_length - 1) * ( $mask_exclude_amount < 0 ? -1 : 1 ) // Making sure to preserve position of mask
509
+ : $mask_exclude_amount;
510
+ // How many chars to mask. Always at least one char will be masked.
511
+ $mask_length = $license_key_length - abs( $mask_exclude_amount );
512
+ $mask = str_repeat( $mask_char, $mask_length );
513
+ $excluded_chars = mb_substr( $license_key, $mask_exclude_amount < 0 ? $mask_length : 0, abs( $mask_exclude_amount ) );
514
+ $displayed_key = sprintf( $mask_exclude_amount > 0 ? '%1$s%2$s' : '%2$s%1$s', $excluded_chars, $mask); ?>
515
+ <input id="wprss-<?php echo $addon_id ?>-license-key" name="wprss_settings_license_keys[<?php echo $addon_id ?>_license_key]"
516
+ type="text" value="<?php echo esc_attr( $displayed_key ) ?>" style="width: 300px;"
517
  />
518
+ <label class="description" for="wprss-<?php echo $addon_id ?>-license-key">
519
+ <?php _e( 'Enter your license key', WPRSS_TEXT_DOMAIN ) ?>
520
  </label><?php
521
  }
522
 
537
  $btn_text = $valid ? 'Deactivate License' : 'Activate License';
538
  $btn_name = "wprss_{$addon_id}_license_" . ( $valid? 'deactivate' : 'activate' );
539
  $btn_class = "button-" . ( $valid ? 'deactivate' : 'activate' ) . "-license";
540
+ wp_nonce_field( "wprss_{$addon_id}_license_nonce", "wprss_{$addon_id}_license_nonce", false ); ?>
541
 
542
  <input type="button" class="<?php echo $btn_class; ?> button-process-license button-secondary" name="<?php echo $btn_name; ?>" value="<?php _e( $btn_text, WPRSS_TEXT_DOMAIN ); ?>" />
543
  <span id="wprss-<?php echo $addon_id; ?>-license-status-text">
565
  $acts_limit = $data->license_limit;
566
  $expires = $data->expires;
567
  $expires = substr( $expires, 0, strpos( $expires, " " ) );
568
+
569
+ // If the license key is garbage, don't show any of the data.
570
+ if ( !empty($data->payment_id) && !empty($data->license_limit ) ) :
571
  ?>
572
  <small>
573
+ <?php if ( $status !== 'valid' && $acts_left === 0 ) : ?>
574
+ <?php $account_url = 'https://www.wprssaggregator.com/account/?action=manage_licenses&payment_id=' . $data->payment_id; ?>
575
+ <a href="<?php echo $account_url; ?>"><?php _e("No activations left. Click here to manage the sites you've activated licenses on.", WPRSS_TEXT_DOMAIN); ?></a>
576
+ <br/>
577
+ <?php endif; ?>
578
  <?php if ( strtotime($expires) < strtotime("+2 weeks") ) : ?>
579
+ <?php $renewal_url = esc_attr(WPRSS_SL_STORE_URL . '/checkout/?edd_license_key=' . $license_key); ?>
580
+ <a href="<?php echo $renewal_url; ?>"><?php _e('Renew your license to continue receiving updates and support.', WPRSS_TEXT_DOMAIN); ?></a>
581
+ <br/>
582
  <?php endif; ?>
583
  <strong><?php _e('Activations', WPRSS_TEXT_DOMAIN); ?>:</strong>
584
  <?php echo $acts_current.'/'.$acts_limit; ?> (<?php echo $acts_left; ?> left)
589
  <strong><?php _e('Registered to', WPRSS_TEXT_DOMAIN); ?>:</strong>
590
  <?php echo $data->customer_name; ?> (<code><?php echo $data->customer_email; ?></code>)
591
  </small>
592
+ <?php endif; ?>
593
  <?php else: ?>
594
  <small><?php _e('Failed to get license information. This is a temporary problem. Check your internet connection and try again later.', WPRSS_TEXT_DOMAIN); ?></small>
595
  <?php endif; ?>
713
  ));
714
  }
715
  }
716
+
717
+
718
+ add_filter( 'wprss_settings_license_key_is_valid', 'wprss_license_validate_key_for_save', 10, 2 );
719
+ /**
720
+ * Invalidates the key if it is obfuscated, causing the saved version to be used.
721
+ * This meanst that the new key will not be saved, as it is considered then to be unchanged.
722
+ *
723
+ * @since 4.6.10
724
+ * @param bool $is_valid Indicates whether the key is currently considered to be valid.
725
+ * @param string $key The license key in question
726
+ * @return Whether or not the key is still to be considered valid.
727
+ */
728
+ function wprss_license_validate_key_for_save( $is_valid, $key ) {
729
+ if ( wprss_license_key_is_obfuscated( $key ) )
730
+ return false;
731
+
732
+ return $is_valid;
733
+ }
734
+
735
+
736
+ /**
737
+ * Determines whether or not the license key in question is obfuscated.
738
+ *
739
+ * This is achieved by searching for the mask character in the key. Because the
740
+ * mask character cannot be a valid license character, the presence of at least
741
+ * one such character indicates that the key is obfuscated.
742
+ *
743
+ * @since 4.6.10
744
+ * @param string $key The license key in question.
745
+ * @return bool Whether or not this key is obfuscated.
746
+ */
747
+ function wprss_license_key_is_obfuscated( $key ) {
748
+ $char = WPRSS_LICENSE_KEY_MASK_CHAR;
749
+ return mb_stripos( $key, $char ) !== false;
750
+ }
includes/readme.php ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Markdown - dependency
3
+ if ( !function_exists( 'Markdown' ) )
4
+ require_once( WPRSS_INC . 'libraries/php-markdown/markdown.php' );
5
+ // The parser
6
+ if ( !class_exists( 'Baikonur_ReadmeParser' ) )
7
+ require_once( WPRSS_INC . 'libraries/WordPress-Readme-Parser/ReadmeParser.php' );
8
+
9
+
10
+ /**
11
+ * Parses a readme file identified by it's path.
12
+ *
13
+ * @since 4.6.10
14
+ * @see Baikonur_ReadmeParser::parse_readme_contents()
15
+ * @param string $file
16
+ * @return \WPRSS_Readme
17
+ */
18
+ function wprss_parse_readme( $file = null ) {
19
+ if ( is_null( $file ) )
20
+ $file = WPRSS_DIR . 'readme.txt';
21
+
22
+ $readme = new WPRSS_Readme( $file );
23
+
24
+ do_action( 'wprss_parse_readme_before', $readme );
25
+ $readme->load();
26
+ do_action( 'wprss_parse_readme_after', $readme );
27
+
28
+ return $readme;
29
+ }
30
+
31
+ /**
32
+ * Parses a readme file, and returns it's changelog.
33
+ *
34
+ * @since 4.4
35
+ * @see Baikonur_ReadmeParser::parse_readme_contents()
36
+ * @return array An array containing version changelogs
37
+ */
38
+ function wprss_parse_changelog( $file = null ) {
39
+ if ( is_null( $file ) )
40
+ $file = WPRSS_DIR . 'readme.txt';
41
+
42
+ $file = apply_filters( 'wprss_parse_changelog_before', $file );
43
+ $readme = wprss_parse_readme( $file );
44
+ $changelog = apply_filters( 'wprss_parse_changelog_after', $readme->get_changelog() );
45
+
46
+ return $changelog;
47
+ }
48
+
49
+
50
+ /**
51
+ * Encapsulates data of a single WordPress readme file.
52
+ */
53
+ class WPRSS_Readme {
54
+
55
+ protected $_parser;
56
+ protected $_readme;
57
+ protected $_file_path;
58
+
59
+ public function __construct( $data = null ) {
60
+ $args = func_get_args();
61
+
62
+ $data = isset( $args[0] ) ? array_shift( $args ) : null;
63
+ if ( is_string( $data ) )
64
+ $this->set_file_path( $data );
65
+
66
+ $this->_construct();
67
+ }
68
+
69
+
70
+ protected function _construct() {
71
+ }
72
+
73
+
74
+ /**
75
+ * @param string $string The readme contents to parse
76
+ * @return string The parsed data
77
+ */
78
+ public function parse_string( $string ) {
79
+ $parser = $this->get_parser();
80
+ $string = $this->_before_parse( $string );
81
+ $result = $parser->parse( $string );
82
+ $result = $this->_after_parse( $result );
83
+
84
+ return $result;
85
+ }
86
+
87
+
88
+ /**
89
+ * @param string $file Path to readme file
90
+ * @return \WPRSS_Readme
91
+ */
92
+ public function parse( $file ) {
93
+ if ( !is_readable( $file ) )
94
+ throw new Exception ( sprintf( 'Could not parse readme: file "%1$s" does not exist or is not readable' ) );
95
+
96
+ $contents = file_get_contents( $file );
97
+ $result = $this->parse_string( $contents );
98
+
99
+ return $result;
100
+ }
101
+
102
+
103
+ protected function _before_parse( $string ) {
104
+ return $string;
105
+ }
106
+
107
+
108
+ protected function _after_parse( $string ) {
109
+ return $string;
110
+ }
111
+
112
+
113
+ /**
114
+ * Loads the contents of the specified file into the instance.
115
+ * Will not load if already loaded.
116
+ *
117
+ * @param string $file Path to the file to load from
118
+ * @return \WPRSS_Readme This instance
119
+ * @throws Exception If no path is provided
120
+ */
121
+ public function load( $file = null ) {
122
+ if ( !empty( $this->_readme ) )
123
+ return $this;
124
+
125
+ if ( is_null( $file ) )
126
+ $file = $this->get_file_path();
127
+
128
+ if ( !$file )
129
+ throw new Exception ( 'Could not load readme: file path must be provided' );
130
+
131
+ $file = $this->_before_load( $file );
132
+ $this->set_file_path( $file );
133
+ $this->_readme = $this->parse( $file );
134
+ $this->_after_load();
135
+
136
+ return $this;
137
+ }
138
+
139
+
140
+ protected function _before_load( $file ) {
141
+ return $file;
142
+ }
143
+
144
+
145
+ protected function _after_load() {
146
+ return $this;
147
+ }
148
+
149
+
150
+ /**
151
+ * Sets the path to the readme file.
152
+ * Cannot be set again once loaded.
153
+ *
154
+ * @param string $path The path of the file to set.
155
+ * @return \WPRSS_Readme This instance.
156
+ */
157
+ public function set_file_path( $path ) {
158
+ if ( !empty( $this->_readme ) )
159
+ return $this;
160
+
161
+ $this->_file_path = $path;
162
+ return $this;
163
+ }
164
+
165
+
166
+ public function get_file_path() {
167
+ return $this->_file_path;
168
+ }
169
+
170
+
171
+ public function has_data( $key = null ) {
172
+ $this->load();
173
+
174
+ $is_empty = empty( $this->_readme );
175
+ if ( is_null( $key ) )
176
+ return !$is_empty;
177
+
178
+ return !$is_empty && isset( $this->_readme->{$key} );
179
+ }
180
+
181
+
182
+ public function get_data( $key = null, $default = null ) {
183
+ $this->load();
184
+ if ( is_null( $key ) )
185
+ return $this->_readme;
186
+ return $this->has_data( $key ) ? $this->_readme->{$key} : $default;
187
+ }
188
+
189
+
190
+ public function get_changelog() {
191
+ $changelog = $this->get_data( 'changelog' );
192
+
193
+ return $changelog;
194
+ }
195
+
196
+
197
+ /**
198
+ * @return WPRSS_Readme_Parser
199
+ */
200
+ public function get_parser() {
201
+ if ( is_null( $this->_parser ) ) {
202
+ $this->_parser = new WPRSS_Readme_Parser();
203
+ $this->_prepare_parser( $this->_parser );
204
+ }
205
+
206
+ return $this->_parser;
207
+ }
208
+
209
+
210
+ /**
211
+ * @param WPRSS_Readme_Parser $parser
212
+ * @return WPRSS_Readme_Parser
213
+ */
214
+ protected function _prepare_parser( $parser ) {
215
+ return $parser;
216
+ }
217
+
218
+ }
219
+
220
+
221
+ /**
222
+ * Padding layer for the ReadmeParser library.
223
+ */
224
+ class WPRSS_Readme_Parser extends Baikonur_ReadmeParser {
225
+
226
+ public function __construct( $data = null ) {
227
+ // Implementing common mechanism
228
+ $this->_construct();
229
+ }
230
+
231
+
232
+ protected function _construct() {
233
+ // Parameterless initialization
234
+ }
235
+
236
+
237
+ /**
238
+ * @param string $string
239
+ * @return array
240
+ */
241
+ public function parse( $string ) {
242
+ $string = $this->_before_parse( $string );
243
+ $result = self::parse_readme_contents( $string );
244
+ $result = $this->_after_parse( $result );
245
+
246
+ return $result;
247
+ }
248
+
249
+ protected function _before_parse( $string ) {
250
+ return $string;
251
+ }
252
+
253
+ protected function _after_parse( $string ) {
254
+ return $string;
255
+ }
256
+ }
js/admin-licensing.js CHANGED
@@ -20,7 +20,8 @@ jQuery( document ).ready( function($) {
20
  }
21
 
22
  promise.then(function( response ) {
23
- var td = button.parent();
 
24
 
25
  // Inject the new HTML we got to update the UI and hook up the onClick handler.
26
  if (response.html !== undefined) {
@@ -30,6 +31,13 @@ jQuery( document ).ready( function($) {
30
  td.children('.button-deactivate-license').click(manage_license);
31
  }
32
 
 
 
 
 
 
 
 
33
  // There was an error.
34
  if (response.error !== undefined) {
35
  console.log('There was an error: ' + response.error);
@@ -43,7 +51,11 @@ jQuery( document ).ready( function($) {
43
 
44
  };
45
 
46
- $('.button-activate-license').click(manage_license);
47
- $('.button-deactivate-license').click(manage_license);
 
 
 
 
48
 
49
- });
20
  }
21
 
22
  promise.then(function( response ) {
23
+ var td = button.parent(),
24
+ i;
25
 
26
  // Inject the new HTML we got to update the UI and hook up the onClick handler.
27
  if (response.html !== undefined) {
31
  td.children('.button-deactivate-license').click(manage_license);
32
  }
33
 
34
+ if (response.licensedAddons) {
35
+ for (i = 0; i < response.licensedAddons.length; i++) {
36
+ $('#wprss-license-notice-' + response.licensedAddons[i]).remove();
37
+ }
38
+ $('.wprss-license-notice.updated').remove();
39
+ }
40
+
41
  // There was an error.
42
  if (response.error !== undefined) {
43
  console.log('There was an error: ' + response.error);
51
 
52
  };
53
 
54
+ // This .js is only enqueued on our settings page, so just check the tab we're on.
55
+ if ( document.location.href.search('tab=licenses_settings') > 0 ) {
56
+ $('.button-activate-license').click(manage_license);
57
+ $('.button-deactivate-license').click(manage_license);
58
+ $('.submit').remove();
59
+ }
60
 
61
+ });
languages/default.po CHANGED
@@ -1,272 +1,1460 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: wprss\n"
4
- "POT-Creation-Date: 2012-09-25 12:09+0100\n"
5
- "PO-Revision-Date: 2012-09-25 13:52+0100\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
- "X-Generator: Poedit 1.5.3\n"
12
  "X-Poedit-KeywordsList: _;__;_e\n"
13
  "X-Poedit-Basepath: ../\n"
14
  "X-Poedit-SearchPath-0: .\n"
15
 
16
- #: wp-rss-aggregator.php:152
17
- msgid "Enter feed name here (e.g. WP Mayor)"
 
18
  msgstr ""
19
 
20
- #: wp-rss-aggregator.php:394
21
- msgid "No feed items found"
22
  msgstr ""
23
 
24
- #: inc/activation.php:11
25
- msgid "This plugin requires WordPress version 3.2 or higher."
 
 
 
26
  msgstr ""
27
 
28
- #: inc/admin-options.php:45 inc/admin-options.php:88
29
- msgid "WP RSS Aggregator Settings"
30
  msgstr ""
31
 
32
- #: inc/admin-options.php:45
33
- msgid "Settings"
 
 
34
  msgstr ""
35
 
36
- #: inc/admin-options.php:67
37
- msgid "Open links behaviour"
38
  msgstr ""
39
 
40
- #: inc/admin-options.php:70
41
- msgid "Set links as"
 
 
 
42
  msgstr ""
43
 
44
- #: inc/admin-options.php:73
45
- msgid "Feed limit"
46
  msgstr ""
47
 
48
- #: inc/admin-options.php:93
49
- msgid "Save Settings"
 
 
 
50
  msgstr ""
51
 
52
- #: inc/admin-options.php:113
53
- msgid "No follow"
54
  msgstr ""
55
 
56
- #: inc/admin-options.php:114
57
- msgid "Follow"
 
 
58
  msgstr ""
59
 
60
- #: inc/admin-options.php:132
61
- msgid "Lightbox"
62
  msgstr ""
63
 
64
- #: inc/admin-options.php:133
65
- msgid "New window"
 
 
 
66
  msgstr ""
67
 
68
- #: inc/admin-options.php:134
69
- msgid "None"
 
 
 
 
 
 
70
  msgstr ""
71
 
72
- #: inc/cron-jobs.php:53
73
- msgid "Once Weekly"
 
 
 
74
  msgstr ""
75
 
76
- #: inc/custom-post-types.php:30
77
- msgid "Feed Sources"
78
  msgstr ""
79
 
80
- #: inc/custom-post-types.php:31
81
- msgid "Feed"
82
  msgstr ""
83
 
84
- #: inc/custom-post-types.php:32 inc/custom-post-types.php:34
85
- msgid "Add New Feed Source"
 
 
86
  msgstr ""
87
 
88
- #: inc/custom-post-types.php:33
89
- msgid "All Feed Sources"
90
  msgstr ""
91
 
92
- #: inc/custom-post-types.php:35
93
- msgid "Edit Feed Source"
94
  msgstr ""
95
 
96
- #: inc/custom-post-types.php:36
97
- msgid "New Feed Source"
98
  msgstr ""
99
 
100
- #: inc/custom-post-types.php:37
101
- msgid "View Feed Source"
102
  msgstr ""
103
 
104
- #: inc/custom-post-types.php:38
105
- msgid "Search Feeds"
106
  msgstr ""
107
 
108
- #: inc/custom-post-types.php:39
109
- msgid "No Feed Sources Found"
110
  msgstr ""
111
 
112
- #: inc/custom-post-types.php:40
113
- msgid "No Feed Sources Found In Trash"
 
 
114
  msgstr ""
115
 
116
- #: inc/custom-post-types.php:41
117
- msgid "RSS Aggregator"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  msgstr ""
119
 
120
- #: inc/custom-post-types.php:58 inc/custom-post-types.php:60
121
- msgid "Imported Feeds"
122
  msgstr ""
123
 
124
- #: inc/custom-post-types.php:59
125
- msgid "Imported Feed"
126
  msgstr ""
127
 
128
- #: inc/custom-post-types.php:61
129
- msgid "View Imported Feed"
130
  msgstr ""
131
 
132
- #: inc/custom-post-types.php:62
133
- msgid "Search Imported Feeds"
134
  msgstr ""
135
 
136
- #: inc/custom-post-types.php:63
137
- msgid "No Imported Feeds Found"
138
  msgstr ""
139
 
140
- #: inc/custom-post-types.php:64
141
- msgid "No Imported Feeds Found In Trash"
142
  msgstr ""
143
 
144
- #: inc/custom-post-types.php:83 inc/custom-post-types.php:135
 
 
 
 
145
  msgid "Name"
146
  msgstr ""
147
 
148
- #: inc/custom-post-types.php:84 inc/custom-post-types.php:306
149
- msgid "URL"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  msgstr ""
151
 
152
- #: inc/custom-post-types.php:85 inc/custom-post-types.php:313
153
- msgid "Description"
154
  msgstr ""
155
 
156
- #: inc/custom-post-types.php:136
157
  msgid "Permalink"
158
  msgstr ""
159
 
160
- #: inc/custom-post-types.php:137
161
  msgid "Date published"
162
  msgstr ""
163
 
164
- #: inc/custom-post-types.php:138
165
  msgid "Source"
166
  msgstr ""
167
 
168
- #: inc/custom-post-types.php:226
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  msgid "Save Feed Source"
170
  msgstr ""
171
 
172
- #: inc/custom-post-types.php:252
173
- msgid "WP RSS Aggregator Help"
174
  msgstr ""
175
 
176
- #: inc/custom-post-types.php:261
177
- msgid "Like this plugin?"
178
  msgstr ""
179
 
180
- #: inc/custom-post-types.php:270
181
- msgid "Follow us"
182
  msgstr ""
183
 
184
- #: inc/custom-post-types.php:279
185
  msgid "Feed Source Details"
186
  msgstr ""
187
 
188
- #: inc/custom-post-types.php:288
189
- msgid "Feed Preview"
 
 
 
 
 
190
  msgstr ""
191
 
192
- #: inc/custom-post-types.php:307
193
- msgid "Enter feed URL (including http://)"
194
  msgstr ""
195
 
196
- #: inc/custom-post-types.php:314
197
- msgid "A short description about this feed source (optional)"
 
198
  msgstr ""
199
 
200
- #: inc/custom-post-types.php:438
201
- msgid "Delete Permanently"
 
202
  msgstr ""
203
 
204
- #: inc/custom-post-types.php:440
205
- msgid "Move to Trash"
206
  msgstr ""
207
 
208
- #: inc/custom-post-types.php:471
 
 
 
 
209
  msgid ""
210
  "<strong>Invalid feed URL</strong> - Double check the feed source URL setting "
211
  "above."
212
  msgstr ""
213
 
214
- #: inc/custom-post-types.php:474
 
 
 
 
 
 
 
 
 
 
 
215
  msgid "No feed URL defined yet"
216
  msgstr ""
217
 
218
- #: inc/custom-post-types.php:486
 
 
 
 
219
  msgid "Need help?"
220
  msgstr ""
221
 
222
- #: inc/custom-post-types.php:488
223
  msgid "Check out the support forum"
224
  msgstr ""
225
 
226
- #: inc/custom-post-types.php:499
227
- msgid "Why not do any or all of the following"
 
 
 
 
228
  msgstr ""
229
 
230
- #: inc/custom-post-types.php:501
231
- msgid "Give it a 5 star rating on WordPress.org."
232
  msgstr ""
233
 
234
- #: inc/custom-post-types.php:502
235
- msgid "Donate a token of your appreciation."
236
  msgstr ""
237
 
238
- #: inc/custom-post-types.php:517
239
  msgid "Follow WP Mayor on Twitter."
240
  msgstr ""
241
 
242
- #: inc/custom-post-types.php:518
243
  msgid "Like WP Mayor on Facebook."
244
  msgstr ""
245
 
246
- #: inc/custom-post-types.php:535
247
- msgid "Feed source updated. "
248
  msgstr ""
249
 
250
- #: inc/custom-post-types.php:536
251
- msgid "Custom field updated."
252
  msgstr ""
253
 
254
- #: inc/custom-post-types.php:537
255
- msgid "Custom field deleted."
256
  msgstr ""
257
 
258
- #: inc/custom-post-types.php:538 inc/custom-post-types.php:544
259
- msgid "Feed source updated."
260
  msgstr ""
261
 
262
- #: inc/custom-post-types.php:540 inc/custom-post-types.php:541
263
- msgid "Feed source saved."
264
  msgstr ""
265
 
266
- #: inc/custom-post-types.php:542
267
- msgid "Feed source submitted."
268
  msgstr ""
269
 
270
- #: inc/custom-post-types.php:628
271
- msgid "Publish Feed"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
  msgstr ""
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: wprss\n"
4
+ "POT-Creation-Date: 2015-02-16 12:17+0700\n"
5
+ "PO-Revision-Date: 2015-02-16 12:17+0700\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.7.1\n"
12
  "X-Poedit-KeywordsList: _;__;_e\n"
13
  "X-Poedit-Basepath: ../\n"
14
  "X-Poedit-SearchPath-0: .\n"
15
 
16
+ #: includes/OPML.php:42
17
+ msgid ""
18
+ "An error occured: The file might not be a valid OPML file or is corrrupt. "
19
  msgstr ""
20
 
21
+ #: includes/admin-addons.php:13
22
+ msgid "Excerpts & Thumbnails"
23
  msgstr ""
24
 
25
+ #: includes/admin-addons.php:14
26
+ msgid ""
27
+ "Adds the ability to display thumbnails and excerpts. Perfect for adding some "
28
+ "life and color to your feed item display. For more flexibility Feed to Post "
29
+ "is a better option."
30
  msgstr ""
31
 
32
+ #: includes/admin-addons.php:20 includes/admin-welcome.php:148
33
+ msgid "Categories"
34
  msgstr ""
35
 
36
+ #: includes/admin-addons.php:21
37
+ msgid ""
38
+ "Assign categories to your feed sources. Then display a particular category "
39
+ "or multiple categories on a post or page via shortcodes."
40
  msgstr ""
41
 
42
+ #: includes/admin-addons.php:27 includes/admin-welcome.php:149
43
+ msgid "Keyword Filtering"
44
  msgstr ""
45
 
46
+ #: includes/admin-addons.php:28
47
+ msgid ""
48
+ "Import feeds that contain specific keywords in either the title or their "
49
+ "content. Control what gets imported to your blog. You can use keywords, "
50
+ "keyphrases and categories."
51
  msgstr ""
52
 
53
+ #: includes/admin-addons.php:34 includes/admin-welcome.php:146
54
+ msgid "Feed to Post"
55
  msgstr ""
56
 
57
+ #: includes/admin-addons.php:35
58
+ msgid ""
59
+ "Allows you to import feed items into posts or any other custom post type "
60
+ "that you have created. Takes WP RSS Aggregator to a whole new level of "
61
+ "flexibility."
62
  msgstr ""
63
 
64
+ #: includes/admin-addons.php:41 includes/admin-welcome.php:150
65
+ msgid "Full Text RSS Feeds"
66
  msgstr ""
67
 
68
+ #: includes/admin-addons.php:42
69
+ msgid ""
70
+ "This add-ons provides the connectivity to our Full Text Premium service, "
71
+ "which gives you unlimited feed items returned per feed source."
72
  msgstr ""
73
 
74
+ #: includes/admin-addons.php:48 includes/admin-welcome.php:151
75
+ msgid "WordAi"
76
  msgstr ""
77
 
78
+ #: includes/admin-addons.php:49
79
+ msgid ""
80
+ "Allows you to spin the content for posts imported by Feed to Post using "
81
+ "WordAi. Cleverly rewrite your posts without changing their meaning and "
82
+ "maintaining human readability."
83
  msgstr ""
84
 
85
+ #: includes/admin-addons.php:59 includes/admin.php:43
86
+ msgid "Add-Ons"
87
+ msgstr ""
88
+
89
+ #: includes/admin-addons.php:60
90
+ msgid ""
91
+ "The following Add-ons are available to increase the functionality of the WP "
92
+ "RSS Aggregator plugin."
93
  msgstr ""
94
 
95
+ #: includes/admin-addons.php:61
96
+ msgid ""
97
+ "Each Add-on can be installed as a separate plugin. Note that activating the "
98
+ "Feed to Post plugin will deactivate the Categories and Excerpts & Thumbnails "
99
+ "add-ons."
100
  msgstr ""
101
 
102
+ #: includes/admin-addons.php:77
103
+ msgid "Installed"
104
  msgstr ""
105
 
106
+ #: includes/admin-addons.php:79
107
+ msgid "Purchase & Install"
108
  msgstr ""
109
 
110
+ #: includes/admin-ajax-notice.php:34
111
+ msgid ""
112
+ "Did you know that you can get more RSS features? Excerpts, thumbnails, "
113
+ "keyword filtering, importing into posts and more... "
114
  msgstr ""
115
 
116
+ #: includes/admin-ajax-notice.php:35
117
+ msgid "Check out the"
118
  msgstr ""
119
 
120
+ #: includes/admin-ajax-notice.php:35
121
+ msgid "extensions"
122
  msgstr ""
123
 
124
+ #: includes/admin-ajax-notice.php:35
125
+ msgid "page."
126
  msgstr ""
127
 
128
+ #: includes/admin-ajax-notice.php:36 includes/licensing.php:268
129
+ msgid "Dismiss this notification"
130
  msgstr ""
131
 
132
+ #: includes/admin-dashboard.php:25 includes/admin-dashboard.php:26
133
+ msgid "Welcome to WP RSS Aggregator"
134
  msgstr ""
135
 
136
+ #: includes/admin-debugging.php:103
137
+ msgid "Update All Feeds Now"
138
  msgstr ""
139
 
140
+ #: includes/admin-debugging.php:104
141
+ msgid ""
142
+ "Click the blue button to update all active feed items now. This will check "
143
+ "all feed sources for any new feed items."
144
  msgstr ""
145
 
146
+ #: includes/admin-debugging.php:105
147
+ msgid "Existing feed items will not be modified."
148
+ msgstr ""
149
+
150
+ #: includes/admin-debugging.php:107
151
+ msgid ""
152
+ "<strong>Note:</strong> This might take more than a few seconds if you have "
153
+ "many feed sources."
154
+ msgstr ""
155
+
156
+ #: includes/admin-debugging.php:112
157
+ msgid "Update all feeds"
158
+ msgstr ""
159
+
160
+ #: includes/admin-debugging.php:126
161
+ msgid "Delete and Re-import Feeds"
162
+ msgstr ""
163
+
164
+ #: includes/admin-debugging.php:127
165
+ msgid ""
166
+ "Click the red button to delete all imported feed items and re-import them."
167
+ msgstr ""
168
+
169
+ #: includes/admin-debugging.php:128
170
+ msgid ""
171
+ "<em><strong>Note:</strong> This is a server-intensive process and should "
172
+ "only be used when instructed to by support staff.</em>"
173
+ msgstr ""
174
+
175
+ #: includes/admin-debugging.php:133
176
+ msgid "Delete and Re-import all feeds"
177
+ msgstr ""
178
+
179
+ #: includes/admin-debugging.php:147 includes/admin-debugging.php:154
180
+ msgid "Restore Default Settings"
181
+ msgstr ""
182
+
183
+ #: includes/admin-debugging.php:148
184
+ msgid "Click the red button to reset the plugin settings to default."
185
+ msgstr ""
186
+
187
+ #: includes/admin-debugging.php:149
188
+ msgid ""
189
+ "<em><strong>Note:</strong> This cannot be undone. Once the settings have "
190
+ "been reset, your old settings cannot be restored.</em>"
191
  msgstr ""
192
 
193
+ #: includes/admin-debugging.php:168
194
+ msgid "Error Log"
195
  msgstr ""
196
 
197
+ #: includes/admin-debugging.php:174
198
+ msgid "Clear log"
199
  msgstr ""
200
 
201
+ #: includes/admin-debugging.php:202 includes/admin.php:42
202
+ msgid "Debugging"
203
  msgstr ""
204
 
205
+ #: includes/admin-debugging.php:252
206
+ msgid "Feeds are being updated in the background."
207
  msgstr ""
208
 
209
+ #: includes/admin-debugging.php:261
210
+ msgid "Feeds deleted and are being re-imported in the background."
211
  msgstr ""
212
 
213
+ #: includes/admin-debugging.php:271
214
+ msgid "The error log has been cleared."
215
  msgstr ""
216
 
217
+ #: includes/admin-debugging.php:281
218
+ msgid "The plugin settings have been reset to default."
219
+ msgstr ""
220
+
221
+ #: includes/admin-display.php:20 includes/admin-display.php:212
222
  msgid "Name"
223
  msgstr ""
224
 
225
+ #: includes/admin-display.php:27
226
+ msgid "State"
227
+ msgstr ""
228
+
229
+ #: includes/admin-display.php:28
230
+ msgid "Updates"
231
+ msgstr ""
232
+
233
+ #: includes/admin-display.php:48
234
+ msgid ""
235
+ "This feed source experienced an error during the last feed fetch or "
236
+ "validation check. Re-check the feed source URL or check the Error Log in the "
237
+ "Debugging page for more details."
238
+ msgstr ""
239
+
240
+ #: includes/admin-display.php:89 includes/admin-heartbeat.php:53
241
+ msgid "None"
242
+ msgstr ""
243
+
244
+ #: includes/admin-display.php:91 includes/admin-heartbeat.php:50
245
+ #: includes/admin-metaboxes.php:466
246
+ msgid "Paused"
247
+ msgstr ""
248
+
249
+ #: includes/admin-display.php:98
250
+ msgid "Next update:"
251
+ msgstr ""
252
+
253
+ #: includes/admin-display.php:106
254
+ msgid "Last updated:"
255
+ msgstr ""
256
+
257
+ #: includes/admin-display.php:107 includes/feed-display.php:153
258
+ #, php-format
259
+ msgid "%1$s ago"
260
+ msgstr ""
261
+
262
+ #: includes/admin-display.php:109
263
+ #, php-format
264
+ msgid ""
265
+ "Last update imported: <code class=\"last-update-imported\">%1$d</code> items"
266
  msgstr ""
267
 
268
+ #: includes/admin-display.php:124
269
+ msgid "Updating feed source"
270
  msgstr ""
271
 
272
+ #: includes/admin-display.php:213 includes/feed-blacklist.php:322
273
  msgid "Permalink"
274
  msgstr ""
275
 
276
+ #: includes/admin-display.php:214
277
  msgid "Date published"
278
  msgstr ""
279
 
280
+ #: includes/admin-display.php:215
281
  msgid "Source"
282
  msgstr ""
283
 
284
+ #: includes/admin-display.php:304
285
+ msgid "Feed source updated. "
286
+ msgstr ""
287
+
288
+ #: includes/admin-display.php:305
289
+ msgid "Custom field updated."
290
+ msgstr ""
291
+
292
+ #: includes/admin-display.php:306
293
+ msgid "Custom field deleted."
294
+ msgstr ""
295
+
296
+ #: includes/admin-display.php:307 includes/admin-display.php:313
297
+ msgid "Feed source updated."
298
+ msgstr ""
299
+
300
+ #: includes/admin-display.php:309 includes/admin-display.php:310
301
+ msgid "Feed source saved."
302
+ msgstr ""
303
+
304
+ #: includes/admin-display.php:311
305
+ msgid "Feed source submitted."
306
+ msgstr ""
307
+
308
+ #: includes/admin-display.php:338
309
+ #, php-format
310
+ msgid "ID: %1$s"
311
+ msgstr ""
312
+
313
+ #: includes/admin-display.php:352
314
+ msgid "View Items"
315
+ msgstr ""
316
+
317
+ #: includes/admin-display.php:355
318
+ msgid "Fetch Items"
319
+ msgstr ""
320
+
321
+ #: includes/admin-display.php:358
322
+ msgid "Delete Items"
323
+ msgstr ""
324
+
325
+ #: includes/admin-display.php:359
326
+ msgid "Delete feed items imported by this feed source"
327
+ msgstr ""
328
+
329
+ #: includes/admin-display.php:529
330
+ msgid "Publish Feed"
331
+ msgstr ""
332
+
333
+ #: includes/admin-editor.php:87
334
+ msgid ""
335
+ "Hold Ctrl or Mac Command key when clicking to select more than one feed "
336
+ "source."
337
+ msgstr ""
338
+
339
+ #: includes/admin-editor.php:97 includes/custom-post-types.php:21
340
+ #: includes/custom-post-types.php:24
341
+ msgid "Feed Sources"
342
+ msgstr ""
343
+
344
+ #: includes/admin-editor.php:99
345
+ msgid "All feed sources"
346
+ msgstr ""
347
+
348
+ #: includes/admin-editor.php:101
349
+ msgid "Choose the feed source to display:"
350
+ msgstr ""
351
+
352
+ #: includes/admin-editor.php:122
353
+ msgid "Exclude:"
354
+ msgstr ""
355
+
356
+ #: includes/admin-editor.php:124
357
+ msgid "Choose the feed sources to exclude:"
358
+ msgstr ""
359
+
360
+ #: includes/admin-editor.php:130
361
+ msgid "Feed Limit:"
362
+ msgstr ""
363
+
364
+ #: includes/admin-editor.php:131
365
+ msgid "Ignore"
366
+ msgstr ""
367
+
368
+ #: includes/admin-editor.php:139
369
+ msgid "Add shortcode"
370
+ msgstr ""
371
+
372
+ #: includes/admin-help.php:13 includes/admin.php:44
373
+ msgid "Help & Support"
374
+ msgstr ""
375
+
376
+ #: includes/admin-help.php:14 includes/admin.php:112
377
+ msgid "Documentation"
378
+ msgstr ""
379
+
380
+ #: includes/admin-help.php:15
381
+ msgid ""
382
+ "In the <a href=\"http://www.wprssaggregator.com/documentation/"
383
+ "\">documentation area</a> on the WP RSS Aggregator website you will find "
384
+ "comprehensive details on how to use the core plugin and all the add-ons.\n"
385
+ "\t\t\t\t\n"
386
+ "\t\t\t\tThere are also some videos to help you make a quick start to setting "
387
+ "up and enjoying this plugin."
388
+ msgstr ""
389
+
390
+ #: includes/admin-help.php:18
391
+ msgid "Frequently Asked Questions (FAQ)"
392
+ msgstr ""
393
+
394
+ #: includes/admin-help.php:19
395
+ msgid ""
396
+ "If after going through the documentation you still have questions, please "
397
+ "take a look at the <a href=\"http://www.wprssaggregator.com/faq/\">FAQ page</"
398
+ "a> on the site, we set this up purposely to answer the most commonly asked "
399
+ "questions by our users."
400
+ msgstr ""
401
+
402
+ #: includes/admin-help.php:21
403
+ msgid "Support Forums - Core (free version) Plugin Users Only"
404
+ msgstr ""
405
+
406
+ #: includes/admin-help.php:22
407
+ msgid ""
408
+ "If you're using the free version of the plugin found on WordPress.org, you "
409
+ "can ask questions on the <a href=\"http://wordpress.org/support/plugin/wp-"
410
+ "rss-aggregator\">support forum</a>."
411
+ msgstr ""
412
+
413
+ #: includes/admin-help.php:23
414
+ msgid "Email Ticketing System - Premium Add-on Users Only"
415
+ msgstr ""
416
+
417
+ #: includes/admin-help.php:24
418
+ msgid ""
419
+ "If you still can't find an answer to your query after reading the "
420
+ "documentation and going through the FAQ, just <a href=\"http://www."
421
+ "wprssaggregator.com/contact/\">open a support request ticket</a>.\n"
422
+ "\t\t\t\t\tWe'll be happy to help you out."
423
+ msgstr ""
424
+
425
+ #: includes/admin-help.php:717
426
+ msgid ""
427
+ "Could not enqueue tooltip content: the queue method is not a valid callable."
428
+ msgstr ""
429
+
430
+ #: includes/admin-import-export.php:60
431
+ #, php-format
432
+ msgid "Successfully imported <code>%1$s</code> feed sources."
433
+ msgstr ""
434
+
435
+ #: includes/admin-import-export.php:116
436
+ msgid "All options are exported successfully."
437
+ msgstr ""
438
+
439
+ #: includes/admin-import-export.php:127
440
+ msgid "All options are restored successfully."
441
+ msgstr ""
442
+
443
+ #: includes/admin-import-export.php:138
444
+ msgid "Invalid file or file size too big."
445
+ msgstr ""
446
+
447
+ #: includes/admin-import-export.php:192
448
+ msgid "Bulk Feed Import"
449
+ msgstr ""
450
+
451
+ #: includes/admin-import-export.php:193
452
+ msgid ""
453
+ "Import multiple feed sources at once, by entering the name and URLs of your "
454
+ "feeds below."
455
+ msgstr ""
456
+
457
+ #: includes/admin-import-export.php:194
458
+ msgid "Separate the name and the URL using a comma on each line:"
459
+ msgstr ""
460
+
461
+ #: includes/admin-import-export.php:195
462
+ msgid "Feed Name, http://www.myfeed.com"
463
+ msgstr ""
464
+
465
+ #: includes/admin-import-export.php:201
466
+ msgid "Bulk Import"
467
+ msgstr ""
468
+
469
+ #: includes/admin-import-export.php:206
470
+ msgid "Import & Export Settings"
471
+ msgstr ""
472
+
473
+ #: includes/admin-import-export.php:208 includes/admin-import-export.php:215
474
+ msgid "Export Settings"
475
+ msgstr ""
476
+
477
+ #: includes/admin-import-export.php:209
478
+ msgid ""
479
+ "Click the <strong>Export Settings</strong> button to generate a file "
480
+ "containing all the settings used by WP RSS Aggregator"
481
+ msgstr ""
482
+
483
+ #: includes/admin-import-export.php:210
484
+ msgid ""
485
+ "After exporting, you can either use the backup file to restore your settings "
486
+ "to this site or to another WordPress site."
487
+ msgstr ""
488
+
489
+ #: includes/admin-import-export.php:219 includes/admin-import-export.php:227
490
+ msgid "Import Settings"
491
+ msgstr ""
492
+
493
+ #: includes/admin-import-export.php:220
494
+ msgid "Click the <strong>Choose file</strong> button and choose a backup file."
495
+ msgstr ""
496
+
497
+ #: includes/admin-import-export.php:221
498
+ msgid ""
499
+ "Press the <strong>Import Settings</strong> button, and WordPress will do the "
500
+ "rest for you."
501
+ msgstr ""
502
+
503
+ #: includes/admin-import-export.php:231
504
+ msgid "Importing/Exporting Feed Sources"
505
+ msgstr ""
506
+
507
+ #: includes/admin-import-export.php:232
508
+ #, php-format
509
+ msgid ""
510
+ "To import/export your feed sources, please use the standard WordPress <a "
511
+ "href=\"%1$simport.php\">Import</a> and <a href=\"%1$sexport.php\">Export</a> "
512
+ "functionality."
513
+ msgstr ""
514
+
515
+ #: includes/admin-import-export.php:233
516
+ #, php-format
517
+ msgid ""
518
+ "On the <a href=\"%1$sexport.php\">Export</a> page, check the <strong>Feed "
519
+ "Sources</strong> radio button and click the <strong>Download Export File</"
520
+ "strong> button. WordPress will then create an XML file containing all the "
521
+ "feed sources."
522
+ msgstr ""
523
+
524
+ #: includes/admin-import-export.php:234
525
+ #, php-format
526
+ msgid ""
527
+ "On the <a href=\"%1$simport.php\">Import</a> page, choose the previously "
528
+ "created file and click the <strong>Upload file and import</strong> button."
529
+ msgstr ""
530
+
531
+ #: includes/admin-log.php:236
532
+ msgid "Log level threshold"
533
+ msgstr ""
534
+
535
+ #: includes/admin-metaboxes.php:20
536
  msgid "Save Feed Source"
537
  msgstr ""
538
 
539
+ #: includes/admin-metaboxes.php:29
540
+ msgid "Feed Preview"
541
  msgstr ""
542
 
543
+ #: includes/admin-metaboxes.php:38
544
+ msgid "Feed Processing"
545
  msgstr ""
546
 
547
+ #: includes/admin-metaboxes.php:48
548
+ msgid "Like This Plugin?"
549
  msgstr ""
550
 
551
+ #: includes/admin-metaboxes.php:58
552
  msgid "Feed Source Details"
553
  msgstr ""
554
 
555
+ #: includes/admin-metaboxes.php:91 includes/opml-importer.php:196
556
+ #: includes/opml-importer.php:227
557
+ msgid "URL"
558
+ msgstr ""
559
+
560
+ #: includes/admin-metaboxes.php:99
561
+ msgid "Limit"
562
  msgstr ""
563
 
564
+ #: includes/admin-metaboxes.php:105
565
+ msgid "Link to enclosure"
566
  msgstr ""
567
 
568
+ #: includes/admin-metaboxes.php:217 includes/admin-metaboxes.php:470
569
+ #: includes/admin-options.php:809 includes/admin-options.php:911
570
+ msgid "Default"
571
  msgstr ""
572
 
573
+ #: includes/admin-metaboxes.php:384
574
+ #, php-format
575
+ msgid "Latest %1$s feed items out of %2$s available from %3$s"
576
  msgstr ""
577
 
578
+ #: includes/admin-metaboxes.php:391 includes/scripts.php:81
579
+ msgid "ago"
580
  msgstr ""
581
 
582
+ #: includes/admin-metaboxes.php:393
583
+ msgid "No Date"
584
+ msgstr ""
585
+
586
+ #: includes/admin-metaboxes.php:414
587
  msgid ""
588
  "<strong>Invalid feed URL</strong> - Double check the feed source URL setting "
589
  "above."
590
  msgstr ""
591
 
592
+ #: includes/admin-metaboxes.php:418
593
+ #, php-format
594
+ msgid ""
595
+ "Not sure where to find the RSS feed on a website? <a target=\"_blank\" href="
596
+ "\"%1$s\">Click here</a> for a visual guide. "
597
+ msgstr ""
598
+
599
+ #: includes/admin-metaboxes.php:426
600
+ msgid "Force the feed"
601
+ msgstr ""
602
+
603
+ #: includes/admin-metaboxes.php:435
604
  msgid "No feed URL defined yet"
605
  msgstr ""
606
 
607
+ #: includes/admin-metaboxes.php:465
608
+ msgid "Active"
609
+ msgstr ""
610
+
611
+ #: includes/admin-metaboxes.php:590
612
  msgid "Need help?"
613
  msgstr ""
614
 
615
+ #: includes/admin-metaboxes.php:592
616
  msgid "Check out the support forum"
617
  msgstr ""
618
 
619
+ #: includes/admin-metaboxes.php:595
620
+ msgid "Suggest a new feature"
621
+ msgstr ""
622
+
623
+ #: includes/admin-metaboxes.php:608
624
+ msgid "Give it a 5 star rating on WordPress.org"
625
  msgstr ""
626
 
627
+ #: includes/admin-metaboxes.php:609
628
+ msgid "Donate a token of your appreciation"
629
  msgstr ""
630
 
631
+ #: includes/admin-metaboxes.php:613
632
+ msgid "Check out the Premium Extensions:"
633
  msgstr ""
634
 
635
+ #: includes/admin-metaboxes.php:634
636
  msgid "Follow WP Mayor on Twitter."
637
  msgstr ""
638
 
639
+ #: includes/admin-metaboxes.php:635
640
  msgid "Like WP Mayor on Facebook."
641
  msgstr ""
642
 
643
+ #: includes/admin-options.php:56
644
+ msgid "General plugin settings"
645
  msgstr ""
646
 
647
+ #: includes/admin-options.php:57
648
+ msgid "General display settings"
649
  msgstr ""
650
 
651
+ #: includes/admin-options.php:58
652
+ msgid "Source display settings"
653
  msgstr ""
654
 
655
+ #: includes/admin-options.php:59
656
+ msgid "Date display settings"
657
  msgstr ""
658
 
659
+ #: includes/admin-options.php:60
660
+ msgid "Styles"
661
  msgstr ""
662
 
663
+ #: includes/admin-options.php:70
664
+ msgid "Limit feed items by age"
665
  msgstr ""
666
 
667
+ #: includes/admin-options.php:74
668
+ msgid "Limit feed items stored"
669
+ msgstr ""
670
+
671
+ #: includes/admin-options.php:78
672
+ msgid "Limit feed items per feed"
673
+ msgstr ""
674
+
675
+ #: includes/admin-options.php:82
676
+ msgid "Feed processing interval"
677
+ msgstr ""
678
+
679
+ #: includes/admin-options.php:86
680
+ msgid "Custom feed URL"
681
+ msgstr ""
682
+
683
+ #: includes/admin-options.php:90
684
+ msgid "Custom feed Title"
685
+ msgstr ""
686
+
687
+ #: includes/admin-options.php:94
688
+ msgid "Custom feed limit"
689
+ msgstr ""
690
+
691
+ #: includes/admin-options.php:98
692
+ msgid "Anonymous tracking"
693
+ msgstr ""
694
+
695
+ #: includes/admin-options.php:106
696
+ msgid "Link title"
697
+ msgstr ""
698
+
699
+ #: includes/admin-options.php:110
700
+ msgid "Title maximum length"
701
+ msgstr ""
702
+
703
+ #: includes/admin-options.php:118
704
+ msgid "Show authors"
705
+ msgstr ""
706
+
707
+ #: includes/admin-options.php:122
708
+ msgid "For video feed items use"
709
+ msgstr ""
710
+
711
+ #: includes/admin-options.php:126
712
+ msgid "Pagination type"
713
+ msgstr ""
714
+
715
+ #: includes/admin-options.php:130
716
+ msgid "Feed display limit"
717
+ msgstr ""
718
+
719
+ #: includes/admin-options.php:134
720
+ msgid "Open links behaviour"
721
+ msgstr ""
722
+
723
+ #: includes/admin-options.php:138
724
+ msgid "Set links as nofollow"
725
+ msgstr ""
726
+
727
+ #: includes/admin-options.php:146
728
+ msgid "Show source"
729
+ msgstr ""
730
+
731
+ #: includes/admin-options.php:150
732
+ msgid "Text preceding source"
733
+ msgstr ""
734
+
735
+ #: includes/admin-options.php:154
736
+ msgid "Link source"
737
+ msgstr ""
738
+
739
+ #: includes/admin-options.php:162
740
+ msgid "Show date"
741
+ msgstr ""
742
+
743
+ #: includes/admin-options.php:166
744
+ msgid "Text preceding date"
745
+ msgstr ""
746
+
747
+ #: includes/admin-options.php:170
748
+ msgid "Date format"
749
+ msgstr ""
750
+
751
+ #: includes/admin-options.php:174
752
+ msgid "Time ago format"
753
+ msgstr ""
754
+
755
+ #: includes/admin-options.php:181
756
+ msgid "Disable Styles"
757
+ msgstr ""
758
+
759
+ #: includes/admin-options.php:343 includes/admin.php:41
760
+ msgid "WP RSS Aggregator Settings"
761
+ msgstr ""
762
+
763
+ #: includes/admin-options.php:353
764
+ msgid "General"
765
+ msgstr ""
766
+
767
+ #: includes/admin-options.php:357
768
+ msgid "Licenses"
769
+ msgstr ""
770
+
771
+ #: includes/admin-options.php:397
772
+ msgid "Save Settings"
773
+ msgstr ""
774
+
775
+ #: includes/admin-options.php:411
776
+ msgid "These are the general settings for WP RSS Aggregator."
777
+ msgstr ""
778
+
779
+ #: includes/admin-options.php:420
780
+ msgid ""
781
+ "In this section you can find some general options that control how the feed "
782
+ "items are displayed."
783
+ msgstr ""
784
+
785
+ #: includes/admin-options.php:430
786
+ msgid "Options that control how the feed item's source is displayed."
787
+ msgstr ""
788
+
789
+ #: includes/admin-options.php:439
790
+ msgid "Options that control how the feed item's date is displayed."
791
+ msgstr ""
792
+
793
+ #: includes/admin-options.php:448
794
+ msgid ""
795
+ "If you would like to disable all styles used in this plugin, tick the "
796
+ "checkbox."
797
+ msgstr ""
798
+
799
+ #: includes/admin-options.php:457
800
+ msgid "Set your security reset code, in case of any errors."
801
+ msgstr ""
802
+
803
+ #: includes/admin-options.php:466
804
+ msgid "Participate in helping us make the plugin better."
805
+ msgstr ""
806
+
807
+ #: includes/admin-options.php:493
808
+ msgid "Original page link"
809
+ msgstr ""
810
+
811
+ #: includes/admin-options.php:494
812
+ msgid "Embedded video player link"
813
+ msgstr ""
814
+
815
+ #: includes/admin-options.php:508
816
+ msgid "This will not affect already imported feed items."
817
+ msgstr ""
818
+
819
+ #: includes/admin-options.php:523
820
+ msgid "Lightbox"
821
+ msgstr ""
822
+
823
+ #: includes/admin-options.php:524 includes/update.php:195
824
+ msgid "New window"
825
+ msgstr ""
826
+
827
+ #: includes/admin-options.php:525
828
+ msgid "Self"
829
+ msgstr ""
830
+
831
+ #: includes/admin-options.php:563
832
+ msgid "PHP Date Format Reference"
833
+ msgstr ""
834
+
835
+ #: includes/admin-options.php:591 includes/admin-options.php:702
836
+ msgid "No limit"
837
+ msgstr ""
838
+
839
+ #: includes/admin-options.php:673
840
+ msgid "\"Older posts\" and \"Newer posts\" links"
841
+ msgstr ""
842
+
843
+ #: includes/admin-options.php:674
844
+ msgid "Page numbers with \"Next\" and \"Previous\" page links"
845
+ msgstr ""
846
+
847
+ #: includes/admin-options.php:736
848
+ msgid "No Limit"
849
+ msgstr ""
850
+
851
+ #: includes/admin-options.php:835
852
+ msgid "Generate Random Code"
853
+ msgstr ""
854
+
855
+ #: includes/admin-options.php:840
856
+ msgid ""
857
+ "Enter the code to use to securely reset the plugin and deactivate it. Be "
858
+ "sure to save this code somewhere safe."
859
+ msgstr ""
860
+
861
+ #: includes/admin-options.php:846
862
+ msgid ""
863
+ "Leave this empty to disable the secure reset function.<br/>\n"
864
+ " You use this code by adding any of the following to any URL on "
865
+ "your site."
866
+ msgstr ""
867
+
868
+ #: includes/admin-options.php:849
869
+ msgid "Resets your WP RSS Aggregator settings"
870
+ msgstr ""
871
+
872
+ #: includes/admin-options.php:850
873
+ msgid "Deactivates WP RSS Aggregator"
874
+ msgstr ""
875
+
876
+ #: includes/admin-options.php:851
877
+ msgid "Does both of the above"
878
+ msgstr ""
879
+
880
+ #: includes/admin-options.php:855
881
+ msgid ""
882
+ "Use the above actions only when absolutely necessary, or when instructed to "
883
+ "by support staff."
884
+ msgstr ""
885
+
886
+ #: includes/admin-options.php:871
887
+ msgid ""
888
+ "Please help us improve WP RSS Aggregator by allowing us to gather anonymous "
889
+ "usage statistics. No sensitive data is collected."
890
+ msgstr ""
891
+
892
+ #: includes/admin-options.php:926
893
+ msgid "now"
894
+ msgstr ""
895
+
896
+ #: includes/admin-statistics.php:149
897
+ msgid "<b>WP RSS Aggregator:</b> Data report sent!"
898
+ msgstr ""
899
+
900
+ #: includes/admin-welcome.php:75
901
+ #, php-format
902
+ msgid "Welcome to WP RSS Aggregator %1$s!"
903
+ msgstr ""
904
+
905
+ #: includes/admin-welcome.php:77
906
+ msgid "Thank you for upgrading to the latest version!"
907
+ msgstr ""
908
+
909
+ #: includes/admin-welcome.php:85
910
+ msgid "What's New?"
911
+ msgstr ""
912
+
913
+ #: includes/admin-welcome.php:109
914
+ msgid "Bulk Adding Feed Sources"
915
+ msgstr ""
916
+
917
+ #: includes/admin-welcome.php:112
918
+ #, php-format
919
+ msgid ""
920
+ "The new bulk adding option saves you time by allowing you to enter your feed "
921
+ "names and URLs all at once.\n"
922
+ "\t\t\t\t\t\t\t\t\t\tSimply type in or paste your feed sources, and with the "
923
+ "press of a button, your feed sources will instantly be created!\n"
924
+ "\t\t\t\t\t\t\t\t\t\tTry it now from the <a href=\"%1$s\">Import &amp; "
925
+ "Export</a> page."
926
+ msgstr ""
927
+
928
+ #: includes/admin-welcome.php:117
929
+ msgid "Feed Item Blacklist"
930
+ msgstr ""
931
+
932
+ #: includes/admin-welcome.php:121
933
+ msgid "Trash undesired items"
934
+ msgstr ""
935
+
936
+ #: includes/admin-welcome.php:122
937
+ msgid ""
938
+ "Did a feed import an item that you do not wish to keep? Up till now, "
939
+ "<strong>WP RSS Aggregator</strong>only allowed you to trash the item and "
940
+ "keep it in your trash."
941
+ msgstr ""
942
+
943
+ #: includes/admin-welcome.php:127
944
+ msgid "Blacklist Trashed Items"
945
+ msgstr ""
946
+
947
+ #: includes/admin-welcome.php:128
948
+ msgid ""
949
+ "Permanently deleting the item will cause it to be re-imported. Using the new "
950
+ "<strong>Delete Permanently &amp; Blacklist</strong> option, the feed item is "
951
+ "deleted and added to the <strong>Blacklist</strong>."
952
+ msgstr ""
953
+
954
+ #: includes/admin-welcome.php:134
955
+ msgid "The Blacklist"
956
+ msgstr ""
957
+
958
+ #: includes/admin-welcome.php:135
959
+ msgid ""
960
+ "This is your list of unwanted feed item links. Any item in this list will be "
961
+ "ignored by <strong>WP RSS Aggregator</strong> in the future, meaning it "
962
+ "won't be imported from any of your feed sources.and added to the "
963
+ "<strong>Blacklist</strong>."
964
+ msgstr ""
965
+
966
+ #: includes/admin-welcome.php:143
967
+ msgid "Check out our add-ons:"
968
+ msgstr ""
969
+
970
+ #: includes/admin-welcome.php:147
971
+ msgid "Excerpts &amp; Thumbnails"
972
+ msgstr ""
973
+
974
+ #: includes/admin-welcome.php:154
975
+ #, php-format
976
+ msgid ""
977
+ "More information about add-ons can be found on our website <a href=\"%1$s\">"
978
+ "%2$s</a>"
979
+ msgstr ""
980
+
981
+ #: includes/admin-welcome.php:158
982
+ #, php-format
983
+ msgid "Changelog for v%1$s"
984
+ msgstr ""
985
+
986
+ #: includes/admin-welcome.php:167
987
+ #, php-format
988
+ msgid ""
989
+ "Need functionality not already available in core or the add-ons? You can <a "
990
+ "href=\"%1$s\">suggest new features</a>!"
991
+ msgstr ""
992
+
993
+ #: includes/admin-welcome.php:178
994
+ msgid ""
995
+ "Fetch RSS feed excerpts to your blog and add thumbnails! Perfect for adding "
996
+ "some life and color to your feeds."
997
+ msgstr ""
998
+
999
+ #: includes/admin-welcome.php:188
1000
+ msgid ""
1001
+ "Organize your feeds into custom categories. Filter feed items by category "
1002
+ "and make custom WordPress feeds for specific categories."
1003
+ msgstr ""
1004
+
1005
+ #: includes/admin-welcome.php:198
1006
+ msgid ""
1007
+ "Import and store feeds that contain specific keywords in either the title or "
1008
+ "their content. Control what gets imported to your blog."
1009
+ msgstr ""
1010
+
1011
+ #: includes/admin-welcome.php:208
1012
+ msgid "Go to WP RSS Aggregator settings"
1013
+ msgstr ""
1014
+
1015
+ #: includes/admin.php:40
1016
+ msgid "Export & Import Settings"
1017
+ msgstr ""
1018
+
1019
+ #: includes/admin.php:40
1020
+ msgid "Import & Export"
1021
+ msgstr ""
1022
+
1023
+ #: includes/admin.php:41 includes/admin.php:111
1024
+ msgid "Settings"
1025
+ msgstr ""
1026
+
1027
+ #: includes/admin.php:94
1028
+ msgid "Name this feed (e.g. WP Mayor)"
1029
+ msgstr ""
1030
+
1031
+ #: includes/admin.php:139
1032
+ #, php-format
1033
+ msgid ""
1034
+ "<b>WP RSS Aggregator</b>: There are saved licenses that have not yet been "
1035
+ "activated. Go to the <a href=\"%1$s\">License page</a> to activate them."
1036
+ msgstr ""
1037
+
1038
+ #: includes/cpt-feeds.php:82
1039
+ #, php-format
1040
+ msgid "%1$s &raquo; %2$s Feed"
1041
+ msgstr ""
1042
+
1043
+ #: includes/cpt-feeds.php:83
1044
+ #, php-format
1045
+ msgid "<link rel=\"%1$s\" type=\"%2$s\" title=\"%3$s\" href=\"%4$s\" />\n"
1046
+ msgstr ""
1047
+
1048
+ #: includes/cron-jobs.php:64
1049
+ msgid "Once every five minutes"
1050
+ msgstr ""
1051
+
1052
+ #: includes/cron-jobs.php:68
1053
+ msgid "Once every ten minutes"
1054
+ msgstr ""
1055
+
1056
+ #: includes/cron-jobs.php:72
1057
+ msgid "Once every fifteen minutes"
1058
+ msgstr ""
1059
+
1060
+ #: includes/cron-jobs.php:76
1061
+ msgid "Once every thirty minutes"
1062
+ msgstr ""
1063
+
1064
+ #: includes/cron-jobs.php:80
1065
+ msgid "Once every two hours"
1066
+ msgstr ""
1067
+
1068
+ #: includes/custom-post-types.php:22
1069
+ msgid "Feed Source"
1070
+ msgstr ""
1071
+
1072
+ #: includes/custom-post-types.php:23
1073
+ msgid "Add New"
1074
+ msgstr ""
1075
+
1076
+ #: includes/custom-post-types.php:25
1077
+ msgid "Add New Feed Source"
1078
+ msgstr ""
1079
+
1080
+ #: includes/custom-post-types.php:26
1081
+ msgid "Edit Feed Source"
1082
+ msgstr ""
1083
+
1084
+ #: includes/custom-post-types.php:27
1085
+ msgid "New Feed Source"
1086
+ msgstr ""
1087
+
1088
+ #: includes/custom-post-types.php:28
1089
+ msgid "View Feed Source"
1090
+ msgstr ""
1091
+
1092
+ #: includes/custom-post-types.php:29
1093
+ msgid "Search Feeds"
1094
+ msgstr ""
1095
+
1096
+ #: includes/custom-post-types.php:30
1097
+ msgid "No Feed Sources Found"
1098
+ msgstr ""
1099
+
1100
+ #: includes/custom-post-types.php:31
1101
+ msgid "No Feed Sources Found In Trash"
1102
+ msgstr ""
1103
+
1104
+ #: includes/custom-post-types.php:32
1105
+ msgid "RSS Aggregator"
1106
+ msgstr ""
1107
+
1108
+ #: includes/custom-post-types.php:72 includes/custom-post-types.php:74
1109
+ msgid "Feed Items"
1110
+ msgstr ""
1111
+
1112
+ #: includes/custom-post-types.php:73
1113
+ msgid "Feed Item"
1114
+ msgstr ""
1115
+
1116
+ #: includes/custom-post-types.php:75
1117
+ msgid "View Feed Items"
1118
+ msgstr ""
1119
+
1120
+ #: includes/custom-post-types.php:76
1121
+ msgid "Search Feed Items"
1122
+ msgstr ""
1123
+
1124
+ #: includes/custom-post-types.php:77
1125
+ msgid "No Feed Items Found"
1126
+ msgstr ""
1127
+
1128
+ #: includes/custom-post-types.php:78
1129
+ msgid "No Feed Items Found In Trash"
1130
+ msgstr ""
1131
+
1132
+ #: includes/feed-blacklist.php:129
1133
+ msgid "The item you are trying to blacklist does not exist"
1134
+ msgstr ""
1135
+
1136
+ #: includes/feed-blacklist.php:134
1137
+ msgid "The item you are trying to blacklist is not valid!"
1138
+ msgstr ""
1139
+
1140
+ #: includes/feed-blacklist.php:196 includes/feed-blacklist.php:197
1141
+ #: includes/feed-blacklist.php:198
1142
+ msgid "Blacklist"
1143
+ msgstr ""
1144
+
1145
+ #: includes/feed-blacklist.php:199
1146
+ msgid "Search Blacklist"
1147
+ msgstr ""
1148
+
1149
+ #: includes/feed-blacklist.php:200
1150
+ msgid "You do not have any items blacklisted yet!"
1151
+ msgstr ""
1152
+
1153
+ #: includes/feed-blacklist.php:242
1154
+ msgid "Delete Permanently & Blacklist"
1155
+ msgstr ""
1156
+
1157
+ #: includes/feed-blacklist.php:248
1158
+ msgid ""
1159
+ "The item will be deleted permanently, and its permalink will be recorded in "
1160
+ "the blacklist"
1161
+ msgstr ""
1162
+
1163
+ #: includes/feed-blacklist.php:261
1164
+ msgid "Remove from blacklist"
1165
+ msgstr ""
1166
+
1167
+ #: includes/feed-blacklist.php:321 includes/opml-importer.php:195
1168
+ #: includes/opml-importer.php:226
1169
+ msgid "Title"
1170
+ msgstr ""
1171
+
1172
+ #: includes/feed-display.php:355
1173
+ msgid "No feed items found."
1174
+ msgstr ""
1175
+
1176
+ #: includes/feed-display.php:405
1177
+ msgid "Older posts"
1178
+ msgstr ""
1179
+
1180
+ #: includes/feed-display.php:406
1181
+ msgid "Newer posts"
1182
+ msgstr ""
1183
+
1184
+ #: includes/feed-importing.php:262
1185
+ #, php-format
1186
+ msgid "Failed to fetch the RSS feed. Error: %s"
1187
+ msgstr ""
1188
+
1189
+ #: includes/feed-importing.php:651
1190
+ #, php-format
1191
+ msgid ""
1192
+ "The PHP script timed out while importing an item from this feed, after %d "
1193
+ "seconds."
1194
+ msgstr ""
1195
+
1196
+ #: includes/feed-states.php:110
1197
+ msgid "The feed sources have been activated!"
1198
+ msgstr ""
1199
+
1200
+ #: includes/feed-states.php:124
1201
+ msgid "The feed sources have been paused!!"
1202
+ msgstr ""
1203
+
1204
+ #: includes/libraries/EDD_licensing/EDD_SL_Plugin_Updater.php:154
1205
+ #, php-format
1206
+ msgid ""
1207
+ "There is a new version of %1$s available. <a target=\"_blank\" class="
1208
+ "\"thickbox\" href=\"%2$s\">View version %3$s details</a>."
1209
+ msgstr ""
1210
+
1211
+ #: includes/libraries/EDD_licensing/EDD_SL_Plugin_Updater.php:161
1212
+ #, php-format
1213
+ msgid ""
1214
+ "There is a new version of %1$s available. <a target=\"_blank\" class="
1215
+ "\"thickbox\" href=\"%2$s\">View version %3$s details</a> or <a href=\"%4$s"
1216
+ "\">update now</a>."
1217
+ msgstr ""
1218
+
1219
+ #: includes/libraries/EDD_licensing/EDD_SL_Plugin_Updater.php:301
1220
+ msgid "You do not have permission to install plugin updates"
1221
+ msgstr ""
1222
+
1223
+ #: includes/libraries/EDD_licensing/EDD_SL_Plugin_Updater.php:301
1224
+ msgid "Error"
1225
+ msgstr ""
1226
+
1227
+ #: includes/licensing.php:235
1228
+ #, php-format
1229
+ msgid ""
1230
+ "Remember to <a href=\"%s\">enter your plugin license code</a> for the WP RSS "
1231
+ "Aggregator <b>%s</b> add-on to benefit from updates and support."
1232
+ msgstr ""
1233
+
1234
+ #: includes/licensing.php:261
1235
+ #, php-format
1236
+ msgid ""
1237
+ "<a href=\"%s\">Save 30%% on your license renewal</a> for the WP RSS "
1238
+ "Aggregator <b>%s</b> add-on and continue receiving updates and support."
1239
+ msgstr ""
1240
+
1241
+ #: includes/licensing.php:296 includes/licensing.php:374
1242
+ msgid "No addon ID"
1243
+ msgstr ""
1244
+
1245
+ #: includes/licensing.php:304 includes/licensing.php:335
1246
+ msgid "Invalid event specified"
1247
+ msgstr ""
1248
+
1249
+ #: includes/licensing.php:307
1250
+ msgid "No event specified"
1251
+ msgstr ""
1252
+
1253
+ #: includes/licensing.php:314
1254
+ msgid "No license"
1255
+ msgstr ""
1256
+
1257
+ #: includes/licensing.php:323
1258
+ msgid "Bad nonce"
1259
+ msgstr ""
1260
+
1261
+ #: includes/licensing.php:326
1262
+ msgid "No nonce"
1263
+ msgstr ""
1264
+
1265
+ #: includes/licensing.php:414
1266
+ msgid "License"
1267
+ msgstr ""
1268
+
1269
+ #: includes/licensing.php:421
1270
+ msgid "License Key"
1271
+ msgstr ""
1272
+
1273
+ #: includes/licensing.php:430
1274
+ msgid "Activate License"
1275
+ msgstr ""
1276
+
1277
+ #: includes/licensing.php:452
1278
+ msgid "Enter your license key"
1279
+ msgstr ""
1280
+
1281
+ #: includes/licensing.php:477
1282
+ msgid "Status"
1283
+ msgstr ""
1284
+
1285
+ #: includes/licensing.php:505
1286
+ msgid "Renew your license to continue receiving updates and support."
1287
+ msgstr ""
1288
+
1289
+ #: includes/licensing.php:508
1290
+ msgid "Activations"
1291
+ msgstr ""
1292
+
1293
+ #: includes/licensing.php:511
1294
+ msgid "Expires on"
1295
+ msgstr ""
1296
+
1297
+ #: includes/licensing.php:514
1298
+ msgid "Registered to"
1299
+ msgstr ""
1300
+
1301
+ #: includes/licensing.php:518
1302
+ msgid ""
1303
+ "Failed to get license information. This is a temporary problem. Check your "
1304
+ "internet connection and try again later."
1305
+ msgstr ""
1306
+
1307
+ #: includes/misc-functions.php:269
1308
+ msgid "&hellip;"
1309
+ msgstr ""
1310
+
1311
+ #: includes/opml-importer.php:65
1312
+ msgid "Import OPML"
1313
+ msgstr ""
1314
+
1315
+ #: includes/opml-importer.php:75
1316
+ msgid "Howdy! Import your feeds here from an OPML (.xml) export file."
1317
+ msgstr ""
1318
+
1319
+ #: includes/opml-importer.php:76
1320
+ msgid "Click the button below, choose your file, and click 'Upload'."
1321
+ msgstr ""
1322
+
1323
+ #: includes/opml-importer.php:77
1324
+ msgid "We will take care of the rest."
1325
+ msgstr ""
1326
+
1327
+ #: includes/opml-importer.php:108
1328
+ msgid "Sorry, an error has been encountered."
1329
+ msgstr ""
1330
+
1331
+ #: includes/opml-importer.php:113
1332
+ msgid "Sorry, it seems your uploaded file has been misplaced!"
1333
+ msgstr ""
1334
+
1335
+ #: includes/opml-importer.php:114
1336
+ msgid "The uploaded file could not be found at "
1337
+ msgstr ""
1338
+
1339
+ #: includes/opml-importer.php:115
1340
+ msgid "It is likely that this was caused by a permissions problem."
1341
+ msgstr ""
1342
+
1343
+ #: includes/opml-importer.php:187
1344
+ msgid "Feeds were imported successfully!"
1345
+ msgstr ""
1346
+
1347
+ #: includes/opml-importer.php:194 includes/opml-importer.php:225
1348
+ msgid "ID"
1349
+ msgstr ""
1350
+
1351
+ #: includes/opml-importer.php:257
1352
+ msgid "WP RSS OPML"
1353
+ msgstr ""
1354
+
1355
+ #: includes/opml-importer.php:258
1356
+ msgid "Import Feeds from an OPML file into WP RSS Aggregator"
1357
+ msgstr ""
1358
+
1359
+ #: includes/scripts.php:31 includes/scripts.php:54
1360
+ msgid "Please wait ..."
1361
+ msgstr ""
1362
+
1363
+ #: includes/scripts.php:52
1364
+ msgid "Failed to import"
1365
+ msgstr ""
1366
+
1367
+ #: includes/scripts.php:53
1368
+ msgid "Items are importing"
1369
+ msgstr ""
1370
+
1371
+ #: includes/scripts.php:55
1372
+ msgid "Bulk Add"
1373
+ msgstr ""
1374
+
1375
+ #: includes/scripts.php:56
1376
+ msgid "OK"
1377
+ msgstr ""
1378
+
1379
+ #: includes/scripts.php:57
1380
+ msgid "Cancel"
1381
+ msgstr ""
1382
+
1383
+ #: includes/scripts.php:58
1384
+ msgid ""
1385
+ "The feed items listed here will be disregarded when importing new items from "
1386
+ "your feed sources."
1387
+ msgstr ""
1388
+
1389
+ #: includes/scripts.php:59
1390
+ msgid "Remove selected from Blacklist"
1391
+ msgstr ""
1392
+
1393
+ #: includes/scripts.php:72
1394
+ msgid "Activate"
1395
+ msgstr ""
1396
+
1397
+ #: includes/scripts.php:73
1398
+ msgid "Pause"
1399
+ msgstr ""
1400
+
1401
+ #: includes/scripts.php:101
1402
+ msgid "Activating..."
1403
+ msgstr ""
1404
+
1405
+ #: includes/scripts.php:102
1406
+ msgid "Deactivating..."
1407
+ msgstr ""
1408
+
1409
+ #: includes/system-info.php:27
1410
+ msgid "System Information"
1411
+ msgstr ""
1412
+
1413
+ #: includes/system-info.php:33
1414
+ msgid ""
1415
+ "To copy the system info, click below then press Ctrl + C (PC) or Cmd + C "
1416
+ "(Mac)."
1417
+ msgstr ""
1418
+
1419
+ #: includes/system-info.php:79
1420
+ msgid "Your server supports fsockopen."
1421
+ msgstr ""
1422
+
1423
+ #: includes/system-info.php:79
1424
+ msgid "Your server does not support fsockopen."
1425
+ msgstr ""
1426
+
1427
+ #: includes/system-info.php:152
1428
+ msgid "Download System Info File"
1429
+ msgstr ""
1430
+
1431
+ #: includes/update.php:67
1432
+ msgid "No Follow"
1433
+ msgstr ""
1434
+
1435
+ #: includes/update.php:69
1436
+ msgid "Follow"
1437
+ msgstr ""
1438
+
1439
+ #: wp-rss-aggregator.php:263
1440
+ msgid "Help improve WP RSS Aggregator"
1441
+ msgstr ""
1442
+
1443
+ #: wp-rss-aggregator.php:263
1444
+ msgid ""
1445
+ "You've just installed WP RSS Aggregator. Please helps us improve it by "
1446
+ "allowing us to gather anonymous usage stats so we know which configurations, "
1447
+ "plugins and themes to test with."
1448
+ msgstr ""
1449
+
1450
+ #: wp-rss-aggregator.php:270
1451
+ msgid "Do not allow tracking"
1452
+ msgstr ""
1453
+
1454
+ #: wp-rss-aggregator.php:271
1455
+ msgid "Allow tracking"
1456
+ msgstr ""
1457
+
1458
+ #: wp-rss-aggregator.php:397
1459
+ msgid "This plugin requires WordPress version 3.3 or higher."
1460
  msgstr ""
readme.txt CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.wprssaggregator.com
5
  Tags: rss, feeds, aggregation, rss to post, autoblog aggregator, rss import, feed aggregator, rss aggregator, multiple rss feeds, multi rss feeds, rss multi importer, feed import, feed import, multiple feed import, feed aggregation, rss feader, feed reader, feed to post, multiple feeds, multi feed importer, multi feed import, multi import, autoblogging, autoblogger, rss feeder, rss post importer, autoblog aggregator, autoblog, autopost, content curation, feedwordpress, wp rss multi import, hungryfeed, wp-o-matic, rss feed, rss feed to post, rss retriever, syndication
6
  Requires at least: 3.3
7
  Tested up to: 4.1
8
- Stable tag: 4.6.9
9
  License: GPLv2 or later
10
  The no.1 RSS feed importer for WordPress. Premium add-ons available for more functionality.
11
 
@@ -167,6 +167,13 @@ The full documentation section can be found on the [WP RSS Aggregator website](w
167
 
168
  == Changelog ==
169
 
 
 
 
 
 
 
 
170
  = 4.6.9 (2015-01-21) =
171
  * Enhanced: Admin user will now be warned about invalid or expiring licenses.
172
  * Enhanced: Admin notices logic centralized in this plugin.
5
  Tags: rss, feeds, aggregation, rss to post, autoblog aggregator, rss import, feed aggregator, rss aggregator, multiple rss feeds, multi rss feeds, rss multi importer, feed import, feed import, multiple feed import, feed aggregation, rss feader, feed reader, feed to post, multiple feeds, multi feed importer, multi feed import, multi import, autoblogging, autoblogger, rss feeder, rss post importer, autoblog aggregator, autoblog, autopost, content curation, feedwordpress, wp rss multi import, hungryfeed, wp-o-matic, rss feed, rss feed to post, rss retriever, syndication
6
  Requires at least: 3.3
7
  Tested up to: 4.1
8
+ Stable tag: 4.6.10
9
  License: GPLv2 or later
10
  The no.1 RSS feed importer for WordPress. Premium add-ons available for more functionality.
11
 
167
 
168
  == Changelog ==
169
 
170
+ = 4.6.10 (2015-02-10) =
171
+ * Enhanced: AJAX license activation.
172
+ * Enhanced: License form more reliable.
173
+ * Enhanced: license-related UI improvements
174
+ * New: Markdown library added. Changelog now read from readme.
175
+ * Fixed bug: Saving license keys not longer triggers error in some cases.
176
+
177
  = 4.6.9 (2015-01-21) =
178
  * Enhanced: Admin user will now be warned about invalid or expiring licenses.
179
  * Enhanced: Admin notices logic centralized in this plugin.
wp-rss-aggregator.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP RSS Aggregator
4
  Plugin URI: http://www.wprssaggregator.com
5
  Description: Imports and aggregates multiple RSS Feeds using SimplePie
6
- Version: 4.6.9
7
  Author: Jean Galea
8
  Author URI: http://www.wprssaggregator.com
9
  License: GPLv2
@@ -29,7 +29,7 @@
29
 
30
  /**
31
  * @package WPRSSAggregator
32
- * @version 4.6.9
33
  * @since 1.0
34
  * @author Jean Galea <info@wprssaggregator.com>
35
  * @copyright Copyright (c) 2012-2015, Jean Galea
@@ -43,7 +43,7 @@
43
 
44
  // Set the version number of the plugin.
45
  if( !defined( 'WPRSS_VERSION' ) )
46
- define( 'WPRSS_VERSION', '4.6.9', true );
47
 
48
  // Set the database version number of the plugin.
49
  if( !defined( 'WPRSS_DB_VERSION' ) )
3
  Plugin Name: WP RSS Aggregator
4
  Plugin URI: http://www.wprssaggregator.com
5
  Description: Imports and aggregates multiple RSS Feeds using SimplePie
6
+ Version: 4.6.10
7
  Author: Jean Galea
8
  Author URI: http://www.wprssaggregator.com
9
  License: GPLv2
29
 
30
  /**
31
  * @package WPRSSAggregator
32
+ * @version 4.6.10
33
  * @since 1.0
34
  * @author Jean Galea <info@wprssaggregator.com>
35
  * @copyright Copyright (c) 2012-2015, Jean Galea
43
 
44
  // Set the version number of the plugin.
45
  if( !defined( 'WPRSS_VERSION' ) )
46
+ define( 'WPRSS_VERSION', '4.6.10', true );
47
 
48
  // Set the database version number of the plugin.
49
  if( !defined( 'WPRSS_DB_VERSION' ) )