Simple Download Monitor - Version 3.8.3

Version Description

  • Spanish translation file updated.
  • Better handling of the stats admin menu interface in mobile devices.
  • Addon updates are now handled by the main plugin.
Download this release

Release Info

Developer mra13
Plugin Icon 128x128 Simple Download Monitor
Version 3.8.3
Comparing to
See all releases

Code changes from version 3.8.2 to 3.8.3

Files changed (86) hide show
  1. includes/class-sdm-addons-updater.php +50 -0
  2. includes/sdm-admin-menu-handler.php +3 -3
  3. languages/simple-download-monitor-es_ES.mo +0 -0
  4. languages/simple-download-monitor-es_ES.po +1299 -360
  5. lib/plugin-update-checker/.editorconfig +15 -0
  6. lib/plugin-update-checker/Puc/v4/Factory.php +6 -0
  7. lib/plugin-update-checker/Puc/v4p8/Autoloader.php +47 -0
  8. lib/plugin-update-checker/Puc/v4p8/DebugBar/Extension.php +177 -0
  9. lib/plugin-update-checker/Puc/v4p8/DebugBar/Panel.php +165 -0
  10. lib/plugin-update-checker/Puc/v4p8/DebugBar/PluginExtension.php +33 -0
  11. lib/plugin-update-checker/Puc/v4p8/DebugBar/PluginPanel.php +38 -0
  12. lib/plugin-update-checker/Puc/v4p8/DebugBar/ThemePanel.php +21 -0
  13. lib/plugin-update-checker/Puc/v4p8/Factory.php +297 -0
  14. lib/plugin-update-checker/Puc/v4p8/InstalledPackage.php +103 -0
  15. lib/plugin-update-checker/Puc/v4p8/Metadata.php +132 -0
  16. lib/plugin-update-checker/Puc/v4p8/OAuthSignature.php +100 -0
  17. lib/plugin-update-checker/Puc/v4p8/Plugin/Info.php +130 -0
  18. lib/plugin-update-checker/Puc/v4p8/Plugin/Package.php +184 -0
  19. lib/plugin-update-checker/Puc/v4p8/Plugin/Ui.php +277 -0
  20. lib/plugin-update-checker/Puc/v4p8/Plugin/Update.php +110 -0
  21. lib/plugin-update-checker/Puc/v4p8/Plugin/UpdateChecker.php +398 -0
  22. lib/plugin-update-checker/Puc/v4p8/Scheduler.php +238 -0
  23. lib/plugin-update-checker/Puc/v4p8/StateStore.php +207 -0
  24. lib/plugin-update-checker/Puc/v4p8/Theme/Package.php +65 -0
  25. lib/plugin-update-checker/Puc/v4p8/Theme/Update.php +84 -0
  26. lib/plugin-update-checker/Puc/v4p8/Theme/UpdateChecker.php +142 -0
  27. lib/plugin-update-checker/Puc/v4p8/Update.php +34 -0
  28. lib/plugin-update-checker/Puc/v4p8/UpdateChecker.php +926 -0
  29. lib/plugin-update-checker/Puc/v4p8/UpgraderStatus.php +199 -0
  30. lib/plugin-update-checker/Puc/v4p8/Utils.php +69 -0
  31. lib/plugin-update-checker/Puc/v4p8/Vcs/Api.php +302 -0
  32. lib/plugin-update-checker/Puc/v4p8/Vcs/BaseChecker.php +27 -0
  33. lib/plugin-update-checker/Puc/v4p8/Vcs/BitBucketApi.php +265 -0
  34. lib/plugin-update-checker/Puc/v4p8/Vcs/GitHubApi.php +417 -0
  35. lib/plugin-update-checker/Puc/v4p8/Vcs/GitLabApi.php +309 -0
  36. lib/plugin-update-checker/Puc/v4p8/Vcs/PluginUpdateChecker.php +213 -0
  37. lib/plugin-update-checker/Puc/v4p8/Vcs/Reference.php +49 -0
  38. lib/plugin-update-checker/Puc/v4p8/Vcs/ThemeUpdateChecker.php +118 -0
  39. lib/plugin-update-checker/README.md +299 -0
  40. lib/plugin-update-checker/composer.json +22 -0
  41. lib/plugin-update-checker/css/puc-debug-bar.css +70 -0
  42. lib/plugin-update-checker/examples/plugin.json +52 -0
  43. lib/plugin-update-checker/examples/theme.json +5 -0
  44. lib/plugin-update-checker/js/debug-bar.js +52 -0
  45. lib/plugin-update-checker/languages/plugin-update-checker-ca.mo +0 -0
  46. lib/plugin-update-checker/languages/plugin-update-checker-ca.po +48 -0
  47. lib/plugin-update-checker/languages/plugin-update-checker-cs_CZ.mo +0 -0
  48. lib/plugin-update-checker/languages/plugin-update-checker-cs_CZ.po +45 -0
  49. lib/plugin-update-checker/languages/plugin-update-checker-da_DK.mo +0 -0
  50. lib/plugin-update-checker/languages/plugin-update-checker-da_DK.po +42 -0
  51. lib/plugin-update-checker/languages/plugin-update-checker-de_DE.mo +0 -0
  52. lib/plugin-update-checker/languages/plugin-update-checker-de_DE.po +38 -0
  53. lib/plugin-update-checker/languages/plugin-update-checker-es_ES.mo +0 -0
  54. lib/plugin-update-checker/languages/plugin-update-checker-es_ES.po +48 -0
  55. lib/plugin-update-checker/languages/plugin-update-checker-fa_IR.mo +0 -0
  56. lib/plugin-update-checker/languages/plugin-update-checker-fa_IR.po +38 -0
  57. lib/plugin-update-checker/languages/plugin-update-checker-fr_CA.mo +0 -0
  58. lib/plugin-update-checker/languages/plugin-update-checker-fr_CA.po +48 -0
  59. lib/plugin-update-checker/languages/plugin-update-checker-fr_FR.mo +0 -0
  60. lib/plugin-update-checker/languages/plugin-update-checker-fr_FR.po +42 -0
  61. lib/plugin-update-checker/languages/plugin-update-checker-hu_HU.mo +0 -0
  62. lib/plugin-update-checker/languages/plugin-update-checker-hu_HU.po +41 -0
  63. lib/plugin-update-checker/languages/plugin-update-checker-it_IT.mo +0 -0
  64. lib/plugin-update-checker/languages/plugin-update-checker-it_IT.po +38 -0
  65. lib/plugin-update-checker/languages/plugin-update-checker-ja.mo +0 -0
  66. lib/plugin-update-checker/languages/plugin-update-checker-ja.po +57 -0
  67. lib/plugin-update-checker/languages/plugin-update-checker-nl_BE.mo +0 -0
  68. lib/plugin-update-checker/languages/plugin-update-checker-nl_BE.po +48 -0
  69. lib/plugin-update-checker/languages/plugin-update-checker-nl_NL.mo +0 -0
  70. lib/plugin-update-checker/languages/plugin-update-checker-nl_NL.po +48 -0
  71. lib/plugin-update-checker/languages/plugin-update-checker-pt_BR.mo +0 -0
  72. lib/plugin-update-checker/languages/plugin-update-checker-pt_BR.po +48 -0
  73. lib/plugin-update-checker/languages/plugin-update-checker-sl_SI.mo +0 -0
  74. lib/plugin-update-checker/languages/plugin-update-checker-sl_SI.po +48 -0
  75. lib/plugin-update-checker/languages/plugin-update-checker-sv_SE.mo +0 -0
  76. lib/plugin-update-checker/languages/plugin-update-checker-sv_SE.po +42 -0
  77. lib/plugin-update-checker/languages/plugin-update-checker.pot +49 -0
  78. lib/plugin-update-checker/license.txt +7 -0
  79. lib/plugin-update-checker/load-v4p8.php +28 -0
  80. lib/plugin-update-checker/plugin-update-checker.php +10 -0
  81. lib/plugin-update-checker/vendor/Parsedown.php +9 -0
  82. lib/plugin-update-checker/vendor/ParsedownLegacy.php +1535 -0
  83. lib/plugin-update-checker/vendor/ParsedownModern.php +1538 -0
  84. lib/plugin-update-checker/vendor/PucReadmeParser.php +341 -0
  85. main.php +11 -6
  86. readme.txt +7 -2
includes/class-sdm-addons-updater.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class SDM_Addons_Updater {
4
+ protected $addons = array(
5
+ array( 'sdm-user-upload', 'sdm-user-upload/main.php', 'sdm-user-upload' ),
6
+ array( 'sdm-squeeze-form', 'sdm-squeeze-form/main.php', 'sdm-squeeze-form', 'sdm-squeeze-form-addon-icon.png' ),
7
+ array( 'sdm-hidden-downloads', 'sdm-hidden-downloads/sdm-hidden-downloads.php', 'sdm-hidden-downloads', 'sdm-hidden-downloads-addon-icon.png' ),
8
+ array( 'sdm-dropbox', 'sdm-dropbox/sdm-dropbox.php', 'sdm-dropbox', 'sdm-dropbox-integration-addon.png' ),
9
+ array( 'sdm-allow-more-file-types', 'sdm-allow-more-file-types/sdm-allow-more-file-types.php', 'sdm-allow-more-file-types', 'sdm-allow-uploads-addon-icon.png' ),
10
+ array( 'sdm-amazon-s3', 'sdm-amazon-s3/sdm-amazon-s3.php', 'sdm-amazon-s3', 'sdm-amazon-s3-addon-icon.png', 'sdm-email-on-download-addon-icon.png' ),
11
+ array( 'sdm-download-email-notification', 'sdm-download-email-notification/sdm-download-email-notification.php', 'sdm-download-email-notification', 'sdm-email-on-download-addon-icon.png' ),
12
+ );
13
+
14
+ private $update_url = 'https://simple-download-monitor.com/updates/?action=get_metadata&slug=';
15
+ private $icons_path = WP_SIMPLE_DL_MONITOR_URL . '/images/addons/';
16
+ private $icons = array();
17
+
18
+ public function __construct() {
19
+ add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
20
+ }
21
+
22
+ public function set_icon( $data ) {
23
+ if ( isset( $this->icons[ $data->slug ] ) ) {
24
+ $data->icons = array( 'default' => $this->icons[ $data->slug ] );
25
+ }
26
+ return $data;
27
+ }
28
+
29
+ public function plugins_loaded() {
30
+ if ( ! class_exists( 'Puc_v4_Factory' ) ) {
31
+ require_once WP_SIMPLE_DL_MONITOR_PATH . 'lib/plugin-update-checker/plugin-update-checker.php';
32
+ }
33
+ foreach ( $this->addons as $addon ) {
34
+ if ( ! empty( $addon[3] ) ) {
35
+ $this->icons[ $addon[2] ] = $this->icons_path . $addon[3];
36
+ add_filter( 'puc_request_info_result-' . $addon[2], array( $this, 'set_icon' ) );
37
+ }
38
+ $plugin_file = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . str_replace( '/', DIRECTORY_SEPARATOR, $addon[1] );
39
+ if ( file_exists( $plugin_file ) ) {
40
+ $my_update_checker = Puc_v4_Factory::buildUpdateChecker(
41
+ $this->update_url . $addon[0],
42
+ $plugin_file,
43
+ $addon[2]
44
+ );
45
+ }
46
+ }
47
+ }
48
+ }
49
+
50
+ new SDM_Addons_Updater();
includes/sdm-admin-menu-handler.php CHANGED
@@ -499,7 +499,7 @@ function sdm_create_stats_page() {
499
  </div>
500
  <div class="sdm-tabs-content-wrapper" style="height: 500px;margin-top: 10px;">
501
  <div data-tab-name="datechart" class="sdm-tab"<?php echo ($active_tab == 'datechart' ? '' : ' style="display:none;"'); ?>>
502
- <div id="downloads_chart" style="width: 700px;"></div>
503
  </div>
504
  <div data-tab-name="geochart" class="sdm-tab"<?php echo ($active_tab == 'geochart' ? '' : ' style="display:none;"'); ?>>
505
  <div id="sdm-api-key-warning">
@@ -509,7 +509,7 @@ function sdm_create_stats_page() {
509
  </div>
510
  </div>
511
 
512
- <div id="country_chart" style="width: 700px;height:437px;"></div>
513
  </div>
514
 
515
  <div data-tab-name="countrylistchart" class="sdm-tab"<?php echo ($active_tab == 'countrylistchart' ? '' : ' style="display:none;"'); ?>>
@@ -582,7 +582,7 @@ function sdm_create_stats_page() {
582
  sdm_dateData.addRows([<?php echo $downloads_by_date; ?>]);
583
 
584
  var sdm_dateChart = new google.visualization.AreaChart(document.getElementById('downloads_chart'));
585
- sdm_dateChart.draw(sdm_dateData, {width: 700, height: 300, title: '<?php _e( 'Downloads by Date', 'simple-download-monitor' ); ?>', colors: ['#3366CC', '#9AA2B4', '#FFE1C9'],
586
  hAxis: {title: 'Date', titleTextStyle: {color: 'black'}},
587
  vAxis: {title: 'Downloads', titleTextStyle: {color: 'black'}},
588
  legend: 'top'
499
  </div>
500
  <div class="sdm-tabs-content-wrapper" style="height: 500px;margin-top: 10px;">
501
  <div data-tab-name="datechart" class="sdm-tab"<?php echo ($active_tab == 'datechart' ? '' : ' style="display:none;"'); ?>>
502
+ <div id="downloads_chart" style="width: auto; max-width: 700px"></div>
503
  </div>
504
  <div data-tab-name="geochart" class="sdm-tab"<?php echo ($active_tab == 'geochart' ? '' : ' style="display:none;"'); ?>>
505
  <div id="sdm-api-key-warning">
509
  </div>
510
  </div>
511
 
512
+ <div id="country_chart" style="width: auto; max-width: 700px; height:437px;"></div>
513
  </div>
514
 
515
  <div data-tab-name="countrylistchart" class="sdm-tab"<?php echo ($active_tab == 'countrylistchart' ? '' : ' style="display:none;"'); ?>>
582
  sdm_dateData.addRows([<?php echo $downloads_by_date; ?>]);
583
 
584
  var sdm_dateChart = new google.visualization.AreaChart(document.getElementById('downloads_chart'));
585
+ sdm_dateChart.draw(sdm_dateData, {width: 'auto', height: 300, title: '<?php _e( 'Downloads by Date', 'simple-download-monitor' ); ?>', colors: ['#3366CC', '#9AA2B4', '#FFE1C9'],
586
  hAxis: {title: 'Date', titleTextStyle: {color: 'black'}},
587
  vAxis: {title: 'Downloads', titleTextStyle: {color: 'black'}},
588
  legend: 'top'
languages/simple-download-monitor-es_ES.mo CHANGED
Binary file
languages/simple-download-monitor-es_ES.po CHANGED
@@ -1,476 +1,587 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: SDM 3.1\n"
4
- "POT-Creation-Date: 2014-07-29 12:06+1000\n"
5
- "PO-Revision-Date: 2014-09-25 07:43+1000\n"
6
- "Last-Translator: Manuel <mbruiz1967@mbrsolution.com>\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.6.9\n"
12
  "X-Poedit-KeywordsList: __;_e\n"
13
  "X-Poedit-Basepath: .\n"
14
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
- "Language: es\n"
16
- "X-Poedit-SearchPath-0: C:\\Users\\amin\\Desktop\\simple-download-monitor\n"
17
-
18
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:91
19
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:310
20
- msgid "Settings"
21
- msgstr "Configuración"
22
 
23
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:145
24
- msgid "Image Successfully Removed"
25
- msgstr "Imagen Eliminado Con Éxito"
26
 
27
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:146
28
- msgid "Error with AJAX"
29
- msgstr "Error con AJAX"
 
30
 
31
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:156
32
- msgid "Please select a Download Item:"
33
- msgstr "Por favor seleccione una Descarga De Artículo:"
34
 
35
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:156
36
- msgid "Download Title"
37
- msgstr "Titulo Descarga"
38
 
39
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:156
40
- msgid "Include Fancy Box"
41
- msgstr "Incluya Caja de Visión"
 
 
 
 
42
 
43
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:156
44
- msgid "Insert SDM Shortcode"
45
- msgstr "Inserte Código Corto De SDM"
46
 
47
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:166
48
- msgid "Incorrect Password"
49
- msgstr "Clave Incorrecta"
50
-
51
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:182
52
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:183
53
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:188
54
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:194
55
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:590
56
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:1034
57
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-post-type-content-handler.php:48
58
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:94
59
- #: C:\Users\amin\Desktop\simple-download-monitor/includes/templates/fancy1/sdm-fancy-1.php:87
60
- msgid "Downloads"
61
- msgstr "Descarga"
62
 
63
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:184
64
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:185
65
- msgid "Add New"
66
- msgstr "Agregar Nuevo"
67
 
68
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:186
69
- msgid "Edit Download"
70
- msgstr "Editar la Bajada"
 
71
 
72
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:187
73
- msgid "New Download"
74
- msgstr "Nueva Descarga"
75
 
76
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:189
77
- msgid "View Download"
78
- msgstr "Ver Descarga"
 
79
 
80
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:190
81
- msgid "Search Downloads"
82
- msgstr "Buscar En Las Bajadas"
83
 
84
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:191
85
- msgid "No Downloads found"
86
- msgstr "Ninguna Descarga Encontrada"
87
 
88
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:192
89
- msgid "No Downloads found in Trash"
90
- msgstr "Ninguna Descarga Encontrada En La Papelera"
91
 
92
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:193
93
- msgid "Parent Download"
94
- msgstr "El Padre De La Descarga "
95
 
96
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:221
97
- msgid "Search Categories"
98
- msgstr "Buscar Categorías"
 
 
 
 
 
 
99
 
100
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:222
101
- msgid "All Categories"
102
- msgstr "Todas Las Categorías"
 
 
 
 
 
103
 
104
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:223
105
- msgid "Categories Genre"
106
- msgstr "Género De Categorías"
107
 
108
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:224
109
- msgid "Categories Genre:"
110
- msgstr "Género De Categorías:"
 
 
 
 
 
111
 
112
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:225
113
- msgid "Edit Category"
114
- msgstr "Editar Categoría"
115
 
116
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:226
117
- msgid "Update Category"
118
- msgstr "Actualizar Categoría"
 
 
119
 
120
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:227
121
- msgid "Add New Category"
122
- msgstr "Añade Una Categorías"
123
 
124
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:228
125
- msgid "New Category"
126
- msgstr "Nueva Categoría"
 
127
 
128
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:229
129
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:1032
130
- msgid "Categories"
131
- msgstr "Categorías"
132
 
133
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:246
134
- msgid "Search Tags"
135
- msgstr "Buscar Etiquetas"
 
 
 
 
136
 
137
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:247
138
- msgid "All Tags"
139
- msgstr "Todas Las Etiquetas"
140
 
141
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:248
142
- msgid "Tags Genre"
143
- msgstr "Género De Etiquetas"
 
 
144
 
145
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:249
146
- msgid "Tags Genre:"
147
- msgstr "Género De Etiquetas:"
 
 
 
148
 
149
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:250
150
- msgid "Edit Tag"
151
- msgstr "Editar Etiqueta"
152
 
153
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:251
154
- msgid "Update Tag"
155
- msgstr "Actualizar La Etiqueta"
156
 
157
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:252
158
- msgid "Add New Tag"
159
- msgstr "Agrega Nueva Etiqueta"
160
 
161
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:253
162
- msgid "New Tag"
163
- msgstr "Nueva Etiqueta"
 
 
164
 
165
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:254
166
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:1033
167
- msgid "Tags"
168
- msgstr "Etiquetas"
169
 
170
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:309
171
- msgid "Logs"
172
- msgstr "Registros"
173
 
174
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:317
175
- msgid "Simple Download Monitor Settings Page"
176
- msgstr "Simple Configuración De Descarga De La Pagina Del Monitor"
177
 
178
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:320
179
- msgid "Follow us"
180
- msgstr "Síganos"
181
 
182
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:320
183
- msgid ""
184
- "on Twitter, Google+ or via Email to stay upto date about the new features of "
185
- "this plugin."
186
- msgstr ""
187
- "en Twitter, Google+ o vía correo electrónico estar acutalizado hasta la "
188
- "fecha de hoy de las nuevas características de este plugin."
189
 
190
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:329
191
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:528
192
- msgid "Admin Options"
193
- msgstr "Opciones Del Administrador"
194
 
195
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:332
196
- msgid "Control various plugin features."
197
- msgstr "Controla varias funciones del plugin."
198
 
199
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:349
200
- msgid "Color Options"
201
- msgstr "Opciones De Color"
202
 
203
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:352
204
- msgid "Adjust color options"
205
- msgstr "Ajuste Las Opciones Del Color"
206
 
207
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:370
208
- msgid ""
209
- "If you need a feature rich and supported plugin for selling your digital "
210
- "items then checkout our"
211
- msgstr ""
212
- "Si usted necesita una característica rica y un plugin compatible para la "
213
- "venta de sus artículos digitales entonces echa un vistazo a nuestra"
214
 
215
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:370
216
- msgid "WP eStore Plugin"
217
- msgstr "WP eStore Plugin"
218
 
219
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:383
220
- msgid "Description"
221
- msgstr "Descripción"
222
 
223
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:385
224
- msgid "Upload File"
225
- msgstr "Subir Archivo"
226
 
227
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:387
228
- msgid "File Thumbnail (Optional)"
229
- msgstr "Archivo Miniatura (Opcional)"
230
 
231
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:389
232
- msgid "Shortcodes"
233
- msgstr "Código Corto"
234
 
235
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:391
236
- msgid "Statistics"
237
- msgstr "Estadísticas"
238
 
239
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:396
240
- msgid "Add a description for this download item."
241
- msgstr "Añadir una descripción para este articulo de descarga."
242
 
243
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:409
244
- msgid "Click \"Select File\" to upload (or choose) the file."
245
- msgstr ""
246
- "Haga clic en \"Seleccione Archivo\" para cargar (o seleccione) el archivo."
247
 
248
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:412
249
- msgid "Select File"
250
- msgstr "Selecciona Archivo"
251
 
252
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:414
253
- msgid "File URL:"
254
- msgstr "Archivo URL:"
255
 
256
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:422
257
  msgid ""
258
- "Click \"Select Image\" to upload (or choose) the file thumbnail image. This "
259
- "thumbnail image will be used to create a fancy file download box if you want "
260
- "to use it."
 
261
  msgstr ""
262
- "Haga clic en \"Seleccionar Imagen\" para subir (o seleccione) la imagen en "
263
- "miniatura del archivo. Esta imagen en miniatura se utiliza para crear un "
264
- "cuadro de descarga de archivo de visión si usted desea utilizarlo."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
 
266
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:427
267
- msgid "Select Image"
268
- msgstr "Selecciona Imagen"
269
 
270
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:428
271
- msgid "Remove Image"
272
- msgstr "Eliminar Imagen"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
 
274
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:442
 
 
 
 
275
  msgid ""
276
- "This is the shortcode which can used on posts or pages to embed a download "
277
- "now button for this file. You can also use the shortcode inserter to add "
278
- "this shortcode to a post or page."
279
  msgstr ""
280
- "Este es el código abreviado que puede utilizar en los mensajes o páginas "
281
- "para incrustar un botón Descargar ahora para este archivo. También puede "
282
- "utilizar el código corto de inserción para agregar este código corto para "
283
- "una entrada o página."
284
 
285
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:447
286
- msgid "This shortcode may be used as a download counter."
287
- msgstr "Este código corto puede ser utilizado como un contador de descarga."
288
 
289
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:456
290
- msgid "These are the statistics for this download item."
291
- msgstr "Estas son las estadísticas sobre este articulo descarga."
292
 
293
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:461
294
- msgid "Number of Downloads:"
295
- msgstr "Numero de Descargas:"
296
 
297
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:464
298
- msgid "Offset Count"
299
- msgstr "Cuenta De Desplazamiento"
300
 
301
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:529
302
- msgid "Colors"
303
- msgstr "Colores"
 
 
 
304
 
305
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:531
306
- msgid "Remove Tinymce Button"
307
- msgstr "Eliminar El Botón Tinymce"
308
 
309
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:532
310
- msgid "Download Button Color"
311
- msgstr "Color Del Botón De Descarga"
312
 
313
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:536
314
- msgid "Admin options settings"
315
- msgstr "Configuración de las opciones administrador"
316
 
317
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:540
318
- msgid "Front End colors settings"
319
- msgstr "Ajustes de colores parte Delantera"
 
 
 
 
 
320
 
321
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:546
322
- msgid "Removes the SDM Downloads button from the WP content editor."
323
- msgstr "Elimina el botón Descargas SDM del editor del contenido WP."
324
 
325
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
326
- msgid "Green"
327
- msgstr "Verde"
328
 
329
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
330
- msgid "Blue"
331
- msgstr "Azul"
332
 
333
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
334
- msgid "Purple"
335
- msgstr "Púrpura"
 
336
 
337
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
338
- msgid "Teal"
339
- msgstr "Verde Azulado"
340
 
341
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
342
- msgid "Dark Blue"
343
- msgstr "Azul Oscuro"
344
 
345
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
346
- msgid "Black"
347
- msgstr "Negro"
348
 
349
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
350
- msgid "Grey"
351
- msgstr "Gris"
 
 
352
 
353
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
354
- msgid "Pink"
355
- msgstr "Rosa"
 
356
 
357
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
358
- msgid "Orange"
359
- msgstr "Naranja"
 
360
 
361
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
362
- msgid "White"
363
- msgstr "Blanco"
 
364
 
365
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:555
366
- msgid "current"
367
- msgstr "al corriente"
368
 
369
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:561
370
- msgid "Adjusts the color of the \"Download Now\" button."
371
- msgstr "Ajusta el color del botón de la \"Descargar Ahora\"."
 
372
 
373
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:589
374
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-post-type-content-handler.php:48
375
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:94
376
- #: C:\Users\amin\Desktop\simple-download-monitor/includes/templates/fancy1/sdm-fancy-1.php:87
377
  msgid "Download"
378
  msgstr "Bajada"
379
 
380
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:613
 
 
 
 
 
 
 
 
381
  msgid "Edit"
382
  msgstr "Editar"
383
 
384
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:614
385
  msgid "Delete"
386
  msgstr "Borrar"
387
 
388
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:638
389
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:1029
390
  msgid "Title"
391
  msgstr "Titulo"
392
 
393
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:639
394
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:1031
395
  msgid "File"
396
  msgstr "Archivo"
397
 
398
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:640
399
  msgid "Visitor IP"
400
  msgstr "IP del Visitante"
401
 
402
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:641
403
- msgid "Date"
404
- msgstr "Fecha"
405
-
406
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:642
407
  msgid "Country"
408
  msgstr "País"
409
 
410
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:662
 
 
 
 
411
  msgid "Delete Permanently"
412
  msgstr "Borrar Permanente"
413
 
414
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:663
415
- msgid "Export All as Excel"
416
- msgstr "Exportar todo como Excel"
417
-
418
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:678
419
  msgid "Nope! Security check failed!"
420
  msgstr "¡No! ¡Control de seguridad falló!"
421
 
422
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:686
423
- msgid "Download Export File"
424
- msgstr "Descarga de archivo de exportación"
425
-
426
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:693
427
  msgid "No entries were selected."
428
  msgstr "No se seleccionaron entradas."
429
 
430
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:693
431
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:709
432
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:711
433
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:728
434
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:730
435
  msgid "Click to Dismiss"
436
  msgstr "Haga clic para Descartar"
437
 
438
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:709
 
 
 
 
 
 
439
  msgid "Entries Deleted!"
440
  msgstr "¡Entradas Eliminadas!"
441
 
442
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:711
443
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:730
444
  msgid "Error"
445
  msgstr "Error"
446
 
447
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:728
448
  msgid "Entry Deleted!"
449
  msgstr "¡Entrada Eliminada!"
450
 
451
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:788
452
- msgid "Download Logs"
453
- msgstr "Descargar Registros"
454
 
455
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:791
456
- msgid "This page lists all tracked downloads."
457
- msgstr "Esta página muestra todas las descargas de rastreadores."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
458
 
459
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:813
460
  msgid "Enter Password to Download:"
461
  msgstr "Introduzca La Contraseña Para Descargar:"
462
 
463
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:816
464
- msgid "Submit"
465
- msgstr "Enviar"
466
 
467
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:862
468
- msgid "Error! Failed to log the download request in the database table"
469
- msgstr ""
470
- "¡Error! No se pudo registrar la solicitud de descarga en la tabla de base de "
471
- "datos"
472
 
473
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:871
 
 
 
 
 
 
 
474
  msgid ""
475
  "Error! The URL value is empty. Please specify a correct URL value to "
476
  "redirect to!"
@@ -478,43 +589,786 @@ msgstr ""
478
  "¡Error ! El valor URL está vacío. ¡Por favor, especifique un valor URL "
479
  "correcto para redirigir a!"
480
 
481
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:1028
482
- msgid "Image"
483
- msgstr "Imagen"
 
484
 
485
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:1030
486
- msgid "ID"
487
- msgstr "ID"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
488
 
489
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:1035
490
- msgid "Date Posted"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
491
  msgstr "Fecha de Publicación"
492
 
493
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:1036
494
- msgid "Visitor Country"
495
- msgstr "País del Usuario"
 
 
 
 
496
 
497
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-post-type-content-handler.php:32
498
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:40
499
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:166
500
- #: C:\Users\amin\Desktop\simple-download-monitor/includes/templates/fancy1/sdm-fancy-1.php:42
501
- msgid "green"
502
- msgstr "verde"
503
 
504
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-post-type-content-handler.php:37
505
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:48
506
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:174
507
- #: C:\Users\amin\Desktop\simple-download-monitor/includes/templates/fancy1/sdm-fancy-1.php:53
508
- #: C:\Users\amin\Desktop\simple-download-monitor/includes/templates/fancy2/sdm-fancy-2.php:57
509
- msgid "Download Now!"
510
- msgstr "Bajar Ahora!"
 
 
 
 
 
 
 
 
511
 
512
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:27
513
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
514
  msgid "Error! Please enter an ID value with this shortcode."
515
  msgstr "¡Error! Por favor, introduzca un valor de ID con este código corto."
516
 
517
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:118
518
  msgid ""
519
  "Error! You must enter a category slug OR a category id with this shortcode. "
520
  "Refer to the documentation for usage instructions."
@@ -523,11 +1377,96 @@ msgstr ""
523
  "categoría con este código corto. Consulte la documentación para obtener "
524
  "instrucciones de uso."
525
 
526
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:122
527
  msgid "Error! Please enter a category slug OR id; not both."
528
  msgstr "¡Error! Por favor introduce una categoría slug O id; no ambos."
529
 
530
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:153
 
 
 
 
 
 
 
 
531
  msgid "There are no download items matching this category criteria."
532
  msgstr ""
533
  "No hay elementos que coincidan con este criterio de categoría de descarga."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: SDM 3.1\n"
4
+ "POT-Creation-Date: 2019-10-25 18:15+1100\n"
5
+ "PO-Revision-Date: 2019-10-26 09:00+1000\n"
6
+ "Last-Translator: Manuel <mbruiz1967@mbrsolution.com>\n"
7
  "Language-Team: \n"
8
+ "Language: es\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 2.2.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: .\n"
15
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
+ "X-Poedit-SearchPath-0: C:/Users/amin/Desktop/simple-download-monitor\n"
 
 
 
 
 
 
17
 
18
+ #: includes/admin-side/sdm-admin-individual-item-logs-page.php:5
19
+ msgid "Specific Download Item Logs"
20
+ msgstr "Descarga específica de registros de elementos"
21
 
22
+ #: includes/admin-side/sdm-admin-individual-item-logs-page.php:22
23
+ msgid "This menu allows you to view the download logs of individual items."
24
+ msgstr ""
25
+ "Este menú te permite ver los registros de descarga de elementos individuales."
26
 
27
+ #: includes/admin-side/sdm-admin-individual-item-logs-page.php:28
28
+ msgid "View Specific Item Logs"
29
+ msgstr "Ver registros de elementos específicos"
30
 
31
+ #: includes/admin-side/sdm-admin-individual-item-logs-page.php:31
32
+ msgid "Enter the Download ID of the item: "
33
+ msgstr "Introduce el ID de descarga del elemento: "
34
 
35
+ #: includes/admin-side/sdm-admin-individual-item-logs-page.php:34
36
+ msgid ""
37
+ "You can find the Download ID of an item from the Downloads menu of the "
38
+ "plugin."
39
+ msgstr ""
40
+ "Puedes encontrar el ID de descarga de un elemento en el menú de descargas "
41
+ "del plugin."
42
 
43
+ #: includes/admin-side/sdm-admin-individual-item-logs-page.php:37
44
+ msgid "View Logs"
45
+ msgstr "Ver registros"
46
 
47
+ #: includes/admin-side/sdm-admin-individual-item-logs-page.php:54
48
+ msgid ""
49
+ "The following table shows the download logs of the item with Download ID: "
50
+ msgstr ""
51
+ "La siguiente tabla muestra los registros de descarga del elemento con ID de "
52
+ "descarga: "
 
 
 
 
 
 
 
 
 
53
 
54
+ #: includes/sdm-admin-menu-handler.php:9
55
+ msgid "Logs"
56
+ msgstr "Registros"
 
57
 
58
+ #: includes/sdm-admin-menu-handler.php:10
59
+ #: includes/sdm-admin-menu-handler.php:472
60
+ msgid "Stats"
61
+ msgstr "Estadísticas"
62
 
63
+ #: includes/sdm-admin-menu-handler.php:11 main.php:187
64
+ msgid "Settings"
65
+ msgstr "Configuración"
66
 
67
+ #: includes/sdm-admin-menu-handler.php:12
68
+ #: includes/sdm-admin-menu-handler.php:129
69
+ msgid "Add-ons"
70
+ msgstr "Extensiones"
71
 
72
+ #: includes/sdm-admin-menu-handler.php:74
73
+ msgid "Simple Download Monitor Settings Page"
74
+ msgstr "Simple Configuración De Descarga De La Pagina Del Monitor"
75
 
76
+ #: includes/sdm-admin-menu-handler.php:79
77
+ msgid "General Settings"
78
+ msgstr "Ajustes generales"
79
 
80
+ #: includes/sdm-admin-menu-handler.php:80
81
+ msgid "Advanced Settings"
82
+ msgstr "Ajustes avanzados"
83
 
84
+ #: includes/sdm-admin-menu-handler.php:123
85
+ msgid "Plugin Documentation"
86
+ msgstr "Documentación del plugin"
87
 
88
+ #: includes/sdm-admin-menu-handler.php:125
89
+ #, php-format
90
+ msgid ""
91
+ "Please read the <a target=\"_blank\" href=\"%s\">Simple Download Monitor</a> "
92
+ "plugin setup instructions and tutorials to learn how to configure and use it."
93
+ msgstr ""
94
+ "Por favor lee las instrucciones y los tutoriales de instalación del plugin "
95
+ "<a target=\"_blank\" href=\"%s\">Simple Download Monitor</a> para obtener "
96
+ "información sobre cómo configurarlo y usarlo."
97
 
98
+ #: includes/sdm-admin-menu-handler.php:131
99
+ #, php-format
100
+ msgid ""
101
+ "Want additional functionality? Check out our <a target=\"_blank\" href=\"%s"
102
+ "\">Add-Ons!</a>"
103
+ msgstr ""
104
+ "¿Quieres funcionalidad adicional? ¡Echa un vistazo a nuestras <a target="
105
+ "\"_blank\" href=\"%s\">extensiones!</a>"
106
 
107
+ #: includes/sdm-admin-menu-handler.php:135
108
+ msgid "Rate Us"
109
+ msgstr "Valóranos"
110
 
111
+ #: includes/sdm-admin-menu-handler.php:137
112
+ #, php-format
113
+ msgid ""
114
+ "Like the plugin? Please give us a <a href=\"%s\" target=\"_blank\">rating!</"
115
+ "a>"
116
+ msgstr ""
117
+ "¿Te gusta el plugin? ¡Por favor danos una <a href=\"%s\" target=\"_blank"
118
+ "\">puntuación!</a>"
119
 
120
+ #: includes/sdm-admin-menu-handler.php:150
121
+ msgid "Our Other Plugins"
122
+ msgstr "Nuestros otros plugins"
123
 
124
+ #: includes/sdm-admin-menu-handler.php:152
125
+ #, php-format
126
+ msgid "Check out <a target=\"_blank\" href=\"%s\">our other plugins</a>"
127
+ msgstr ""
128
+ "Echa un vistazo a <a target=\"_blank\" href=\"%s\">nuestros otros plugins</a>"
129
 
130
+ #: includes/sdm-admin-menu-handler.php:156
131
+ msgid "Social"
132
+ msgstr "Social"
133
 
134
+ #: includes/sdm-admin-menu-handler.php:158
135
+ #, php-format
136
+ msgid "<a target=\"_blank\" href=\"%s\">Facebook</a>"
137
+ msgstr "<a target=\"_blank\" href=\"%s\">Facebook</a>"
138
 
139
+ #: includes/sdm-admin-menu-handler.php:159
140
+ #, php-format
141
+ msgid "<a target=\"_blank\" href=\"%s\">Twitter</a>"
142
+ msgstr "<a target=\"_blank\" href=\"%s\">Twitter</a>"
143
 
144
+ #: includes/sdm-admin-menu-handler.php:166
145
+ msgid ""
146
+ "If you need a feature rich and supported plugin for selling your digital "
147
+ "items then checkout our"
148
+ msgstr ""
149
+ "Si usted necesita una característica rica y un plugin compatible para la "
150
+ "venta de sus artículos digitales entonces echa un vistazo a nuestra"
151
 
152
+ #: includes/sdm-admin-menu-handler.php:166
153
+ msgid "WP eStore Plugin"
154
+ msgstr "WP eStore Plugin"
155
 
156
+ #: includes/sdm-admin-menu-handler.php:239
157
+ msgid "Are you sure want to delete all plugin's data and deactivate plugin?"
158
+ msgstr ""
159
+ "¿Seguro que quieres eliminar todos los datos del plugin y desactivar el "
160
+ "plugin?"
161
 
162
+ #: includes/sdm-admin-menu-handler.php:244
163
+ msgid ""
164
+ "Data has been deleted and plugin deactivated. Click OK to go to Plugins page."
165
+ msgstr ""
166
+ "Los datos han sido eliminados y el plugin desactivado. Haz clic en Aceptar "
167
+ "para ir a la página de plugins."
168
 
169
+ #: includes/sdm-admin-menu-handler.php:248
170
+ msgid "Error occurred."
171
+ msgstr "Ha ocurrido un error."
172
 
173
+ #: includes/sdm-admin-menu-handler.php:301
174
+ msgid "Main Logs"
175
+ msgstr "Registros principales"
176
 
177
+ #: includes/sdm-admin-menu-handler.php:302
178
+ msgid "Specific Item Logs"
179
+ msgstr "Registros de elementos específicos"
180
 
181
+ #: includes/sdm-admin-menu-handler.php:349
182
+ msgid "Log entries exported! Click on the following link to download the file."
183
+ msgstr ""
184
+ "¡Entradas de registro exportadas! Haz clic en el siguiente enlace para "
185
+ "descargar el archivo."
186
 
187
+ #: includes/sdm-admin-menu-handler.php:350
188
+ msgid "Download Logs CSV File"
189
+ msgstr "Descarga los archivo CSV de registros"
 
190
 
191
+ #: includes/sdm-admin-menu-handler.php:360
192
+ msgid "Download log entries deleted!"
193
+ msgstr "¡Descarga las entradas de registro borradas!"
194
 
195
+ #: includes/sdm-admin-menu-handler.php:371
196
+ msgid "Download Logs"
197
+ msgstr "Descargar Registros"
198
 
199
+ #: includes/sdm-admin-menu-handler.php:374
200
+ msgid "This page lists all tracked downloads."
201
+ msgstr "Esta página muestra todas las descargas de rastreadores."
202
 
203
+ #: includes/sdm-admin-menu-handler.php:381
204
+ msgid "Export Download Log Entries"
205
+ msgstr "Exporta las entradas de registro de descarga"
 
 
 
 
206
 
207
+ #: includes/sdm-admin-menu-handler.php:385
208
+ msgid "Export Log Entries to CSV File"
209
+ msgstr "Exporta las entradas de registro a un archivo CSV"
 
210
 
211
+ #: includes/sdm-admin-menu-handler.php:393
212
+ msgid "Reset Download Log Entries"
213
+ msgstr "Restablecer las entradas de descarga de registro"
214
 
215
+ #: includes/sdm-admin-menu-handler.php:397
216
+ msgid "Reset Log Entries"
217
+ msgstr "Restablecer las entradas de registro"
218
 
219
+ #: includes/sdm-admin-menu-handler.php:476
220
+ msgid "Choose Date Range (yyyy-mm-dd)"
221
+ msgstr "Elige rango de fecha (aaaa-mm-dd)"
222
 
223
+ #: includes/sdm-admin-menu-handler.php:480
224
+ msgid "Start Date: "
225
+ msgstr "Fecha de comienzo "
 
 
 
 
226
 
227
+ #: includes/sdm-admin-menu-handler.php:481
228
+ msgid "End Date: "
229
+ msgstr "Fecha de finalización: "
230
 
231
+ #: includes/sdm-admin-menu-handler.php:483
232
+ msgid "This Month"
233
+ msgstr "Este mes"
234
 
235
+ #: includes/sdm-admin-menu-handler.php:484
236
+ msgid "Last Month"
237
+ msgstr "El mes pasado"
238
 
239
+ #: includes/sdm-admin-menu-handler.php:485
240
+ msgid "This Year"
241
+ msgstr "Este año"
242
 
243
+ #: includes/sdm-admin-menu-handler.php:486
244
+ msgid "Last Year"
245
+ msgstr "El año pasado"
246
 
247
+ #: includes/sdm-admin-menu-handler.php:487
248
+ msgid "All Time"
249
+ msgstr "Todo el tiempo"
250
 
251
+ #: includes/sdm-admin-menu-handler.php:490
252
+ msgid "View Stats"
253
+ msgstr "Ver estadísticas"
254
 
255
+ #: includes/sdm-admin-menu-handler.php:496
256
+ msgid "Downloads by date"
257
+ msgstr "Descargas por fecha"
 
258
 
259
+ #: includes/sdm-admin-menu-handler.php:497
260
+ msgid "Downloads by country"
261
+ msgstr "Descargas por país"
262
 
263
+ #: includes/sdm-admin-menu-handler.php:498
264
+ msgid "Downloads by country list"
265
+ msgstr "Descargas por lista de países"
266
 
267
+ #: includes/sdm-admin-menu-handler.php:508
268
  msgid ""
269
+ "Enter your Google Maps API Key <a href=\"edit.php?"
270
+ "post_type=sdm_downloads&page=sdm-settings&action=advanced-"
271
+ "settings#maps_api_key\" target=\"_blank\">in the settings</a> to properly "
272
+ "display the chart."
273
  msgstr ""
274
+ "Introduce tu clave API de Google Maps <a href=\"edit.php?"
275
+ "post_type=sdm_downloads&page=sdm-settings&action=advanced-"
276
+ "settings#maps_api_key\" target=\"_blank\">en los ajustes</a> para mostrar el "
277
+ "gráfico correctamente."
278
+
279
+ #: includes/sdm-admin-menu-handler.php:519
280
+ #: includes/sdm-admin-menu-handler.php:539
281
+ msgid "Country Name"
282
+ msgstr "Nombre del país"
283
+
284
+ #: includes/sdm-admin-menu-handler.php:520
285
+ #: includes/sdm-admin-menu-handler.php:540
286
+ msgid "Total Downloads"
287
+ msgstr "Descargas totales"
288
+
289
+ #: includes/sdm-admin-menu-handler.php:580 includes/sdm-logs-list-table.php:73
290
+ msgid "Date"
291
+ msgstr "Fecha"
292
 
293
+ #: includes/sdm-admin-menu-handler.php:581
294
+ msgid "Number of downloads"
295
+ msgstr "Número de descargas"
296
 
297
+ #: includes/sdm-admin-menu-handler.php:585
298
+ msgid "Downloads by Date"
299
+ msgstr "Descargas por fecha"
300
+
301
+ #: includes/sdm-blocks.php:28
302
+ msgid "Default"
303
+ msgstr "Por defecto"
304
+
305
+ #: includes/sdm-blocks.php:37
306
+ msgid "SDM Download"
307
+ msgstr "Descarga de SDM"
308
+
309
+ #: includes/sdm-blocks.php:38
310
+ msgid "Download Item"
311
+ msgstr "Elemento de descarga"
312
+
313
+ #: includes/sdm-blocks.php:39
314
+ msgid "Select download item."
315
+ msgstr "Selecciona el elemento de descarga."
316
 
317
+ #: includes/sdm-blocks.php:40
318
+ msgid "Button Text"
319
+ msgstr "Texto del botón"
320
+
321
+ #: includes/sdm-blocks.php:41
322
  msgid ""
323
+ "Customized text for the download button. Leave it blank to use default text."
 
 
324
  msgstr ""
325
+ "Texto personalizado para el botón de descarga. Déjalo en blanco para usar el "
326
+ "texto por defecto."
 
 
327
 
328
+ #: includes/sdm-blocks.php:42
329
+ msgid "Template"
330
+ msgstr "Plantilla"
331
 
332
+ #: includes/sdm-blocks.php:43
333
+ msgid "Select download item template."
334
+ msgstr "Selecciona la plantilla de elemento de descarga."
335
 
336
+ #: includes/sdm-blocks.php:44
337
+ msgid "Open Download in a New Window"
338
+ msgstr "Abrir la descarga en una nueva ventana"
339
 
340
+ #: includes/sdm-blocks.php:45 main.php:268
341
+ msgid "Button Color"
342
+ msgstr "Color del botón"
343
 
344
+ #: includes/sdm-blocks.php:46
345
+ msgid ""
346
+ "Select button color. Note that this option may not work for some templates."
347
+ msgstr ""
348
+ "Selecciona el color del botón. Ten en cuenta que esta opción puede no "
349
+ "funcionar para algunas plantillas."
350
 
351
+ #: includes/sdm-blocks.php:86
352
+ msgid "Select item to view"
353
+ msgstr "Selecciona el elemento para ver"
354
 
355
+ #: includes/sdm-blocks.php:107
356
+ msgid "(Select item)"
357
+ msgstr "(Selecciona un elemento)"
358
 
359
+ #: includes/sdm-download-request-handler.php:13
360
+ msgid "Error! Incorrect download item id."
361
+ msgstr "¡Error! El id de elemento de descarga es incorrecto."
362
 
363
+ #: includes/sdm-download-request-handler.php:16
364
+ #, php-format
365
+ msgid ""
366
+ "Error! This download item (%s) does not have any download link. Edit this "
367
+ "item and specify a downloadable file URL for it."
368
+ msgstr ""
369
+ "¡Error! El elemento de descarga (%s) no tiene ningún enlace de descarga. "
370
+ "Edita este elemento y especifica la URL de un archivo descargable para él."
371
 
372
+ #: includes/sdm-download-request-handler.php:30
373
+ msgid "Error! This download requires a password."
374
+ msgstr "¡Error! Esta descarga requiere una contraseña."
375
 
376
+ #: includes/sdm-download-request-handler.php:32 main.php:890 main.php:892
377
+ msgid "Click here"
378
+ msgstr "Haz clic aquí"
379
 
380
+ #: includes/sdm-download-request-handler.php:33
381
+ msgid " and enter a valid password for this item"
382
+ msgstr " e introduce una contraseña válida para este elemento"
383
 
384
+ #: includes/sdm-download-request-handler.php:41
385
+ msgid "Error! Incorrect password. This download requires a valid password."
386
+ msgstr ""
387
+ "¡Error! Contraseña incorrecta. Esta descarga requiere una contraseña válida."
388
 
389
+ #: includes/sdm-download-request-handler.php:79
390
+ msgid "__Click here__ to go to login page."
391
+ msgstr "__Hacer clic aquí__ para ir a la página de acceso."
392
 
393
+ #: includes/sdm-download-request-handler.php:82
394
+ msgid "You need to be logged in to download this file."
395
+ msgstr "Debes estar conectado para bajar este archivo."
396
 
397
+ #: includes/sdm-download-request-handler.php:86
398
+ msgid "Not Logged In"
399
+ msgstr "No estás conectado"
400
 
401
+ #: includes/sdm-download-request-handler.php:144
402
+ msgid "Error! Failed to log the download request in the database table"
403
+ msgstr ""
404
+ "¡Error! No se pudo registrar la solicitud de descarga en la tabla de base de "
405
+ "datos"
406
 
407
+ #: includes/sdm-download-request-handler.php:216
408
+ #: includes/sdm-download-request-handler.php:220
409
+ msgid "ERROR:"
410
+ msgstr "ERROR:"
411
 
412
+ #: includes/sdm-download-request-handler.php:216
413
+ #: includes/sdm-download-request-handler.php:220
414
+ msgid "Google reCAPTCHA verification failed."
415
+ msgstr "La verificación del Google reCAPTCHA falló."
416
 
417
+ #: includes/sdm-download-request-handler.php:216
418
+ #: includes/sdm-download-request-handler.php:220
419
+ msgid "Back"
420
+ msgstr "Volver"
421
 
422
+ #: includes/sdm-download-request-handler.php:220
423
+ msgid "Do you have JavaScript enabled?"
424
+ msgstr "¿Tienes Javascript activado?"
425
 
426
+ #: includes/sdm-latest-downloads.php:43 includes/sdm-popular-downloads.php:43
427
+ msgid "There are no download items matching this shortcode criteria."
428
+ msgstr ""
429
+ "No hay elementos de descarga que coincidan con estos criterios de shortcode."
430
 
431
+ #: includes/sdm-logs-list-table.php:19
432
+ #: includes/templates/fancy1/sdm-fancy-1.php:140
433
+ #: sdm-post-type-content-handler.php:98 sdm-shortcodes.php:172
 
434
  msgid "Download"
435
  msgstr "Bajada"
436
 
437
+ #: includes/sdm-logs-list-table.php:20
438
+ #: includes/templates/fancy1/sdm-fancy-1.php:140 main.php:1160
439
+ #: sdm-post-type-and-taxonomy.php:7 sdm-post-type-and-taxonomy.php:8
440
+ #: sdm-post-type-and-taxonomy.php:13 sdm-post-type-and-taxonomy.php:19
441
+ #: sdm-post-type-content-handler.php:98 sdm-shortcodes.php:172
442
+ msgid "Downloads"
443
+ msgstr "Descarga"
444
+
445
+ #: includes/sdm-logs-list-table.php:45
446
  msgid "Edit"
447
  msgstr "Editar"
448
 
449
+ #: includes/sdm-logs-list-table.php:46
450
  msgid "Delete"
451
  msgstr "Borrar"
452
 
453
+ #: includes/sdm-logs-list-table.php:70 main.php:1154
 
454
  msgid "Title"
455
  msgstr "Titulo"
456
 
457
+ #: includes/sdm-logs-list-table.php:71 main.php:1157
 
458
  msgid "File"
459
  msgstr "Archivo"
460
 
461
+ #: includes/sdm-logs-list-table.php:72
462
  msgid "Visitor IP"
463
  msgstr "IP del Visitante"
464
 
465
+ #: includes/sdm-logs-list-table.php:74
 
 
 
 
466
  msgid "Country"
467
  msgstr "País"
468
 
469
+ #: includes/sdm-logs-list-table.php:75
470
+ msgid "Username"
471
+ msgstr "Nombre de usuario"
472
+
473
+ #: includes/sdm-logs-list-table.php:96
474
  msgid "Delete Permanently"
475
  msgstr "Borrar Permanente"
476
 
477
+ #: includes/sdm-logs-list-table.php:111 includes/sdm-logs-list-table.php:142
 
 
 
 
478
  msgid "Nope! Security check failed!"
479
  msgstr "¡No! ¡Control de seguridad falló!"
480
 
481
+ #: includes/sdm-logs-list-table.php:115
 
 
 
 
482
  msgid "No entries were selected."
483
  msgstr "No se seleccionaron entradas."
484
 
485
+ #: includes/sdm-logs-list-table.php:115 includes/sdm-logs-list-table.php:129
486
+ #: includes/sdm-logs-list-table.php:131 includes/sdm-logs-list-table.php:151
487
+ #: includes/sdm-logs-list-table.php:153
 
 
488
  msgid "Click to Dismiss"
489
  msgstr "Haga clic para Descartar"
490
 
491
+ #: includes/sdm-logs-list-table.php:122
492
+ msgid "Error! The row id value of a log entry must be numeric."
493
+ msgstr ""
494
+ "¡Error! El valor de identificación de la fila de una entrada de registro "
495
+ "debe ser numérico."
496
+
497
+ #: includes/sdm-logs-list-table.php:129
498
  msgid "Entries Deleted!"
499
  msgstr "¡Entradas Eliminadas!"
500
 
501
+ #: includes/sdm-logs-list-table.php:131 includes/sdm-logs-list-table.php:153
 
502
  msgid "Error"
503
  msgstr "Error"
504
 
505
+ #: includes/sdm-logs-list-table.php:151
506
  msgid "Entry Deleted!"
507
  msgstr "¡Entrada Eliminada!"
508
 
509
+ #: includes/sdm-search-shortcode-handler.php:65
510
+ msgid "Showing search results for "
511
+ msgstr "Mostrando los resultados de búsqueda para "
512
 
513
+ #: includes/sdm-search-shortcode-handler.php:66
514
+ msgid "Number of items found: "
515
+ msgstr "Número de elementos encontrados: "
516
+
517
+ #: includes/sdm-search-shortcode-handler.php:67
518
+ msgid "Keywords searched: "
519
+ msgstr "Palabras clave buscadas: "
520
+
521
+ #: includes/sdm-search-shortcode-handler.php:70
522
+ msgid "Nothing found for "
523
+ msgstr "No he encontrado nada para "
524
+
525
+ #: includes/sdm-utility-functions.php:9
526
+ msgid "Green"
527
+ msgstr "Verde"
528
+
529
+ #: includes/sdm-utility-functions.php:10
530
+ msgid "Blue"
531
+ msgstr "Azul"
532
+
533
+ #: includes/sdm-utility-functions.php:11
534
+ msgid "Purple"
535
+ msgstr "Púrpura"
536
+
537
+ #: includes/sdm-utility-functions.php:12
538
+ msgid "Teal"
539
+ msgstr "Verde Azulado"
540
+
541
+ #: includes/sdm-utility-functions.php:13
542
+ msgid "Dark Blue"
543
+ msgstr "Azul Oscuro"
544
+
545
+ #: includes/sdm-utility-functions.php:14
546
+ msgid "Black"
547
+ msgstr "Negro"
548
+
549
+ #: includes/sdm-utility-functions.php:15
550
+ msgid "Grey"
551
+ msgstr "Gris"
552
+
553
+ #: includes/sdm-utility-functions.php:16
554
+ msgid "Pink"
555
+ msgstr "Rosa"
556
+
557
+ #: includes/sdm-utility-functions.php:17
558
+ msgid "Orange"
559
+ msgstr "Naranja"
560
+
561
+ #: includes/sdm-utility-functions.php:18
562
+ msgid "White"
563
+ msgstr "Blanco"
564
 
565
+ #: includes/sdm-utility-functions.php:57
566
  msgid "Enter Password to Download:"
567
  msgstr "Introduzca La Contraseña Para Descargar:"
568
 
569
+ #: includes/sdm-utility-functions.php:263
570
+ msgid "I agree to the "
571
+ msgstr "Estoy de acuerdo con los "
572
 
573
+ #: includes/sdm-utility-functions.php:263
574
+ msgid "terms and conditions"
575
+ msgstr "términos y condiciones"
 
 
576
 
577
+ #: includes/sdm-utility-functions.php:298
578
+ #: includes/templates/fancy0/sdm-fancy-0.php:97
579
+ #: includes/templates/fancy1/sdm-fancy-1.php:56
580
+ #: includes/templates/fancy2/sdm-fancy-2.php:82 sdm-shortcodes.php:186
581
+ msgid "Download Now!"
582
+ msgstr "Bajar Ahora!"
583
+
584
+ #: includes/sdm-utility-functions.php:338
585
  msgid ""
586
  "Error! The URL value is empty. Please specify a correct URL value to "
587
  "redirect to!"
589
  "¡Error ! El valor URL está vacío. ¡Por favor, especifique un valor URL "
590
  "correcto para redirigir a!"
591
 
592
+ #: includes/templates/fancy0/sdm-fancy-0.php:84
593
+ #: sdm-post-type-content-handler.php:56
594
+ msgid "green"
595
+ msgstr "verde"
596
 
597
+ #: includes/templates/fancy1/sdm-fancy-1.php:159
598
+ #: includes/templates/fancy2/sdm-fancy-2.php:176
599
+ #: sdm-post-type-content-handler.php:135
600
+ msgid "Size: "
601
+ msgstr "Tamaño: "
602
+
603
+ #: includes/templates/fancy1/sdm-fancy-1.php:166
604
+ #: includes/templates/fancy2/sdm-fancy-2.php:183 main.php:508
605
+ #: sdm-post-type-content-handler.php:142
606
+ msgid "Version: "
607
+ msgstr "Version: "
608
+
609
+ #: includes/templates/fancy1/sdm-fancy-1.php:173
610
+ #: includes/templates/fancy2/sdm-fancy-2.php:190
611
+ #: sdm-post-type-content-handler.php:149
612
+ msgid "Published: "
613
+ msgstr "Publicado: "
614
+
615
+ #: includes/templates/fancy3/sdm-fancy-3.php:55
616
+ #: includes/templates/fancy3/sdm-fancy-3.php:86
617
+ msgid "View Details"
618
+ msgstr "Ver detalles"
619
+
620
+ #: main.php:249 main.php:345
621
+ msgid "Select File"
622
+ msgstr "Selecciona Archivo"
623
 
624
+ #: main.php:250
625
+ msgid "Select Thumbnail"
626
+ msgstr "Selecciona miniatura"
627
+
628
+ #: main.php:251
629
+ msgid "Insert"
630
+ msgstr "Insertar"
631
+
632
+ #: main.php:252
633
+ msgid "Image Successfully Removed"
634
+ msgstr "Imagen Eliminado Con Éxito"
635
+
636
+ #: main.php:253
637
+ msgid "Error with AJAX"
638
+ msgstr "Error con AJAX"
639
+
640
+ #: main.php:264
641
+ msgid "Please select a Download Item:"
642
+ msgstr "Por favor seleccione una Descarga De Artículo:"
643
+
644
+ #: main.php:265
645
+ msgid "Download Title"
646
+ msgstr "Titulo Descarga"
647
+
648
+ #: main.php:266
649
+ msgid "Include Fancy Box"
650
+ msgstr "Incluya Caja de Visión"
651
+
652
+ #: main.php:267
653
+ msgid "Open New Window"
654
+ msgstr "Abrir una nueva ventana"
655
+
656
+ #: main.php:269
657
+ msgid "Insert SDM Shortcode"
658
+ msgstr "Inserte Código Corto De SDM"
659
+
660
+ #: main.php:311
661
+ msgid "Description"
662
+ msgstr "Descripción"
663
+
664
+ #: main.php:312
665
+ msgid "Downloadable File (Visitors will download this item)"
666
+ msgstr "Archivo descargable (Los visitantes descargarán este elemento)"
667
+
668
+ #: main.php:313
669
+ msgid "PHP Dispatch or Redirect"
670
+ msgstr "Envío PHP o Redirigir"
671
+
672
+ #: main.php:314
673
+ msgid "Miscellaneous Download Item Properties"
674
+ msgstr "Otras propiedades del elemento de descarga"
675
+
676
+ #: main.php:315
677
+ msgid "File Thumbnail (Optional)"
678
+ msgstr "Archivo Miniatura (Opcional)"
679
+
680
+ #: main.php:316
681
+ msgid "Statistics"
682
+ msgstr "Estadísticas"
683
+
684
+ #: main.php:318
685
+ msgid "Other Details (Optional)"
686
+ msgstr "Otros detalles (Opcional)"
687
+
688
+ #: main.php:319
689
+ msgid "Shortcodes"
690
+ msgstr "Código Corto"
691
+
692
+ #: main.php:323
693
+ msgid "Add a description for this download item."
694
+ msgstr "Añadir una descripción para este articulo de descarga."
695
+
696
+ #: main.php:337
697
+ msgid ""
698
+ "Manually enter a valid URL of the file in the text box below, or click "
699
+ "\"Select File\" button to upload (or choose) the downloadable file."
700
+ msgstr ""
701
+ "Introduce manualmente una URL válida del archivo en el cuadro de texto "
702
+ "siguiente, o haz clic en el botón \"Seleccionar archivo\" para cargar (o "
703
+ "elegir) el archivo descargable."
704
+
705
+ #: main.php:348
706
+ msgid "Steps to upload a file or choose one from your media library:"
707
+ msgstr "Pasos para subir un archivo o elegir uno de tu biblioteca de medios:"
708
+
709
+ #: main.php:350
710
+ msgid "Hit the \"Select File\" button."
711
+ msgstr "Haz clic en el botón \"Seleccionar archivo\"."
712
+
713
+ #: main.php:351
714
+ msgid "Upload a new file or choose an existing one from your media library."
715
+ msgstr ""
716
+ "Sube un archivo nuevo o elije uno existente de tu biblioteca de medios."
717
+
718
+ #: main.php:352
719
+ msgid ""
720
+ "Click the \"Insert\" button, this will populate the uploaded file's URL in "
721
+ "the above text field."
722
+ msgstr ""
723
+ "Haz clic en el botón \"Insertar\", esto completará la URL del archivo subido "
724
+ "en el campo de texto de arriba."
725
+
726
+ #: main.php:373
727
+ msgid ""
728
+ "Dispatch the file via PHP directly instead of redirecting to it. PHP "
729
+ "Dispatching keeps the download URL hidden. Dispatching works only for local "
730
+ "files (files that you uploaded to this site via this plugin or media "
731
+ "library)."
732
+ msgstr ""
733
+ "Envía el archivo a través de PHP directamente en lugar de redirigir a él. "
734
+ "Envíos PHP mantiene oculta la URL de descarga. El envío funciona solo para "
735
+ "archivos locales (archivos que has subido en este sitio a través de este "
736
+ "plugin o biblioteca de medios)."
737
+
738
+ #: main.php:397
739
+ msgid "Open download in a new window."
740
+ msgstr "Abrir la descarga en una nueva ventana."
741
+
742
+ #: main.php:403
743
+ msgid "Hide the download button on the single download page of this item."
744
+ msgstr "Oculta el botón de descarga en la página de descarga de este elemento."
745
+
746
+ #: main.php:409
747
+ msgid "Disable the single download page for this download item. "
748
+ msgstr ""
749
+ "Desactiva la página individual de descarga para este elemento de descarga. "
750
+
751
+ #: main.php:410
752
+ msgid "This can be useful if you are using an addon like the "
753
+ msgstr "Esto puede ser útil si usas una extensión como "
754
+
755
+ #: main.php:421
756
+ msgid ""
757
+ "Manually enter a valid URL, or click \"Select Image\" to upload (or choose) "
758
+ "the file thumbnail image."
759
+ msgstr ""
760
+ "Introduce manualmente una dirección URL válida, o haz clic en «Seleccionar "
761
+ "imagen» para subir (o elegir) la imagen en miniatura del archivo."
762
+
763
+ #: main.php:426
764
+ msgid "Select Image"
765
+ msgstr "Selecciona Imagen"
766
+
767
+ #: main.php:427
768
+ msgid "Remove Image"
769
+ msgstr "Eliminar Imagen"
770
+
771
+ #: main.php:441
772
+ msgid ""
773
+ "This thumbnail image will be used to create a fancy file download box if you "
774
+ "want to use it."
775
+ msgstr ""
776
+ "Esta imagen en miniatura se utilizará para crear un cuadro de descarga de "
777
+ "archivos de lujo si quieres usarlo."
778
+
779
+ #: main.php:455
780
+ msgid "These are the statistics for this download item."
781
+ msgstr "Estas son las estadísticas sobre este articulo descarga."
782
+
783
+ #: main.php:462
784
+ msgid "Number of Downloads:"
785
+ msgstr "Numero de Descargas:"
786
+
787
+ #: main.php:467
788
+ msgid "Offset Count: "
789
+ msgstr "Recuento de desplazamiento: "
790
+
791
+ #: main.php:470
792
+ msgid ""
793
+ "Enter any positive or negative numerical value; to offset the download count "
794
+ "shown to the visitors (when using the download counter shortcode)."
795
+ msgstr ""
796
+ "Introduce cualquier valor numérico positivo o negativo; para compensar el "
797
+ "conteo de descargas mostrado a los visitantes (cuando se usa el shortcode "
798
+ "del contador de descargas)."
799
+
800
+ #: main.php:477
801
+ msgid "Disable download logging for this item."
802
+ msgstr "Desactivar el registro de descarga para este elemento."
803
+
804
+ #: main.php:498
805
+ msgid "File Size: "
806
+ msgstr "Tamaño del archivo: "
807
+
808
+ #: main.php:501
809
+ msgid "Enter the size of this file (example value: 2.15 MB)."
810
+ msgstr "Introduce el tamaño de este archivo (valor de ejemplo: 2.15 MB)."
811
+
812
+ #: main.php:503
813
+ msgid "Show file size in fancy display."
814
+ msgstr "Mostrar el tamaño del archivo en una pantalla amigable."
815
+
816
+ #: main.php:511
817
+ msgid "Enter the version number for this item if any (example value: v2.5.10)."
818
+ msgstr ""
819
+ "Introduce el número de versión para este artículo si lo hay (valor de "
820
+ "ejemplo: v2.5.10)."
821
+
822
+ #: main.php:513
823
+ msgid "Show version number in fancy display."
824
+ msgstr "Mostrar el número de versión en una pantalla amigable."
825
+
826
+ #: main.php:518
827
+ msgid "Publish Date: "
828
+ msgstr "Fecha de publicación: "
829
+
830
+ #: main.php:520
831
+ msgid "Show download published date in fancy display."
832
+ msgstr ""
833
+ "Mostrar la fecha de publicación de la descarga en una pantalla amigable."
834
+
835
+ #: main.php:525
836
+ msgid "Download Button Text: "
837
+ msgstr "Texto del botón de descarga: "
838
+
839
+ #: main.php:528
840
+ msgid ""
841
+ "You can use this field to customize the download now button text of this "
842
+ "item."
843
+ msgstr ""
844
+ "Puedes usar este campo para personalizar el texto del botón descargar ahora "
845
+ "de este elemento."
846
+
847
+ #: main.php:535
848
+ msgid ""
849
+ "The following shortcode can be used on posts or pages to embed a download "
850
+ "now button for this file. You can also use the shortcode inserter (in the "
851
+ "post editor) to add this shortcode to a post or page."
852
+ msgstr ""
853
+ "Puedes utilizar el siguiente shortcode en entradas o páginas para incrustar "
854
+ "el botón Descarga ahora para este archivo. También puedes usar el shortcode "
855
+ "de insertar (en el editor de entradas) para agregar este shortcode a una "
856
+ "entrada o página."
857
+
858
+ #: main.php:541
859
+ msgid ""
860
+ "The following shortcode can be used to show a download counter for this item."
861
+ msgstr ""
862
+ "El siguiente shortcode se puede usar para mostrar el contador de la descarga "
863
+ "de este elemento."
864
+
865
+ #: main.php:547
866
+ msgid ""
867
+ "Read the full shortcode usage documentation <a href=\"https://www."
868
+ "tipsandtricks-hq.com/simple-wordpress-download-monitor-plugin\" target="
869
+ "\"_blank\">here</a>."
870
+ msgstr ""
871
+ "Lee la documentación completa del uso del shortcode <a href=\"https://www."
872
+ "tipsandtricks-hq.com/simple-wordpress-download-monitor-plugin\" target="
873
+ "\"_blank\">aquí</a>."
874
+
875
+ #: main.php:684
876
+ msgid "General Options"
877
+ msgstr "Opciones generales"
878
+
879
+ #: main.php:685
880
+ msgid "User Login Related"
881
+ msgstr "Relacionado con el acceso de usuarios"
882
+
883
+ #: main.php:686
884
+ msgid "Admin Options"
885
+ msgstr "Opciones Del Administrador"
886
+
887
+ #: main.php:688
888
+ msgid "Colors"
889
+ msgstr "Colores"
890
+
891
+ #: main.php:689
892
+ msgid "Debug"
893
+ msgstr "Depuración"
894
+
895
+ #: main.php:690
896
+ msgid "Delete Plugin Data"
897
+ msgstr "Borrar los datos del plugin"
898
+
899
+ #: main.php:693
900
+ msgid "Hide Download Count"
901
+ msgstr "Oculta el conteo de descarga"
902
+
903
+ #: main.php:694
904
+ msgid "PHP Dispatching"
905
+ msgstr "Envíos PHP"
906
+
907
+ #: main.php:696
908
+ msgid "Only Allow Logged-in Users to Download"
909
+ msgstr "Sólo permite a los usuarios conectados descargar"
910
+
911
+ #: main.php:697
912
+ msgid "Login Page URL"
913
+ msgstr "URL de la página de acceso"
914
+
915
+ #: main.php:698
916
+ msgid "Redirect Users to Download Page"
917
+ msgstr "Redirigir usuarios de vuelta a la página de descarga"
918
+
919
+ #: main.php:700
920
+ msgid "Remove Tinymce Button"
921
+ msgstr "Eliminar El Botón Tinymce"
922
+
923
+ #: main.php:701
924
+ msgid "Log Unique IP"
925
+ msgstr "Registrar IP único"
926
+
927
+ #: main.php:702
928
+ msgid "Do Not Capture IP Address"
929
+ msgstr "No capturar la dirección IP"
930
+
931
+ #: main.php:703
932
+ msgid "Do Not Count Downloads from Bots"
933
+ msgstr "No cuentes las descargas de bots"
934
+
935
+ #: main.php:704
936
+ msgid "Disable Download Logs"
937
+ msgstr "Desactiva la bajada de los registros"
938
+
939
+ #: main.php:706
940
+ msgid "Download Button Color"
941
+ msgstr "Color Del Botón De Descarga"
942
+
943
+ #: main.php:708
944
+ msgid "Enable Debug"
945
+ msgstr "Activar depuración"
946
+
947
+ #: main.php:714
948
+ msgid "Google Captcha (reCAPTCHA)"
949
+ msgstr "Google Captcha (reCAPTCHA)"
950
+
951
+ #: main.php:715
952
+ msgid "Terms and Conditions"
953
+ msgstr "Términos y Condiciones"
954
+
955
+ #: main.php:716
956
+ msgid "Adsense/Ad Insertion"
957
+ msgstr "Adsense/inserción del anuncio"
958
+
959
+ #: main.php:717
960
+ msgid "Google Maps API Key"
961
+ msgstr "Clave API de Google Maps"
962
+
963
+ #: main.php:720
964
+ msgid "Enable reCAPTCHA"
965
+ msgstr "Activar reCAPTCHA"
966
+
967
+ #: main.php:721
968
+ msgid "Site Key"
969
+ msgstr "Clave del sitio"
970
+
971
+ #: main.php:722
972
+ msgid "Secret Key"
973
+ msgstr "Clave secreta"
974
+
975
+ #: main.php:725
976
+ msgid "Enable Terms and Conditions"
977
+ msgstr "Activar términos y condiciones"
978
+
979
+ #: main.php:726
980
+ msgid "Terms Page URL"
981
+ msgstr "URL de la página de Términos"
982
+
983
+ #: main.php:729
984
+ msgid "Below Download Description"
985
+ msgstr "A continuación la descripción de descarga"
986
+
987
+ #: main.php:732
988
+ msgid "API Key"
989
+ msgstr "Clave API"
990
+
991
+ #: main.php:737
992
+ msgid "General options settings"
993
+ msgstr "Ajustes de opciones generales"
994
+
995
+ #: main.php:742
996
+ msgid ""
997
+ "Visitor login related settings (useful if you only want to allow logged-in "
998
+ "users to be able to download files."
999
+ msgstr ""
1000
+ "Ajustes relacionados con el acceso de visitantes (útil si solo quieres "
1001
+ "permitir a los usuarios conectados poder descargar archivos)."
1002
+
1003
+ #: main.php:747
1004
+ msgid "Admin options settings"
1005
+ msgstr "Configuración de las opciones administrador"
1006
+
1007
+ #: main.php:752
1008
+ msgid "Front End colors settings"
1009
+ msgstr "Ajustes de colores parte Delantera"
1010
+
1011
+ #: main.php:757
1012
+ msgid "Debug settings"
1013
+ msgstr "Ajustes de depuración"
1014
+
1015
+ #: main.php:762
1016
+ msgid ""
1017
+ "You can delete all the data related to this plugin from database using the "
1018
+ "button below. Useful when you're uninstalling the plugin and don't want any "
1019
+ "leftovers remaining."
1020
+ msgstr ""
1021
+ "Puedes eliminar todos los datos relacionados con este plugin de la base de "
1022
+ "datos utilizando el botón a continuación. Útil cuando desinstalas el plugin "
1023
+ "y no quieres que queden restos."
1024
+
1025
+ #: main.php:763
1026
+ msgid "Warning"
1027
+ msgstr "Advertencia"
1028
+
1029
+ #: main.php:763
1030
+ msgid ""
1031
+ "this can't be undone. All settings, download items, download logs will be "
1032
+ "deleted."
1033
+ msgstr ""
1034
+ "esto no puede deshacerse. Se eliminarán todos los ajustes, elementos de "
1035
+ "descarga y registros de descarga."
1036
+
1037
+ #: main.php:764
1038
+ msgid "Delete all data and deactivate plugin"
1039
+ msgstr "Borrar todo los datos y desactivar el plugin"
1040
+
1041
+ #: main.php:770
1042
+ msgid "Google Captcha (reCAPTCHA) options"
1043
+ msgstr "Opciones de Google Captcha (reCAPTCHA)"
1044
+
1045
+ #: main.php:779
1046
+ msgid ""
1047
+ "You can use this section to insert adsense or other ad code inside the "
1048
+ "download item output"
1049
+ msgstr ""
1050
+ "Puedes usar esta sección para insertar adsense u otro código de anuncio "
1051
+ "dentro de la salida del elemento de descarga"
1052
+
1053
+ #: main.php:783
1054
+ msgid ""
1055
+ "Google Maps API key is required to display the \"Downloads by Country\" "
1056
+ "chart."
1057
+ msgstr ""
1058
+ "Se requiere una clave API de Google Maps para mostrar el gráfico «Descargas "
1059
+ "por país»."
1060
+
1061
+ #: main.php:789
1062
+ msgid ""
1063
+ "Check this box if you want to use <a href=\"https://www.google.com/recaptcha/"
1064
+ "admin\" target=\"_blank\">reCAPTCHA</a>. "
1065
+ msgstr ""
1066
+ "Selecciona esta casilla si deseas utilizar <a href=\"https://www.google.com/"
1067
+ "recaptcha/admin\" target=\"_blank\">reCAPTCHA</a>. "
1068
+
1069
+ #: main.php:790
1070
+ msgid "The captcha option adds a captcha to the download now buttons."
1071
+ msgstr ""
1072
+ "La opción de captcha añade un captcha a los botones de descargar ahora."
1073
+
1074
+ #: main.php:797
1075
+ msgid "The site key for the reCAPTCHA API"
1076
+ msgstr "La clave del sitio para la API de reCAPTCHA"
1077
+
1078
+ #: main.php:804
1079
+ msgid "The secret key for the reCAPTCHA API"
1080
+ msgstr "La clave secreta para la API de reCAPTCHA"
1081
+
1082
+ #: main.php:810
1083
+ msgid "Hide the download count that is shown in some of the fancy templates."
1084
+ msgstr ""
1085
+ "Oculta el conteo de descargas que se muestra en algunas de las plantillas de "
1086
+ "lujo."
1087
+
1088
+ #: main.php:817
1089
+ msgid ""
1090
+ "When you create a new download item, The PHP Dispatching option should be "
1091
+ "enabled by default. PHP Dispatching keeps the URL of the downloadable files "
1092
+ "hidden."
1093
+ msgstr ""
1094
+ "Cuando creas un nuevo elemento de descarga, la opción de Envío PHP debe "
1095
+ "estar activada de manera por defecto. Envío PHP mantiene oculta la URL de "
1096
+ "los archivos descargables."
1097
+
1098
+ #: main.php:824
1099
+ msgid ""
1100
+ "Enable this option if you want to allow downloads only for logged-in users. "
1101
+ "When enabled, anonymous users clicking on the download button will receive "
1102
+ "an error message."
1103
+ msgstr ""
1104
+ "Activa esta opción si deseas permitir las descargas solo para usuarios "
1105
+ "conectados. Cuando está activado, los usuarios anónimos que hacen clic en el "
1106
+ "botón de descarga recibirán un mensaje de error."
1107
+
1108
+ #: main.php:831
1109
+ msgid ""
1110
+ "Only works if you have set a Login Page URL value above. Enable this option "
1111
+ "if you want to redirect the users to the download page after they log into "
1112
+ "the site."
1113
+ msgstr ""
1114
+ "Solo funciona si has configurado arriba un valor de URL de página de acceso. "
1115
+ "Activa esta opción si quieres redirigir a los usuarios de vuelta a la página "
1116
+ "de descarga después de que accedan al sitio."
1117
+
1118
+ #: main.php:838
1119
+ msgid ""
1120
+ "(Optional) Specify a login page URL where users can login. This is useful if "
1121
+ "you only allow logged in users to be able to download. This link will be "
1122
+ "added to the message that is shown to anonymous users."
1123
+ msgstr ""
1124
+ "(Opcional) Especifica una URL de la página de acceso donde los usuarios "
1125
+ "pueden acceder. Esto es útil si solo permites que los usuarios conectados "
1126
+ "puedan descargar. Este enlace se agregará al mensaje que se muestra a los "
1127
+ "usuarios anónimos."
1128
+
1129
+ #: main.php:844
1130
+ msgid "Removes the SDM Downloads button from the WP content editor."
1131
+ msgstr "Elimina el botón Descargas SDM del editor del contenido WP."
1132
+
1133
+ #: main.php:850
1134
+ msgid "Only logs downloads from unique IP addresses."
1135
+ msgstr "Sólo registra descargas de direcciones IP únicas."
1136
+
1137
+ #: main.php:856
1138
+ msgid ""
1139
+ "Use this if you do not want to capture the IP address and Country of the "
1140
+ "visitors when they download an item."
1141
+ msgstr ""
1142
+ "Utiliza esto si no deseas capturar la dirección IP y el país de los "
1143
+ "visitantes cuando descarguen un elemento."
1144
+
1145
+ #: main.php:862
1146
+ msgid "When enabled, the plugin won't count and log downloads from bots."
1147
+ msgstr ""
1148
+ "Cuando está activado, el plugin no contará y registrará las descargas de los "
1149
+ "bots."
1150
+
1151
+ #: main.php:868
1152
+ msgid ""
1153
+ "Disables all download logs. (This global option overrides the individual "
1154
+ "download item option.)"
1155
+ msgstr ""
1156
+ "Desactiva todos los registros de descarga. (Esta opción global sobreescribe "
1157
+ "la opción de descarga individual del elemento.)"
1158
+
1159
+ #: main.php:882
1160
+ msgid "Adjusts the color of the \"Download Now\" button."
1161
+ msgstr "Ajusta el color del botón de la \"Descargar Ahora\"."
1162
+
1163
+ #: main.php:888
1164
+ msgid "Check this option to enable debug logging."
1165
+ msgstr "Selecciona esta opción para activar el registro de depuración."
1166
+
1167
+ #: main.php:891
1168
+ msgid " to view log file."
1169
+ msgstr " para ver el archivo de registro."
1170
+
1171
+ #: main.php:893
1172
+ msgid " to reset log file."
1173
+ msgstr " para restablecer el archivo de registro."
1174
+
1175
+ #: main.php:899
1176
+ msgid ""
1177
+ "You can use this option to make the visitors agree to your terms before they "
1178
+ "can download the item."
1179
+ msgstr ""
1180
+ "Puedes usar esta opción para hacer que los visitantes acepten tus términos "
1181
+ "antes de que puedan descargar el artículo."
1182
+
1183
+ #: main.php:906
1184
+ msgid "Enter the URL of your terms and conditions page."
1185
+ msgstr "Introduce la URL de tu página de términos y condiciones."
1186
+
1187
+ #: main.php:914
1188
+ msgid ""
1189
+ "Enter the Adsense or Ad code that you want to show below the download item "
1190
+ "description."
1191
+ msgstr ""
1192
+ "Introduce el código de Adsense o anuncio que deseas mostrar debajo de la "
1193
+ "descripción del elemento de descarga."
1194
+
1195
+ #: main.php:921
1196
+ msgid ""
1197
+ "Enter your Google Maps API key. You can create new API key using <a href="
1198
+ "\"https://developers.google.com/maps/documentation/javascript/get-api-key\" "
1199
+ "target=\"_blank\">this instruction</a>."
1200
+ msgstr ""
1201
+ "Introduce tu clave API de Google Maps. Puedes crear una clave API nueva "
1202
+ "usando <a href=\"https://developers.google.com/maps/documentation/javascript/"
1203
+ "get-api-key\" target=\"_blank\">estas instrucciones</a>."
1204
+
1205
+ #: main.php:928
1206
+ msgid "Clone"
1207
+ msgstr "Clonar"
1208
+
1209
+ #: main.php:954
1210
+ msgid "No post to duplicate has been supplied!"
1211
+ msgstr "¡No se ha proporcionado ninguna entrada para duplicar!"
1212
+
1213
+ #: main.php:1040
1214
+ msgid "Post creation failed, could not find original post: "
1215
+ msgstr ""
1216
+ "La creación de la entrada ha fallado, no se ha podido encontrar la entrada "
1217
+ "original: "
1218
+
1219
+ #: main.php:1079
1220
+ msgid "Permission denied!"
1221
+ msgstr "¡Permiso denegado!"
1222
+
1223
+ #: main.php:1155
1224
+ msgid "Image"
1225
+ msgstr "Imagen"
1226
+
1227
+ #: main.php:1156
1228
+ msgid "ID"
1229
+ msgstr "ID"
1230
+
1231
+ #: main.php:1158 sdm-post-type-and-taxonomy.php:56
1232
+ msgid "Categories"
1233
+ msgstr "Categorías"
1234
+
1235
+ #: main.php:1159 sdm-post-type-and-taxonomy.php:80
1236
+ msgid "Tags"
1237
+ msgstr "Etiquetas"
1238
+
1239
+ #: main.php:1161
1240
+ msgid "Date Posted"
1241
  msgstr "Fecha de Publicación"
1242
 
1243
+ #: sdm-post-type-and-taxonomy.php:9 sdm-post-type-and-taxonomy.php:10
1244
+ msgid "Add New"
1245
+ msgstr "Agregar Nuevo"
1246
+
1247
+ #: sdm-post-type-and-taxonomy.php:11
1248
+ msgid "Edit Download"
1249
+ msgstr "Editar la Bajada"
1250
 
1251
+ #: sdm-post-type-and-taxonomy.php:12
1252
+ msgid "New Download"
1253
+ msgstr "Nueva Descarga"
 
 
 
1254
 
1255
+ #: sdm-post-type-and-taxonomy.php:14
1256
+ msgid "View Download"
1257
+ msgstr "Ver Descarga"
1258
+
1259
+ #: sdm-post-type-and-taxonomy.php:15
1260
+ msgid "Search Downloads"
1261
+ msgstr "Buscar En Las Bajadas"
1262
+
1263
+ #: sdm-post-type-and-taxonomy.php:16
1264
+ msgid "No Downloads found"
1265
+ msgstr "Ninguna Descarga Encontrada"
1266
+
1267
+ #: sdm-post-type-and-taxonomy.php:17
1268
+ msgid "No Downloads found in Trash"
1269
+ msgstr "Ninguna Descarga Encontrada En La Papelera"
1270
 
1271
+ #: sdm-post-type-and-taxonomy.php:18
1272
+ msgid "Parent Download"
1273
+ msgstr "Descarga principal"
1274
+
1275
+ #: sdm-post-type-and-taxonomy.php:46
1276
+ msgid "Download Categories"
1277
+ msgstr "Categorías de descargas"
1278
+
1279
+ #: sdm-post-type-and-taxonomy.php:47
1280
+ msgid "Download Category"
1281
+ msgstr "Categoría de descargas"
1282
+
1283
+ #: sdm-post-type-and-taxonomy.php:48
1284
+ msgid "Search Categories"
1285
+ msgstr "Buscar Categorías"
1286
+
1287
+ #: sdm-post-type-and-taxonomy.php:49
1288
+ msgid "All Categories"
1289
+ msgstr "Todas Las Categorías"
1290
+
1291
+ #: sdm-post-type-and-taxonomy.php:50
1292
+ msgid "Categories Genre"
1293
+ msgstr "Género De Categorías"
1294
+
1295
+ #: sdm-post-type-and-taxonomy.php:51
1296
+ msgid "Categories Genre:"
1297
+ msgstr "Género De Categorías:"
1298
+
1299
+ #: sdm-post-type-and-taxonomy.php:52
1300
+ msgid "Edit Category"
1301
+ msgstr "Editar Categoría"
1302
+
1303
+ #: sdm-post-type-and-taxonomy.php:53
1304
+ msgid "Update Category"
1305
+ msgstr "Actualizar Categoría"
1306
+
1307
+ #: sdm-post-type-and-taxonomy.php:54
1308
+ msgid "Add New Category"
1309
+ msgstr "Añade Una Categorías"
1310
+
1311
+ #: sdm-post-type-and-taxonomy.php:55
1312
+ msgid "New Category"
1313
+ msgstr "Nueva Categoría"
1314
+
1315
+ #: sdm-post-type-and-taxonomy.php:70
1316
+ msgid "Download Tags"
1317
+ msgstr "Etiquetas de descargas"
1318
+
1319
+ #: sdm-post-type-and-taxonomy.php:71
1320
+ msgid "Download Tag"
1321
+ msgstr "Etiqueta de descargas"
1322
+
1323
+ #: sdm-post-type-and-taxonomy.php:72
1324
+ msgid "Search Tags"
1325
+ msgstr "Buscar Etiquetas"
1326
+
1327
+ #: sdm-post-type-and-taxonomy.php:73
1328
+ msgid "All Tags"
1329
+ msgstr "Todas Las Etiquetas"
1330
+
1331
+ #: sdm-post-type-and-taxonomy.php:74
1332
+ msgid "Tags Genre"
1333
+ msgstr "Género De Etiquetas"
1334
+
1335
+ #: sdm-post-type-and-taxonomy.php:75
1336
+ msgid "Tags Genre:"
1337
+ msgstr "Género De Etiquetas:"
1338
+
1339
+ #: sdm-post-type-and-taxonomy.php:76
1340
+ msgid "Edit Tag"
1341
+ msgstr "Editar Etiqueta"
1342
+
1343
+ #: sdm-post-type-and-taxonomy.php:77
1344
+ msgid "Update Tag"
1345
+ msgstr "Actualizar La Etiqueta"
1346
+
1347
+ #: sdm-post-type-and-taxonomy.php:78
1348
+ msgid "Add New Tag"
1349
+ msgstr "Agrega Nueva Etiqueta"
1350
+
1351
+ #: sdm-post-type-and-taxonomy.php:79
1352
+ msgid "New Tag"
1353
+ msgstr "Nueva Etiqueta"
1354
+
1355
+ #: sdm-post-type-content-handler.php:19
1356
+ msgid "The admin of this site has disabled this download item page."
1357
+ msgstr ""
1358
+ "El administrador de este sitio ha desactivado el botón de descarga de esta "
1359
+ "página."
1360
+
1361
+ #: sdm-post-type-content-handler.php:126
1362
+ msgid "The admin of this site has disabled the download button for this page."
1363
+ msgstr ""
1364
+ "El administrador de este sitio ha desactivado el botón de descarga de esta "
1365
+ "página."
1366
+
1367
+ #: sdm-shortcodes.php:82 sdm-shortcodes.php:152 sdm-shortcodes.php:166
1368
  msgid "Error! Please enter an ID value with this shortcode."
1369
  msgstr "¡Error! Por favor, introduzca un valor de ID con este código corto."
1370
 
1371
+ #: sdm-shortcodes.php:199
1372
  msgid ""
1373
  "Error! You must enter a category slug OR a category id with this shortcode. "
1374
  "Refer to the documentation for usage instructions."
1377
  "categoría con este código corto. Consulte la documentación para obtener "
1378
  "instrucciones de uso."
1379
 
1380
+ #: sdm-shortcodes.php:204
1381
  msgid "Error! Please enter a category slug OR id; not both."
1382
  msgstr "¡Error! Por favor introduce una categoría slug O id; no ambos."
1383
 
1384
+ #: sdm-shortcodes.php:240
1385
+ msgid ""
1386
+ "Error! You must enter a numeric number for the \"pagination\" parameter of "
1387
+ "the shortcode. Refer to the usage documentation."
1388
+ msgstr ""
1389
+ "¡Error! Debes ingresar un número numérico para el parámetro «pagination» del "
1390
+ "shortcode. Consulta la documentación de uso."
1391
+
1392
+ #: sdm-shortcodes.php:265
1393
  msgid "There are no download items matching this category criteria."
1394
  msgstr ""
1395
  "No hay elementos que coincidan con este criterio de categoría de descarga."
1396
+
1397
+ #. Plugin Name of the plugin/theme
1398
+ msgid "Simple Download Monitor"
1399
+ msgstr "Simple Download Monitor"
1400
+
1401
+ #. Plugin URI of the plugin/theme
1402
+ msgid "https://simple-download-monitor.com/"
1403
+ msgstr "https://simple-download-monitor.com/"
1404
+
1405
+ #. Description of the plugin/theme
1406
+ msgid ""
1407
+ "Easily manage downloadable files and monitor downloads of your digital files "
1408
+ "from your WordPress site."
1409
+ msgstr ""
1410
+ "Administrar fácilmente los archivos descargables y monitorear las descargas "
1411
+ "de los archivos digitales desde tu sitio de WordPress."
1412
+
1413
+ #. Author of the plugin/theme
1414
+ msgid "Tips and Tricks HQ, Ruhul Amin, Josh Lobe"
1415
+ msgstr "Tips and Tricks HQ, Ruhul Amin, Josh Lobe"
1416
+
1417
+ #. Author URI of the plugin/theme
1418
+ msgid "https://www.tipsandtricks-hq.com/development-center"
1419
+ msgstr "https://www.tipsandtricks-hq.com/development-center"
1420
+
1421
+ # ## Translation strings for the addons
1422
+ # Squeeze form addon
1423
+ msgid "The download has been sent to your email. Please check your inbox."
1424
+ msgstr ""
1425
+ "La descarga ha sido enviada a tu correo electrónico. Por favor, revisa tu "
1426
+ "bandeja de entrada."
1427
+
1428
+ msgid "Name"
1429
+ msgstr "Nombre"
1430
+
1431
+ msgid "Email"
1432
+ msgstr "Correo electrónico"
1433
+
1434
+ #~ msgid "Incorrect Password"
1435
+ #~ msgstr "Clave Incorrecta"
1436
+
1437
+ #~ msgid "Follow us"
1438
+ #~ msgstr "Síganos"
1439
+
1440
+ #~ msgid ""
1441
+ #~ "on Twitter, Google+ or via Email to stay upto date about the new features "
1442
+ #~ "of this plugin."
1443
+ #~ msgstr ""
1444
+ #~ "en Twitter, Google+ o vía correo electrónico estar acutalizado hasta la "
1445
+ #~ "fecha de hoy de las nuevas características de este plugin."
1446
+
1447
+ #~ msgid "Control various plugin features."
1448
+ #~ msgstr "Controla varias funciones del plugin."
1449
+
1450
+ #~ msgid "Color Options"
1451
+ #~ msgstr "Opciones De Color"
1452
+
1453
+ #~ msgid "Adjust color options"
1454
+ #~ msgstr "Ajuste Las Opciones Del Color"
1455
+
1456
+ #~ msgid "Upload File"
1457
+ #~ msgstr "Subir Archivo"
1458
+
1459
+ #~ msgid "current"
1460
+ #~ msgstr "al corriente"
1461
+
1462
+ #~ msgid "Export All as Excel"
1463
+ #~ msgstr "Exportar todo como Excel"
1464
+
1465
+ #~ msgid "Download Export File"
1466
+ #~ msgstr "Descarga de archivo de exportación"
1467
+
1468
+ #~ msgid "Submit"
1469
+ #~ msgstr "Enviar"
1470
+
1471
+ #~ msgid "Visitor Country"
1472
+ #~ msgstr "País del Usuario"
lib/plugin-update-checker/.editorconfig ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [*]
2
+ charset=utf-8
3
+ end_of_line=lf
4
+ insert_final_newline=false
5
+ indent_style=tab
6
+ tab_width=4
7
+
8
+ [{phpunit.xml.dist,*.jhm,*.xslt,*.xul,*.rng,*.xsl,*.xsd,*.ant,*.tld,*.fxml,*.jrxml,*.xml,*.jnlp,*.wsdl}]
9
+ indent_style=space
10
+ indent_size=4
11
+
12
+ [*.svg]
13
+ indent_style=space
14
+ indent_size=4
15
+
lib/plugin-update-checker/Puc/v4/Factory.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4_Factory', false) ):
3
+
4
+ class Puc_v4_Factory extends Puc_v4p8_Factory { }
5
+
6
+ endif;
lib/plugin-update-checker/Puc/v4p8/Autoloader.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p8_Autoloader', false) ):
4
+
5
+ class Puc_v4p8_Autoloader {
6
+ private $prefix = '';
7
+ private $rootDir = '';
8
+ private $libraryDir = '';
9
+
10
+ private $staticMap;
11
+
12
+ public function __construct() {
13
+ $this->rootDir = dirname(__FILE__) . '/';
14
+ $nameParts = explode('_', __CLASS__, 3);
15
+ $this->prefix = $nameParts[0] . '_' . $nameParts[1] . '_';
16
+
17
+ $this->libraryDir = realpath($this->rootDir . '../..') . '/';
18
+ $this->staticMap = array(
19
+ 'PucReadmeParser' => 'vendor/PucReadmeParser.php',
20
+ 'Parsedown' => 'vendor/Parsedown.php',
21
+ 'Puc_v4_Factory' => 'Puc/v4/Factory.php',
22
+ );
23
+
24
+ spl_autoload_register(array($this, 'autoload'));
25
+ }
26
+
27
+ public function autoload($className) {
28
+ if ( isset($this->staticMap[$className]) && file_exists($this->libraryDir . $this->staticMap[$className]) ) {
29
+ /** @noinspection PhpIncludeInspection */
30
+ include ($this->libraryDir . $this->staticMap[$className]);
31
+ return;
32
+ }
33
+
34
+ if (strpos($className, $this->prefix) === 0) {
35
+ $path = substr($className, strlen($this->prefix));
36
+ $path = str_replace('_', '/', $path);
37
+ $path = $this->rootDir . $path . '.php';
38
+
39
+ if (file_exists($path)) {
40
+ /** @noinspection PhpIncludeInspection */
41
+ include $path;
42
+ }
43
+ }
44
+ }
45
+ }
46
+
47
+ endif;
lib/plugin-update-checker/Puc/v4p8/DebugBar/Extension.php ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p8_DebugBar_Extension', false) ):
3
+
4
+ class Puc_v4p8_DebugBar_Extension {
5
+ const RESPONSE_BODY_LENGTH_LIMIT = 4000;
6
+
7
+ /** @var Puc_v4p8_UpdateChecker */
8
+ protected $updateChecker;
9
+ protected $panelClass = 'Puc_v4p8_DebugBar_Panel';
10
+
11
+ public function __construct($updateChecker, $panelClass = null) {
12
+ $this->updateChecker = $updateChecker;
13
+ if ( isset($panelClass) ) {
14
+ $this->panelClass = $panelClass;
15
+ }
16
+
17
+ add_filter('debug_bar_panels', array($this, 'addDebugBarPanel'));
18
+ add_action('debug_bar_enqueue_scripts', array($this, 'enqueuePanelDependencies'));
19
+
20
+ add_action('wp_ajax_puc_v4_debug_check_now', array($this, 'ajaxCheckNow'));
21
+ }
22
+
23
+ /**
24
+ * Register the PUC Debug Bar panel.
25
+ *
26
+ * @param array $panels
27
+ * @return array
28
+ */
29
+ public function addDebugBarPanel($panels) {
30
+ if ( $this->updateChecker->userCanInstallUpdates() ) {
31
+ $panels[] = new $this->panelClass($this->updateChecker);
32
+ }
33
+ return $panels;
34
+ }
35
+
36
+ /**
37
+ * Enqueue our Debug Bar scripts and styles.
38
+ */
39
+ public function enqueuePanelDependencies() {
40
+ wp_enqueue_style(
41
+ 'puc-debug-bar-style-v4',
42
+ $this->getLibraryUrl("/css/puc-debug-bar.css"),
43
+ array('debug-bar'),
44
+ '20171124'
45
+ );
46
+
47
+ wp_enqueue_script(
48
+ 'puc-debug-bar-js-v4',
49
+ $this->getLibraryUrl("/js/debug-bar.js"),
50
+ array('jquery'),
51
+ '20170516'
52
+ );
53
+ }
54
+
55
+ /**
56
+ * Run an update check and output the result. Useful for making sure that
57
+ * the update checking process works as expected.
58
+ */
59
+ public function ajaxCheckNow() {
60
+ if ( $_POST['uid'] !== $this->updateChecker->getUniqueName('uid') ) {
61
+ return;
62
+ }
63
+ $this->preAjaxRequest();
64
+ $update = $this->updateChecker->checkForUpdates();
65
+ if ( $update !== null ) {
66
+ echo "An update is available:";
67
+ echo '<pre>', htmlentities(print_r($update, true)), '</pre>';
68
+ } else {
69
+ echo 'No updates found.';
70
+ }
71
+
72
+ $errors = $this->updateChecker->getLastRequestApiErrors();
73
+ if ( !empty($errors) ) {
74
+ printf('<p>The update checker encountered %d API error%s.</p>', count($errors), (count($errors) > 1) ? 's' : '');
75
+
76
+ foreach (array_values($errors) as $num => $item) {
77
+ $wpError = $item['error'];
78
+ /** @var WP_Error $wpError */
79
+ printf('<h4>%d) %s</h4>', $num + 1, esc_html($wpError->get_error_message()));
80
+
81
+ echo '<dl>';
82
+ printf('<dt>Error code:</dt><dd><code>%s</code></dd>', esc_html($wpError->get_error_code()));
83
+
84
+ if ( isset($item['url']) ) {
85
+ printf('<dt>Requested URL:</dt><dd><code>%s</code></dd>', esc_html($item['url']));
86
+ }
87
+
88
+ if ( isset($item['httpResponse']) ) {
89
+ if ( is_wp_error($item['httpResponse']) ) {
90
+ $httpError = $item['httpResponse'];
91
+ /** @var WP_Error $httpError */
92
+ printf(
93
+ '<dt>WordPress HTTP API error:</dt><dd>%s (<code>%s</code>)</dd>',
94
+ esc_html($httpError->get_error_message()),
95
+ esc_html($httpError->get_error_code())
96
+ );
97
+ } else {
98
+ //Status code.
99
+ printf(
100
+ '<dt>HTTP status:</dt><dd><code>%d %s</code></dd>',
101
+ wp_remote_retrieve_response_code($item['httpResponse']),
102
+ wp_remote_retrieve_response_message($item['httpResponse'])
103
+ );
104
+
105
+ //Headers.
106
+ echo '<dt>Response headers:</dt><dd><pre>';
107
+ foreach (wp_remote_retrieve_headers($item['httpResponse']) as $name => $value) {
108
+ printf("%s: %s\n", esc_html($name), esc_html($value));
109
+ }
110
+ echo '</pre></dd>';
111
+
112
+ //Body.
113
+ $body = wp_remote_retrieve_body($item['httpResponse']);
114
+ if ( $body === '' ) {
115
+ $body = '(Empty response.)';
116
+ } else if ( strlen($body) > self::RESPONSE_BODY_LENGTH_LIMIT ) {
117
+ $length = strlen($body);
118
+ $body = substr($body, 0, self::RESPONSE_BODY_LENGTH_LIMIT)
119
+ . sprintf("\n(Long string truncated. Total length: %d bytes.)", $length);
120
+ }
121
+
122
+ printf('<dt>Response body:</dt><dd><pre>%s</pre></dd>', esc_html($body));
123
+ }
124
+ }
125
+ echo '<dl>';
126
+ }
127
+ }
128
+
129
+ exit;
130
+ }
131
+
132
+ /**
133
+ * Check access permissions and enable error display (for debugging).
134
+ */
135
+ protected function preAjaxRequest() {
136
+ if ( !$this->updateChecker->userCanInstallUpdates() ) {
137
+ die('Access denied');
138
+ }
139
+ check_ajax_referer('puc-ajax');
140
+
141
+ error_reporting(E_ALL);
142
+ @ini_set('display_errors', 'On');
143
+ }
144
+
145
+ /**
146
+ * @param string $filePath
147
+ * @return string
148
+ */
149
+ private function getLibraryUrl($filePath) {
150
+ $absolutePath = realpath(dirname(__FILE__) . '/../../../' . ltrim($filePath, '/'));
151
+
152
+ //Where is the library located inside the WordPress directory structure?
153
+ $absolutePath = Puc_v4p8_Factory::normalizePath($absolutePath);
154
+
155
+ $pluginDir = Puc_v4p8_Factory::normalizePath(WP_PLUGIN_DIR);
156
+ $muPluginDir = Puc_v4p8_Factory::normalizePath(WPMU_PLUGIN_DIR);
157
+ $themeDir = Puc_v4p8_Factory::normalizePath(get_theme_root());
158
+
159
+ if ( (strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0) ) {
160
+ //It's part of a plugin.
161
+ return plugins_url(basename($absolutePath), $absolutePath);
162
+ } else if ( strpos($absolutePath, $themeDir) === 0 ) {
163
+ //It's part of a theme.
164
+ $relativePath = substr($absolutePath, strlen($themeDir) + 1);
165
+ $template = substr($relativePath, 0, strpos($relativePath, '/'));
166
+ $baseUrl = get_theme_root_uri($template);
167
+
168
+ if ( !empty($baseUrl) && $relativePath ) {
169
+ return $baseUrl . '/' . $relativePath;
170
+ }
171
+ }
172
+
173
+ return '';
174
+ }
175
+ }
176
+
177
+ endif;
lib/plugin-update-checker/Puc/v4p8/DebugBar/Panel.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p8_DebugBar_Panel', false) && class_exists('Debug_Bar_Panel', false) ):
4
+
5
+ class Puc_v4p8_DebugBar_Panel extends Debug_Bar_Panel {
6
+ /** @var Puc_v4p8_UpdateChecker */
7
+ protected $updateChecker;
8
+
9
+ private $responseBox = '<div class="puc-ajax-response" style="display: none;"></div>';
10
+
11
+ public function __construct($updateChecker) {
12
+ $this->updateChecker = $updateChecker;
13
+ $title = sprintf(
14
+ '<span class="puc-debug-menu-link-%s">PUC (%s)</span>',
15
+ esc_attr($this->updateChecker->getUniqueName('uid')),
16
+ $this->updateChecker->slug
17
+ );
18
+ parent::__construct($title);
19
+ }
20
+
21
+ public function render() {
22
+ printf(
23
+ '<div class="puc-debug-bar-panel-v4" id="%1$s" data-slug="%2$s" data-uid="%3$s" data-nonce="%4$s">',
24
+ esc_attr($this->updateChecker->getUniqueName('debug-bar-panel')),
25
+ esc_attr($this->updateChecker->slug),
26
+ esc_attr($this->updateChecker->getUniqueName('uid')),
27
+ esc_attr(wp_create_nonce('puc-ajax'))
28
+ );
29
+
30
+ $this->displayConfiguration();
31
+ $this->displayStatus();
32
+ $this->displayCurrentUpdate();
33
+
34
+ echo '</div>';
35
+ }
36
+
37
+ private function displayConfiguration() {
38
+ echo '<h3>Configuration</h3>';
39
+ echo '<table class="puc-debug-data">';
40
+ $this->displayConfigHeader();
41
+ $this->row('Slug', htmlentities($this->updateChecker->slug));
42
+ $this->row('DB option', htmlentities($this->updateChecker->optionName));
43
+
44
+ $requestInfoButton = $this->getMetadataButton();
45
+ $this->row('Metadata URL', htmlentities($this->updateChecker->metadataUrl) . ' ' . $requestInfoButton . $this->responseBox);
46
+
47
+ $scheduler = $this->updateChecker->scheduler;
48
+ if ( $scheduler->checkPeriod > 0 ) {
49
+ $this->row('Automatic checks', 'Every ' . $scheduler->checkPeriod . ' hours');
50
+ } else {
51
+ $this->row('Automatic checks', 'Disabled');
52
+ }
53
+
54
+ if ( isset($scheduler->throttleRedundantChecks) ) {
55
+ if ( $scheduler->throttleRedundantChecks && ($scheduler->checkPeriod > 0) ) {
56
+ $this->row(
57
+ 'Throttling',
58
+ sprintf(
59
+ 'Enabled. If an update is already available, check for updates every %1$d hours instead of every %2$d hours.',
60
+ $scheduler->throttledCheckPeriod,
61
+ $scheduler->checkPeriod
62
+ )
63
+ );
64
+ } else {
65
+ $this->row('Throttling', 'Disabled');
66
+ }
67
+ }
68
+
69
+ $this->updateChecker->onDisplayConfiguration($this);
70
+
71
+ echo '</table>';
72
+ }
73
+
74
+ protected function displayConfigHeader() {
75
+ //Do nothing. This should be implemented in subclasses.
76
+ }
77
+
78
+ protected function getMetadataButton() {
79
+ return '';
80
+ }
81
+
82
+ private function displayStatus() {
83
+ echo '<h3>Status</h3>';
84
+ echo '<table class="puc-debug-data">';
85
+ $state = $this->updateChecker->getUpdateState();
86
+ $checkNowButton = '';
87
+ if ( function_exists('get_submit_button') ) {
88
+ $checkNowButton = get_submit_button(
89
+ 'Check Now',
90
+ 'secondary',
91
+ 'puc-check-now-button',
92
+ false,
93
+ array('id' => $this->updateChecker->getUniqueName('check-now-button'))
94
+ );
95
+ }
96
+
97
+ if ( $state->getLastCheck() > 0 ) {
98
+ $this->row('Last check', $this->formatTimeWithDelta($state->getLastCheck()) . ' ' . $checkNowButton . $this->responseBox);
99
+ } else {
100
+ $this->row('Last check', 'Never');
101
+ }
102
+
103
+ $nextCheck = wp_next_scheduled($this->updateChecker->scheduler->getCronHookName());
104
+ $this->row('Next automatic check', $this->formatTimeWithDelta($nextCheck));
105
+
106
+ if ( $state->getCheckedVersion() !== '' ) {
107
+ $this->row('Checked version', htmlentities($state->getCheckedVersion()));
108
+ $this->row('Cached update', $state->getUpdate());
109
+ }
110
+ $this->row('Update checker class', htmlentities(get_class($this->updateChecker)));
111
+ echo '</table>';
112
+ }
113
+
114
+ private function displayCurrentUpdate() {
115
+ $update = $this->updateChecker->getUpdate();
116
+ if ( $update !== null ) {
117
+ echo '<h3>An Update Is Available</h3>';
118
+ echo '<table class="puc-debug-data">';
119
+ $fields = $this->getUpdateFields();
120
+ foreach($fields as $field) {
121
+ if ( property_exists($update, $field) ) {
122
+ $this->row(ucwords(str_replace('_', ' ', $field)), htmlentities($update->$field));
123
+ }
124
+ }
125
+ echo '</table>';
126
+ } else {
127
+ echo '<h3>No updates currently available</h3>';
128
+ }
129
+ }
130
+
131
+ protected function getUpdateFields() {
132
+ return array('version', 'download_url', 'slug',);
133
+ }
134
+
135
+ private function formatTimeWithDelta($unixTime) {
136
+ if ( empty($unixTime) ) {
137
+ return 'Never';
138
+ }
139
+
140
+ $delta = time() - $unixTime;
141
+ $result = human_time_diff(time(), $unixTime);
142
+ if ( $delta < 0 ) {
143
+ $result = 'after ' . $result;
144
+ } else {
145
+ $result = $result . ' ago';
146
+ }
147
+ $result .= ' (' . $this->formatTimestamp($unixTime) . ')';
148
+ return $result;
149
+ }
150
+
151
+ private function formatTimestamp($unixTime) {
152
+ return gmdate('Y-m-d H:i:s', $unixTime + (get_option('gmt_offset') * 3600));
153
+ }
154
+
155
+ public function row($name, $value) {
156
+ if ( is_object($value) || is_array($value) ) {
157
+ $value = '<pre>' . htmlentities(print_r($value, true)) . '</pre>';
158
+ } else if ($value === null) {
159
+ $value = '<code>null</code>';
160
+ }
161
+ printf('<tr><th scope="row">%1$s</th> <td>%2$s</td></tr>', $name, $value);
162
+ }
163
+ }
164
+
165
+ endif;
lib/plugin-update-checker/Puc/v4p8/DebugBar/PluginExtension.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p8_DebugBar_PluginExtension', false) ):
3
+
4
+ class Puc_v4p8_DebugBar_PluginExtension extends Puc_v4p8_DebugBar_Extension {
5
+ /** @var Puc_v4p8_Plugin_UpdateChecker */
6
+ protected $updateChecker;
7
+
8
+ public function __construct($updateChecker) {
9
+ parent::__construct($updateChecker, 'Puc_v4p8_DebugBar_PluginPanel');
10
+
11
+ add_action('wp_ajax_puc_v4_debug_request_info', array($this, 'ajaxRequestInfo'));
12
+ }
13
+
14
+ /**
15
+ * Request plugin info and output it.
16
+ */
17
+ public function ajaxRequestInfo() {
18
+ if ( $_POST['uid'] !== $this->updateChecker->getUniqueName('uid') ) {
19
+ return;
20
+ }
21
+ $this->preAjaxRequest();
22
+ $info = $this->updateChecker->requestInfo();
23
+ if ( $info !== null ) {
24
+ echo 'Successfully retrieved plugin info from the metadata URL:';
25
+ echo '<pre>', htmlentities(print_r($info, true)), '</pre>';
26
+ } else {
27
+ echo 'Failed to retrieve plugin info from the metadata URL.';
28
+ }
29
+ exit;
30
+ }
31
+ }
32
+
33
+ endif;
lib/plugin-update-checker/Puc/v4p8/DebugBar/PluginPanel.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p8_DebugBar_PluginPanel', false) ):
4
+
5
+ class Puc_v4p8_DebugBar_PluginPanel extends Puc_v4p8_DebugBar_Panel {
6
+ /**
7
+ * @var Puc_v4p8_Plugin_UpdateChecker
8
+ */
9
+ protected $updateChecker;
10
+
11
+ protected function displayConfigHeader() {
12
+ $this->row('Plugin file', htmlentities($this->updateChecker->pluginFile));
13
+ parent::displayConfigHeader();
14
+ }
15
+
16
+ protected function getMetadataButton() {
17
+ $requestInfoButton = '';
18
+ if ( function_exists('get_submit_button') ) {
19
+ $requestInfoButton = get_submit_button(
20
+ 'Request Info',
21
+ 'secondary',
22
+ 'puc-request-info-button',
23
+ false,
24
+ array('id' => $this->updateChecker->getUniqueName('request-info-button'))
25
+ );
26
+ }
27
+ return $requestInfoButton;
28
+ }
29
+
30
+ protected function getUpdateFields() {
31
+ return array_merge(
32
+ parent::getUpdateFields(),
33
+ array('homepage', 'upgrade_notice', 'tested',)
34
+ );
35
+ }
36
+ }
37
+
38
+ endif;
lib/plugin-update-checker/Puc/v4p8/DebugBar/ThemePanel.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p8_DebugBar_ThemePanel', false) ):
4
+
5
+ class Puc_v4p8_DebugBar_ThemePanel extends Puc_v4p8_DebugBar_Panel {
6
+ /**
7
+ * @var Puc_v4p8_Theme_UpdateChecker
8
+ */
9
+ protected $updateChecker;
10
+
11
+ protected function displayConfigHeader() {
12
+ $this->row('Theme directory', htmlentities($this->updateChecker->directoryName));
13
+ parent::displayConfigHeader();
14
+ }
15
+
16
+ protected function getUpdateFields() {
17
+ return array_merge(parent::getUpdateFields(), array('details_url'));
18
+ }
19
+ }
20
+
21
+ endif;
lib/plugin-update-checker/Puc/v4p8/Factory.php ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p8_Factory', false) ):
3
+
4
+ /**
5
+ * A factory that builds update checker instances.
6
+ *
7
+ * When multiple versions of the same class have been loaded (e.g. PluginUpdateChecker 4.0
8
+ * and 4.1), this factory will always use the latest available minor version. Register class
9
+ * versions by calling {@link PucFactory::addVersion()}.
10
+ *
11
+ * At the moment it can only build instances of the UpdateChecker class. Other classes are
12
+ * intended mainly for internal use and refer directly to specific implementations.
13
+ */
14
+ class Puc_v4p8_Factory {
15
+ protected static $classVersions = array();
16
+ protected static $sorted = false;
17
+
18
+ protected static $myMajorVersion = '';
19
+ protected static $latestCompatibleVersion = '';
20
+
21
+ /**
22
+ * Create a new instance of the update checker.
23
+ *
24
+ * This method automatically detects if you're using it for a plugin or a theme and chooses
25
+ * the appropriate implementation for your update source (JSON file, GitHub, BitBucket, etc).
26
+ *
27
+ * @see Puc_v4p8_UpdateChecker::__construct
28
+ *
29
+ * @param string $metadataUrl The URL of the metadata file, a GitHub repository, or another supported update source.
30
+ * @param string $fullPath Full path to the main plugin file or to the theme directory.
31
+ * @param string $slug Custom slug. Defaults to the name of the main plugin file or the theme directory.
32
+ * @param int $checkPeriod How often to check for updates (in hours).
33
+ * @param string $optionName Where to store book-keeping info about update checks.
34
+ * @param string $muPluginFile The plugin filename relative to the mu-plugins directory.
35
+ * @return Puc_v4p8_Plugin_UpdateChecker|Puc_v4p8_Theme_UpdateChecker|Puc_v4p8_Vcs_BaseChecker
36
+ */
37
+ public static function buildUpdateChecker($metadataUrl, $fullPath, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') {
38
+ $fullPath = self::normalizePath($fullPath);
39
+ $id = null;
40
+
41
+ //Plugin or theme?
42
+ $themeDirectory = self::getThemeDirectoryName($fullPath);
43
+ if ( self::isPluginFile($fullPath) ) {
44
+ $type = 'Plugin';
45
+ $id = $fullPath;
46
+ } else if ( $themeDirectory !== null ) {
47
+ $type = 'Theme';
48
+ $id = $themeDirectory;
49
+ } else {
50
+ throw new RuntimeException(sprintf(
51
+ 'The update checker cannot determine if "%s" is a plugin or a theme. ' .
52
+ 'This is a bug. Please contact the PUC developer.',
53
+ htmlentities($fullPath)
54
+ ));
55
+ }
56
+
57
+ //Which hosting service does the URL point to?
58
+ $service = self::getVcsService($metadataUrl);
59
+
60
+ $apiClass = null;
61
+ if ( empty($service) ) {
62
+ //The default is to get update information from a remote JSON file.
63
+ $checkerClass = $type . '_UpdateChecker';
64
+ } else {
65
+ //You can also use a VCS repository like GitHub.
66
+ $checkerClass = 'Vcs_' . $type . 'UpdateChecker';
67
+ $apiClass = $service . 'Api';
68
+ }
69
+
70
+ $checkerClass = self::getCompatibleClassVersion($checkerClass);
71
+ if ( $checkerClass === null ) {
72
+ trigger_error(
73
+ sprintf(
74
+ 'PUC %s does not support updates for %ss %s',
75
+ htmlentities(self::$latestCompatibleVersion),
76
+ strtolower($type),
77
+ $service ? ('hosted on ' . htmlentities($service)) : 'using JSON metadata'
78
+ ),
79
+ E_USER_ERROR
80
+ );
81
+ return null;
82
+ }
83
+
84
+ if ( !isset($apiClass) ) {
85
+ //Plain old update checker.
86
+ return new $checkerClass($metadataUrl, $id, $slug, $checkPeriod, $optionName, $muPluginFile);
87
+ } else {
88
+ //VCS checker + an API client.
89
+ $apiClass = self::getCompatibleClassVersion($apiClass);
90
+ if ( $apiClass === null ) {
91
+ trigger_error(sprintf(
92
+ 'PUC %s does not support %s',
93
+ htmlentities(self::$latestCompatibleVersion),
94
+ htmlentities($service)
95
+ ), E_USER_ERROR);
96
+ return null;
97
+ }
98
+
99
+ return new $checkerClass(
100
+ new $apiClass($metadataUrl),
101
+ $id,
102
+ $slug,
103
+ $checkPeriod,
104
+ $optionName,
105
+ $muPluginFile
106
+ );
107
+ }
108
+ }
109
+
110
+ /**
111
+ *
112
+ * Normalize a filesystem path. Introduced in WP 3.9.
113
+ * Copying here allows use of the class on earlier versions.
114
+ * This version adapted from WP 4.8.2 (unchanged since 4.5.0)
115
+ *
116
+ * @param string $path Path to normalize.
117
+ * @return string Normalized path.
118
+ */
119
+ public static function normalizePath($path) {
120
+ if ( function_exists('wp_normalize_path') ) {
121
+ return wp_normalize_path($path);
122
+ }
123
+ $path = str_replace('\\', '/', $path);
124
+ $path = preg_replace('|(?<=.)/+|', '/', $path);
125
+ if ( substr($path, 1, 1) === ':' ) {
126
+ $path = ucfirst($path);
127
+ }
128
+ return $path;
129
+ }
130
+
131
+ /**
132
+ * Check if the path points to a plugin file.
133
+ *
134
+ * @param string $absolutePath Normalized path.
135
+ * @return bool
136
+ */
137
+ protected static function isPluginFile($absolutePath) {
138
+ //Is the file inside the "plugins" or "mu-plugins" directory?
139
+ $pluginDir = self::normalizePath(WP_PLUGIN_DIR);
140
+ $muPluginDir = self::normalizePath(WPMU_PLUGIN_DIR);
141
+ if ( (strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0) ) {
142
+ return true;
143
+ }
144
+
145
+ //Is it a file at all? Caution: is_file() can fail if the parent dir. doesn't have the +x permission set.
146
+ if ( !is_file($absolutePath) ) {
147
+ return false;
148
+ }
149
+
150
+ //Does it have a valid plugin header?
151
+ //This is a last-ditch check for plugins symlinked from outside the WP root.
152
+ if ( function_exists('get_file_data') ) {
153
+ $headers = get_file_data($absolutePath, array('Name' => 'Plugin Name'), 'plugin');
154
+ return !empty($headers['Name']);
155
+ }
156
+
157
+ return false;
158
+ }
159
+
160
+ /**
161
+ * Get the name of the theme's directory from a full path to a file inside that directory.
162
+ * E.g. "/abc/public_html/wp-content/themes/foo/whatever.php" => "foo".
163
+ *
164
+ * Note that subdirectories are currently not supported. For example,
165
+ * "/xyz/wp-content/themes/my-theme/includes/whatever.php" => NULL.
166
+ *
167
+ * @param string $absolutePath Normalized path.
168
+ * @return string|null Directory name, or NULL if the path doesn't point to a theme.
169
+ */
170
+ protected static function getThemeDirectoryName($absolutePath) {
171
+ if ( is_file($absolutePath) ) {
172
+ $absolutePath = dirname($absolutePath);
173
+ }
174
+
175
+ if ( file_exists($absolutePath . '/style.css') ) {
176
+ return basename($absolutePath);
177
+ }
178
+ return null;
179
+ }
180
+
181
+ /**
182
+ * Get the name of the hosting service that the URL points to.
183
+ *
184
+ * @param string $metadataUrl
185
+ * @return string|null
186
+ */
187
+ private static function getVcsService($metadataUrl) {
188
+ $service = null;
189
+
190
+ //Which hosting service does the URL point to?
191
+ $host = parse_url($metadataUrl, PHP_URL_HOST);
192
+ $path = parse_url($metadataUrl, PHP_URL_PATH);
193
+
194
+ //Check if the path looks like "/user-name/repository".
195
+ //For GitLab.com it can also be "/user/group1/group2/.../repository".
196
+ $repoRegex = '@^/?([^/]+?)/([^/#?&]+?)/?$@';
197
+ if ( $host === 'gitlab.com' ) {
198
+ $repoRegex = '@^/?(?:[^/#?&]++/){1,20}(?:[^/#?&]++)/?$@';
199
+ }
200
+ if ( preg_match($repoRegex, $path) ) {
201
+ $knownServices = array(
202
+ 'github.com' => 'GitHub',
203
+ 'bitbucket.org' => 'BitBucket',
204
+ 'gitlab.com' => 'GitLab',
205
+ );
206
+ if ( isset($knownServices[$host]) ) {
207
+ $service = $knownServices[$host];
208
+ }
209
+ }
210
+
211
+ return apply_filters('puc_get_vcs_service', $service, $host, $path, $metadataUrl);
212
+ }
213
+
214
+ /**
215
+ * Get the latest version of the specified class that has the same major version number
216
+ * as this factory class.
217
+ *
218
+ * @param string $class Partial class name.
219
+ * @return string|null Full class name.
220
+ */
221
+ protected static function getCompatibleClassVersion($class) {
222
+ if ( isset(self::$classVersions[$class][self::$latestCompatibleVersion]) ) {
223
+ return self::$classVersions[$class][self::$latestCompatibleVersion];
224
+ }
225
+ return null;
226
+ }
227
+
228
+ /**
229
+ * Get the specific class name for the latest available version of a class.
230
+ *
231
+ * @param string $class
232
+ * @return null|string
233
+ */
234
+ public static function getLatestClassVersion($class) {
235
+ if ( !self::$sorted ) {
236
+ self::sortVersions();
237
+ }
238
+
239
+ if ( isset(self::$classVersions[$class]) ) {
240
+ return reset(self::$classVersions[$class]);
241
+ } else {
242
+ return null;
243
+ }
244
+ }
245
+
246
+ /**
247
+ * Sort available class versions in descending order (i.e. newest first).
248
+ */
249
+ protected static function sortVersions() {
250
+ foreach ( self::$classVersions as $class => $versions ) {
251
+ uksort($versions, array(__CLASS__, 'compareVersions'));
252
+ self::$classVersions[$class] = $versions;
253
+ }
254
+ self::$sorted = true;
255
+ }
256
+
257
+ protected static function compareVersions($a, $b) {
258
+ return -version_compare($a, $b);
259
+ }
260
+
261
+ /**
262
+ * Register a version of a class.
263
+ *
264
+ * @access private This method is only for internal use by the library.
265
+ *
266
+ * @param string $generalClass Class name without version numbers, e.g. 'PluginUpdateChecker'.
267
+ * @param string $versionedClass Actual class name, e.g. 'PluginUpdateChecker_1_2'.
268
+ * @param string $version Version number, e.g. '1.2'.
269
+ */
270
+ public static function addVersion($generalClass, $versionedClass, $version) {
271
+ if ( empty(self::$myMajorVersion) ) {
272
+ $nameParts = explode('_', __CLASS__, 3);
273
+ self::$myMajorVersion = substr(ltrim($nameParts[1], 'v'), 0, 1);
274
+ }
275
+
276
+ //Store the greatest version number that matches our major version.
277
+ $components = explode('.', $version);
278
+ if ( $components[0] === self::$myMajorVersion ) {
279
+
280
+ if (
281
+ empty(self::$latestCompatibleVersion)
282
+ || version_compare($version, self::$latestCompatibleVersion, '>')
283
+ ) {
284
+ self::$latestCompatibleVersion = $version;
285
+ }
286
+
287
+ }
288
+
289
+ if ( !isset(self::$classVersions[$generalClass]) ) {
290
+ self::$classVersions[$generalClass] = array();
291
+ }
292
+ self::$classVersions[$generalClass][$version] = $versionedClass;
293
+ self::$sorted = false;
294
+ }
295
+ }
296
+
297
+ endif;
lib/plugin-update-checker/Puc/v4p8/InstalledPackage.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p8_InstalledPackage', false) ):
3
+
4
+ /**
5
+ * This class represents a currently installed plugin or theme.
6
+ *
7
+ * Not to be confused with the "package" field in WP update API responses that contains
8
+ * the download URL of a the new version.
9
+ */
10
+ abstract class Puc_v4p8_InstalledPackage {
11
+ /**
12
+ * @var Puc_v4p8_UpdateChecker
13
+ */
14
+ protected $updateChecker;
15
+
16
+ public function __construct($updateChecker) {
17
+ $this->updateChecker = $updateChecker;
18
+ }
19
+
20
+ /**
21
+ * Get the currently installed version of the plugin or theme.
22
+ *
23
+ * @return string|null Version number.
24
+ */
25
+ abstract public function getInstalledVersion();
26
+
27
+ /**
28
+ * Get the full path of the plugin or theme directory (without a trailing slash).
29
+ *
30
+ * @return string
31
+ */
32
+ abstract public function getAbsoluteDirectoryPath();
33
+
34
+ /**
35
+ * Check whether a regular file exists in the package's directory.
36
+ *
37
+ * @param string $relativeFileName File name relative to the package directory.
38
+ * @return bool
39
+ */
40
+ public function fileExists($relativeFileName) {
41
+ return is_file(
42
+ $this->getAbsoluteDirectoryPath()
43
+ . DIRECTORY_SEPARATOR
44
+ . ltrim($relativeFileName, '/\\')
45
+ );
46
+ }
47
+
48
+ /* -------------------------------------------------------------------
49
+ * File header parsing
50
+ * -------------------------------------------------------------------
51
+ */
52
+
53
+ /**
54
+ * Parse plugin or theme metadata from the header comment.
55
+ *
56
+ * This is basically a simplified version of the get_file_data() function from /wp-includes/functions.php.
57
+ * It's intended as a utility for subclasses that detect updates by parsing files in a VCS.
58
+ *
59
+ * @param string|null $content File contents.
60
+ * @return string[]
61
+ */
62
+ public function getFileHeader($content) {
63
+ $content = (string)$content;
64
+
65
+ //WordPress only looks at the first 8 KiB of the file, so we do the same.
66
+ $content = substr($content, 0, 8192);
67
+ //Normalize line endings.
68
+ $content = str_replace("\r", "\n", $content);
69
+
70
+ $headers = $this->getHeaderNames();
71
+ $results = array();
72
+ foreach ($headers as $field => $name) {
73
+ $success = preg_match('/^[ \t\/*#@]*' . preg_quote($name, '/') . ':(.*)$/mi', $content, $matches);
74
+
75
+ if ( ($success === 1) && $matches[1] ) {
76
+ $value = $matches[1];
77
+ if ( function_exists('_cleanup_header_comment') ) {
78
+ $value = _cleanup_header_comment($value);
79
+ }
80
+ $results[$field] = $value;
81
+ } else {
82
+ $results[$field] = '';
83
+ }
84
+ }
85
+
86
+ return $results;
87
+ }
88
+
89
+ /**
90
+ * @return array Format: ['HeaderKey' => 'Header Name']
91
+ */
92
+ abstract protected function getHeaderNames();
93
+
94
+ /**
95
+ * Get the value of a specific plugin or theme header.
96
+ *
97
+ * @param string $headerName
98
+ * @return string Either the value of the header, or an empty string if the header doesn't exist.
99
+ */
100
+ abstract public function getHeaderValue($headerName);
101
+
102
+ }
103
+ endif;
lib/plugin-update-checker/Puc/v4p8/Metadata.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p8_Metadata', false) ):
3
+
4
+ /**
5
+ * A base container for holding information about updates and plugin metadata.
6
+ *
7
+ * @author Janis Elsts
8
+ * @copyright 2016
9
+ * @access public
10
+ */
11
+ abstract class Puc_v4p8_Metadata {
12
+
13
+ /**
14
+ * Create an instance of this class from a JSON document.
15
+ *
16
+ * @abstract
17
+ * @param string $json
18
+ * @return self
19
+ */
20
+ public static function fromJson(/** @noinspection PhpUnusedParameterInspection */ $json) {
21
+ throw new LogicException('The ' . __METHOD__ . ' method must be implemented by subclasses');
22
+ }
23
+
24
+ /**
25
+ * @param string $json
26
+ * @param self $target
27
+ * @return bool
28
+ */
29
+ protected static function createFromJson($json, $target) {
30
+ /** @var StdClass $apiResponse */
31
+ $apiResponse = json_decode($json);
32
+ if ( empty($apiResponse) || !is_object($apiResponse) ){
33
+ $errorMessage = "Failed to parse update metadata. Try validating your .json file with http://jsonlint.com/";
34
+ do_action('puc_api_error', new WP_Error('puc-invalid-json', $errorMessage));
35
+ trigger_error($errorMessage, E_USER_NOTICE);
36
+ return false;
37
+ }
38
+
39
+ $valid = $target->validateMetadata($apiResponse);
40
+ if ( is_wp_error($valid) ){
41
+ do_action('puc_api_error', $valid);
42
+ trigger_error($valid->get_error_message(), E_USER_NOTICE);
43
+ return false;
44
+ }
45
+
46
+ foreach(get_object_vars($apiResponse) as $key => $value){
47
+ $target->$key = $value;
48
+ }
49
+
50
+ return true;
51
+ }
52
+
53
+ /**
54
+ * No validation by default! Subclasses should check that the required fields are present.
55
+ *
56
+ * @param StdClass $apiResponse
57
+ * @return bool|WP_Error
58
+ */
59
+ protected function validateMetadata(/** @noinspection PhpUnusedParameterInspection */ $apiResponse) {
60
+ return true;
61
+ }
62
+
63
+ /**
64
+ * Create a new instance by copying the necessary fields from another object.
65
+ *
66
+ * @abstract
67
+ * @param StdClass|self $object The source object.
68
+ * @return self The new copy.
69
+ */
70
+ public static function fromObject(/** @noinspection PhpUnusedParameterInspection */ $object) {
71
+ throw new LogicException('The ' . __METHOD__ . ' method must be implemented by subclasses');
72
+ }
73
+
74
+ /**
75
+ * Create an instance of StdClass that can later be converted back to an
76
+ * update or info container. Useful for serialization and caching, as it
77
+ * avoids the "incomplete object" problem if the cached value is loaded
78
+ * before this class.
79
+ *
80
+ * @return StdClass
81
+ */
82
+ public function toStdClass() {
83
+ $object = new stdClass();
84
+ $this->copyFields($this, $object);
85
+ return $object;
86
+ }
87
+
88
+ /**
89
+ * Transform the metadata into the format used by WordPress core.
90
+ *
91
+ * @return object
92
+ */
93
+ abstract public function toWpFormat();
94
+
95
+ /**
96
+ * Copy known fields from one object to another.
97
+ *
98
+ * @param StdClass|self $from
99
+ * @param StdClass|self $to
100
+ */
101
+ protected function copyFields($from, $to) {
102
+ $fields = $this->getFieldNames();
103
+
104
+ if ( property_exists($from, 'slug') && !empty($from->slug) ) {
105
+ //Let plugins add extra fields without having to create subclasses.
106
+ $fields = apply_filters($this->getPrefixedFilter('retain_fields') . '-' . $from->slug, $fields);
107
+ }
108
+
109
+ foreach ($fields as $field) {
110
+ if ( property_exists($from, $field) ) {
111
+ $to->$field = $from->$field;
112
+ }
113
+ }
114
+ }
115
+
116
+ /**
117
+ * @return string[]
118
+ */
119
+ protected function getFieldNames() {
120
+ return array();
121
+ }
122
+
123
+ /**
124
+ * @param string $tag
125
+ * @return string
126
+ */
127
+ protected function getPrefixedFilter($tag) {
128
+ return 'puc_' . $tag;
129
+ }
130
+ }
131
+
132
+ endif;
lib/plugin-update-checker/Puc/v4p8/OAuthSignature.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p8_OAuthSignature', false) ):
4
+
5
+ /**
6
+ * A basic signature generator for zero-legged OAuth 1.0.
7
+ */
8
+ class Puc_v4p8_OAuthSignature {
9
+ private $consumerKey = '';
10
+ private $consumerSecret = '';
11
+
12
+ public function __construct($consumerKey, $consumerSecret) {
13
+ $this->consumerKey = $consumerKey;
14
+ $this->consumerSecret = $consumerSecret;
15
+ }
16
+
17
+ /**
18
+ * Sign a URL using OAuth 1.0.
19
+ *
20
+ * @param string $url The URL to be signed. It may contain query parameters.
21
+ * @param string $method HTTP method such as "GET", "POST" and so on.
22
+ * @return string The signed URL.
23
+ */
24
+ public function sign($url, $method = 'GET') {
25
+ $parameters = array();
26
+
27
+ //Parse query parameters.
28
+ $query = parse_url($url, PHP_URL_QUERY);
29
+ if ( !empty($query) ) {
30
+ parse_str($query, $parsedParams);
31
+ if ( is_array($parameters) ) {
32
+ $parameters = $parsedParams;
33
+ }
34
+ //Remove the query string from the URL. We'll replace it later.
35
+ $url = substr($url, 0, strpos($url, '?'));
36
+ }
37
+
38
+ $parameters = array_merge(
39
+ $parameters,
40
+ array(
41
+ 'oauth_consumer_key' => $this->consumerKey,
42
+ 'oauth_nonce' => $this->nonce(),
43
+ 'oauth_signature_method' => 'HMAC-SHA1',
44
+ 'oauth_timestamp' => time(),
45
+ 'oauth_version' => '1.0',
46
+ )
47
+ );
48
+ unset($parameters['oauth_signature']);
49
+
50
+ //Parameters must be sorted alphabetically before signing.
51
+ ksort($parameters);
52
+
53
+ //The most complicated part of the request - generating the signature.
54
+ //The string to sign contains the HTTP method, the URL path, and all of
55
+ //our query parameters. Everything is URL encoded. Then we concatenate
56
+ //them with ampersands into a single string to hash.
57
+ $encodedVerb = urlencode($method);
58
+ $encodedUrl = urlencode($url);
59
+ $encodedParams = urlencode(http_build_query($parameters, '', '&'));
60
+
61
+ $stringToSign = $encodedVerb . '&' . $encodedUrl . '&' . $encodedParams;
62
+
63
+ //Since we only have one OAuth token (the consumer secret) we only have
64
+ //to use it as our HMAC key. However, we still have to append an & to it
65
+ //as if we were using it with additional tokens.
66
+ $secret = urlencode($this->consumerSecret) . '&';
67
+
68
+ //The signature is a hash of the consumer key and the base string. Note
69
+ //that we have to get the raw output from hash_hmac and base64 encode
70
+ //the binary data result.
71
+ $parameters['oauth_signature'] = base64_encode(hash_hmac('sha1', $stringToSign, $secret, true));
72
+
73
+ return ($url . '?' . http_build_query($parameters));
74
+ }
75
+
76
+ /**
77
+ * Generate a random nonce.
78
+ *
79
+ * @return string
80
+ */
81
+ private function nonce() {
82
+ $mt = microtime();
83
+
84
+ $rand = null;
85
+ if ( is_callable('random_bytes') ) {
86
+ try {
87
+ $rand = random_bytes(16);
88
+ } catch (Exception $ex) {
89
+ //Fall back to mt_rand (below).
90
+ }
91
+ }
92
+ if ( $rand === null ) {
93
+ $rand = mt_rand();
94
+ }
95
+
96
+ return md5($mt . '_' . $rand);
97
+ }
98
+ }
99
+
100
+ endif;
lib/plugin-update-checker/Puc/v4p8/Plugin/Info.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p8_Plugin_Info', false) ):
3
+
4
+ /**
5
+ * A container class for holding and transforming various plugin metadata.
6
+ *
7
+ * @author Janis Elsts
8
+ * @copyright 2016
9
+ * @access public
10
+ */
11
+ class Puc_v4p8_Plugin_Info extends Puc_v4p8_Metadata {
12
+ //Most fields map directly to the contents of the plugin's info.json file.
13
+ //See the relevant docs for a description of their meaning.
14
+ public $name;
15
+ public $slug;
16
+ public $version;
17
+ public $homepage;
18
+ public $sections = array();
19
+ public $download_url;
20
+
21
+ public $banners;
22
+ public $icons = array();
23
+ public $translations = array();
24
+
25
+ public $author;
26
+ public $author_homepage;
27
+
28
+ public $requires;
29
+ public $tested;
30
+ public $upgrade_notice;
31
+
32
+ public $rating;
33
+ public $num_ratings;
34
+ public $downloaded;
35
+ public $active_installs;
36
+ public $last_updated;
37
+
38
+ public $id = 0; //The native WP.org API returns numeric plugin IDs, but they're not used for anything.
39
+
40
+ public $filename; //Plugin filename relative to the plugins directory.
41
+
42
+ /**
43
+ * Create a new instance of Plugin Info from JSON-encoded plugin info
44
+ * returned by an external update API.
45
+ *
46
+ * @param string $json Valid JSON string representing plugin info.
47
+ * @return self|null New instance of Plugin Info, or NULL on error.
48
+ */
49
+ public static function fromJson($json){
50
+ $instance = new self();
51
+
52
+ if ( !parent::createFromJson($json, $instance) ) {
53
+ return null;
54
+ }
55
+
56
+ //json_decode decodes assoc. arrays as objects. We want them as arrays.
57
+ $instance->sections = (array)$instance->sections;
58
+ $instance->icons = (array)$instance->icons;
59
+
60
+ return $instance;
61
+ }
62
+
63
+ /**
64
+ * Very, very basic validation.
65
+ *
66
+ * @param StdClass $apiResponse
67
+ * @return bool|WP_Error
68
+ */
69
+ protected function validateMetadata($apiResponse) {
70
+ if (
71
+ !isset($apiResponse->name, $apiResponse->version)
72
+ || empty($apiResponse->name)
73
+ || empty($apiResponse->version)
74
+ ) {
75
+ return new WP_Error(
76
+ 'puc-invalid-metadata',
77
+ "The plugin metadata file does not contain the required 'name' and/or 'version' keys."
78
+ );
79
+ }
80
+ return true;
81
+ }
82
+
83
+
84
+ /**
85
+ * Transform plugin info into the format used by the native WordPress.org API
86
+ *
87
+ * @return object
88
+ */
89
+ public function toWpFormat(){
90
+ $info = new stdClass;
91
+
92
+ //The custom update API is built so that many fields have the same name and format
93
+ //as those returned by the native WordPress.org API. These can be assigned directly.
94
+ $sameFormat = array(
95
+ 'name', 'slug', 'version', 'requires', 'tested', 'rating', 'upgrade_notice',
96
+ 'num_ratings', 'downloaded', 'active_installs', 'homepage', 'last_updated',
97
+ );
98
+ foreach($sameFormat as $field){
99
+ if ( isset($this->$field) ) {
100
+ $info->$field = $this->$field;
101
+ } else {
102
+ $info->$field = null;
103
+ }
104
+ }
105
+
106
+ //Other fields need to be renamed and/or transformed.
107
+ $info->download_link = $this->download_url;
108
+ $info->author = $this->getFormattedAuthor();
109
+ $info->sections = array_merge(array('description' => ''), $this->sections);
110
+
111
+ if ( !empty($this->banners) ) {
112
+ //WP expects an array with two keys: "high" and "low". Both are optional.
113
+ //Docs: https://wordpress.org/plugins/about/faq/#banners
114
+ $info->banners = is_object($this->banners) ? get_object_vars($this->banners) : $this->banners;
115
+ $info->banners = array_intersect_key($info->banners, array('high' => true, 'low' => true));
116
+ }
117
+
118
+ return $info;
119
+ }
120
+
121
+ protected function getFormattedAuthor() {
122
+ if ( !empty($this->author_homepage) ){
123
+ /** @noinspection HtmlUnknownTarget */
124
+ return sprintf('<a href="%s">%s</a>', $this->author_homepage, $this->author);
125
+ }
126
+ return $this->author;
127
+ }
128
+ }
129
+
130
+ endif;
lib/plugin-update-checker/Puc/v4p8/Plugin/Package.php ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p8_Plugin_Package', false) ):
3
+
4
+ class Puc_v4p8_Plugin_Package extends Puc_v4p8_InstalledPackage {
5
+ /**
6
+ * @var Puc_v4p8_Plugin_UpdateChecker
7
+ */
8
+ protected $updateChecker;
9
+
10
+ /**
11
+ * @var string Full path of the main plugin file.
12
+ */
13
+ protected $pluginAbsolutePath = '';
14
+
15
+ /**
16
+ * @var string Plugin basename.
17
+ */
18
+ private $pluginFile;
19
+
20
+ /**
21
+ * @var string|null
22
+ */
23
+ private $cachedInstalledVersion = null;
24
+
25
+ public function __construct($pluginAbsolutePath, $updateChecker) {
26
+ $this->pluginAbsolutePath = $pluginAbsolutePath;
27
+ $this->pluginFile = plugin_basename($this->pluginAbsolutePath);
28
+
29
+ parent::__construct($updateChecker);
30
+
31
+ //Clear the version number cache when something - anything - is upgraded or WP clears the update cache.
32
+ add_filter('upgrader_post_install', array($this, 'clearCachedVersion'));
33
+ add_action('delete_site_transient_update_plugins', array($this, 'clearCachedVersion'));
34
+ }
35
+
36
+ public function getInstalledVersion() {
37
+ if ( isset($this->cachedInstalledVersion) ) {
38
+ return $this->cachedInstalledVersion;
39
+ }
40
+
41
+ $pluginHeader = $this->getPluginHeader();
42
+ if ( isset($pluginHeader['Version']) ) {
43
+ $this->cachedInstalledVersion = $pluginHeader['Version'];
44
+ return $pluginHeader['Version'];
45
+ } else {
46
+ //This can happen if the filename points to something that is not a plugin.
47
+ $this->updateChecker->triggerError(
48
+ sprintf(
49
+ "Can't to read the Version header for '%s'. The filename is incorrect or is not a plugin.",
50
+ $this->updateChecker->pluginFile
51
+ ),
52
+ E_USER_WARNING
53
+ );
54
+ return null;
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Clear the cached plugin version. This method can be set up as a filter (hook) and will
60
+ * return the filter argument unmodified.
61
+ *
62
+ * @param mixed $filterArgument
63
+ * @return mixed
64
+ */
65
+ public function clearCachedVersion($filterArgument = null) {
66
+ $this->cachedInstalledVersion = null;
67
+ return $filterArgument;
68
+ }
69
+
70
+ public function getAbsoluteDirectoryPath() {
71
+ return dirname($this->pluginAbsolutePath);
72
+ }
73
+
74
+ /**
75
+ * Get the value of a specific plugin or theme header.
76
+ *
77
+ * @param string $headerName
78
+ * @param string $defaultValue
79
+ * @return string Either the value of the header, or $defaultValue if the header doesn't exist or is empty.
80
+ */
81
+ public function getHeaderValue($headerName, $defaultValue = '') {
82
+ $headers = $this->getPluginHeader();
83
+ if ( isset($headers[$headerName]) && ($headers[$headerName] !== '') ) {
84
+ return $headers[$headerName];
85
+ }
86
+ return $defaultValue;
87
+ }
88
+
89
+ protected function getHeaderNames() {
90
+ return array(
91
+ 'Name' => 'Plugin Name',
92
+ 'PluginURI' => 'Plugin URI',
93
+ 'Version' => 'Version',
94
+ 'Description' => 'Description',
95
+ 'Author' => 'Author',
96
+ 'AuthorURI' => 'Author URI',
97
+ 'TextDomain' => 'Text Domain',
98
+ 'DomainPath' => 'Domain Path',
99
+ 'Network' => 'Network',
100
+
101
+ //The newest WordPress version that this plugin requires or has been tested with.
102
+ //We support several different formats for compatibility with other libraries.
103
+ 'Tested WP' => 'Tested WP',
104
+ 'Requires WP' => 'Requires WP',
105
+ 'Tested up to' => 'Tested up to',
106
+ 'Requires at least' => 'Requires at least',
107
+ );
108
+ }
109
+
110
+ /**
111
+ * Get the translated plugin title.
112
+ *
113
+ * @return string
114
+ */
115
+ public function getPluginTitle() {
116
+ $title = '';
117
+ $header = $this->getPluginHeader();
118
+ if ( $header && !empty($header['Name']) && isset($header['TextDomain']) ) {
119
+ $title = translate($header['Name'], $header['TextDomain']);
120
+ }
121
+ return $title;
122
+ }
123
+
124
+ /**
125
+ * Get plugin's metadata from its file header.
126
+ *
127
+ * @return array
128
+ */
129
+ public function getPluginHeader() {
130
+ if ( !is_file($this->pluginAbsolutePath) ) {
131
+ //This can happen if the plugin filename is wrong.
132
+ $this->updateChecker->triggerError(
133
+ sprintf(
134
+ "Can't to read the plugin header for '%s'. The file does not exist.",
135
+ $this->updateChecker->pluginFile
136
+ ),
137
+ E_USER_WARNING
138
+ );
139
+ return array();
140
+ }
141
+
142
+ if ( !function_exists('get_plugin_data') ) {
143
+ /** @noinspection PhpIncludeInspection */
144
+ require_once(ABSPATH . '/wp-admin/includes/plugin.php');
145
+ }
146
+ return get_plugin_data($this->pluginAbsolutePath, false, false);
147
+ }
148
+
149
+ public function removeHooks() {
150
+ remove_filter('upgrader_post_install', array($this, 'clearCachedVersion'));
151
+ remove_action('delete_site_transient_update_plugins', array($this, 'clearCachedVersion'));
152
+ }
153
+
154
+ /**
155
+ * Check if the plugin file is inside the mu-plugins directory.
156
+ *
157
+ * @return bool
158
+ */
159
+ public function isMuPlugin() {
160
+ static $cachedResult = null;
161
+
162
+ if ( $cachedResult === null ) {
163
+ if ( !defined('WPMU_PLUGIN_DIR') || !is_string(WPMU_PLUGIN_DIR) ) {
164
+ $cachedResult = false;
165
+ return $cachedResult;
166
+ }
167
+
168
+ //Convert both paths to the canonical form before comparison.
169
+ $muPluginDir = realpath(WPMU_PLUGIN_DIR);
170
+ $pluginPath = realpath($this->pluginAbsolutePath);
171
+ //If realpath() fails, just normalize the syntax instead.
172
+ if (($muPluginDir === false) || ($pluginPath === false)) {
173
+ $muPluginDir = Puc_v4p8_Factory::normalizePath(WPMU_PLUGIN_DIR);
174
+ $pluginPath = Puc_v4p8_Factory::normalizePath($this->pluginAbsolutePath);
175
+ }
176
+
177
+ $cachedResult = (strpos($pluginPath, $muPluginDir) === 0);
178
+ }
179
+
180
+ return $cachedResult;
181
+ }
182
+ }
183
+
184
+ endif;
lib/plugin-update-checker/Puc/v4p8/Plugin/Ui.php ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p8_Plugin_Ui', false) ):
3
+ /**
4
+ * Additional UI elements for plugins.
5
+ */
6
+ class Puc_v4p8_Plugin_Ui {
7
+ private $updateChecker;
8
+ private $manualCheckErrorTransient = '';
9
+
10
+ /**
11
+ * @param Puc_v4p8_Plugin_UpdateChecker $updateChecker
12
+ */
13
+ public function __construct($updateChecker) {
14
+ $this->updateChecker = $updateChecker;
15
+ $this->manualCheckErrorTransient = $this->updateChecker->getUniqueName('manual_check_errors');
16
+
17
+ add_action('admin_init', array($this, 'onAdminInit'));
18
+ }
19
+
20
+ public function onAdminInit() {
21
+ if ( $this->updateChecker->userCanInstallUpdates() ) {
22
+ $this->handleManualCheck();
23
+
24
+ add_filter('plugin_row_meta', array($this, 'addViewDetailsLink'), 10, 3);
25
+ add_filter('plugin_row_meta', array($this, 'addCheckForUpdatesLink'), 10, 2);
26
+ add_action('all_admin_notices', array($this, 'displayManualCheckResult'));
27
+ }
28
+ }
29
+
30
+ /**
31
+ * Add a "View Details" link to the plugin row in the "Plugins" page. By default,
32
+ * the new link will appear before the "Visit plugin site" link (if present).
33
+ *
34
+ * You can change the link text by using the "puc_view_details_link-$slug" filter.
35
+ * Returning an empty string from the filter will disable the link.
36
+ *
37
+ * You can change the position of the link using the
38
+ * "puc_view_details_link_position-$slug" filter.
39
+ * Returning 'before' or 'after' will place the link immediately before/after
40
+ * the "Visit plugin site" link.
41
+ * Returning 'append' places the link after any existing links at the time of the hook.
42
+ * Returning 'replace' replaces the "Visit plugin site" link.
43
+ * Returning anything else disables the link when there is a "Visit plugin site" link.
44
+ *
45
+ * If there is no "Visit plugin site" link 'append' is always used!
46
+ *
47
+ * @param array $pluginMeta Array of meta links.
48
+ * @param string $pluginFile
49
+ * @param array $pluginData Array of plugin header data.
50
+ * @return array
51
+ */
52
+ public function addViewDetailsLink($pluginMeta, $pluginFile, $pluginData = array()) {
53
+ if ( $this->isMyPluginFile($pluginFile) && !isset($pluginData['slug']) ) {
54
+ $linkText = apply_filters($this->updateChecker->getUniqueName('view_details_link'), __('View details'));
55
+ if ( !empty($linkText) ) {
56
+ $viewDetailsLinkPosition = 'append';
57
+
58
+ //Find the "Visit plugin site" link (if present).
59
+ $visitPluginSiteLinkIndex = count($pluginMeta) - 1;
60
+ if ( $pluginData['PluginURI'] ) {
61
+ $escapedPluginUri = esc_url($pluginData['PluginURI']);
62
+ foreach ($pluginMeta as $linkIndex => $existingLink) {
63
+ if ( strpos($existingLink, $escapedPluginUri) !== false ) {
64
+ $visitPluginSiteLinkIndex = $linkIndex;
65
+ $viewDetailsLinkPosition = apply_filters(
66
+ $this->updateChecker->getUniqueName('view_details_link_position'),
67
+ 'before'
68
+ );
69
+ break;
70
+ }
71
+ }
72
+ }
73
+
74
+ $viewDetailsLink = sprintf('<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>',
75
+ esc_url(network_admin_url('plugin-install.php?tab=plugin-information&plugin=' . urlencode($this->updateChecker->slug) .
76
+ '&TB_iframe=true&width=600&height=550')),
77
+ esc_attr(sprintf(__('More information about %s'), $pluginData['Name'])),
78
+ esc_attr($pluginData['Name']),
79
+ $linkText
80
+ );
81
+ switch ($viewDetailsLinkPosition) {
82
+ case 'before':
83
+ array_splice($pluginMeta, $visitPluginSiteLinkIndex, 0, $viewDetailsLink);
84
+ break;
85
+ case 'after':
86
+ array_splice($pluginMeta, $visitPluginSiteLinkIndex + 1, 0, $viewDetailsLink);
87
+ break;
88
+ case 'replace':
89
+ $pluginMeta[$visitPluginSiteLinkIndex] = $viewDetailsLink;
90
+ break;
91
+ case 'append':
92
+ default:
93
+ $pluginMeta[] = $viewDetailsLink;
94
+ break;
95
+ }
96
+ }
97
+ }
98
+ return $pluginMeta;
99
+ }
100
+
101
+ /**
102
+ * Add a "Check for updates" link to the plugin row in the "Plugins" page. By default,
103
+ * the new link will appear after the "Visit plugin site" link if present, otherwise
104
+ * after the "View plugin details" link.
105
+ *
106
+ * You can change the link text by using the "puc_manual_check_link-$slug" filter.
107
+ * Returning an empty string from the filter will disable the link.
108
+ *
109
+ * @param array $pluginMeta Array of meta links.
110
+ * @param string $pluginFile
111
+ * @return array
112
+ */
113
+ public function addCheckForUpdatesLink($pluginMeta, $pluginFile) {
114
+ if ( $this->isMyPluginFile($pluginFile) ) {
115
+ $linkUrl = wp_nonce_url(
116
+ add_query_arg(
117
+ array(
118
+ 'puc_check_for_updates' => 1,
119
+ 'puc_slug' => $this->updateChecker->slug,
120
+ ),
121
+ self_admin_url('plugins.php')
122
+ ),
123
+ 'puc_check_for_updates'
124
+ );
125
+
126
+ $linkText = apply_filters(
127
+ $this->updateChecker->getUniqueName('manual_check_link'),
128
+ __('Check for updates', 'plugin-update-checker')
129
+ );
130
+ if ( !empty($linkText) ) {
131
+ /** @noinspection HtmlUnknownTarget */
132
+ $pluginMeta[] = sprintf('<a href="%s">%s</a>', esc_attr($linkUrl), $linkText);
133
+ }
134
+ }
135
+ return $pluginMeta;
136
+ }
137
+
138
+ protected function isMyPluginFile($pluginFile) {
139
+ return ($pluginFile == $this->updateChecker->pluginFile)
140
+ || (!empty($this->updateChecker->muPluginFile) && ($pluginFile == $this->updateChecker->muPluginFile));
141
+ }
142
+
143
+ /**
144
+ * Check for updates when the user clicks the "Check for updates" link.
145
+ *
146
+ * @see self::addCheckForUpdatesLink()
147
+ *
148
+ * @return void
149
+ */
150
+ public function handleManualCheck() {
151
+ $shouldCheck =
152
+ isset($_GET['puc_check_for_updates'], $_GET['puc_slug'])
153
+ && $_GET['puc_slug'] == $this->updateChecker->slug
154
+ && check_admin_referer('puc_check_for_updates');
155
+
156
+ if ( $shouldCheck ) {
157
+ $update = $this->updateChecker->checkForUpdates();
158
+ $status = ($update === null) ? 'no_update' : 'update_available';
159
+
160
+ if ( ($update === null) && !empty($this->lastRequestApiErrors) ) {
161
+ //Some errors are not critical. For example, if PUC tries to retrieve the readme.txt
162
+ //file from GitHub and gets a 404, that's an API error, but it doesn't prevent updates
163
+ //from working. Maybe the plugin simply doesn't have a readme.
164
+ //Let's only show important errors.
165
+ $foundCriticalErrors = false;
166
+ $questionableErrorCodes = array(
167
+ 'puc-github-http-error',
168
+ 'puc-gitlab-http-error',
169
+ 'puc-bitbucket-http-error',
170
+ );
171
+
172
+ foreach ($this->lastRequestApiErrors as $item) {
173
+ $wpError = $item['error'];
174
+ /** @var WP_Error $wpError */
175
+ if ( !in_array($wpError->get_error_code(), $questionableErrorCodes) ) {
176
+ $foundCriticalErrors = true;
177
+ break;
178
+ }
179
+ }
180
+
181
+ if ( $foundCriticalErrors ) {
182
+ $status = 'error';
183
+ set_site_transient($this->manualCheckErrorTransient, $this->lastRequestApiErrors, 60);
184
+ }
185
+ }
186
+
187
+ wp_redirect(add_query_arg(
188
+ array(
189
+ 'puc_update_check_result' => $status,
190
+ 'puc_slug' => $this->updateChecker->slug,
191
+ ),
192
+ self_admin_url('plugins.php')
193
+ ));
194
+ exit;
195
+ }
196
+ }
197
+
198
+ /**
199
+ * Display the results of a manual update check.
200
+ *
201
+ * @see self::handleManualCheck()
202
+ *
203
+ * You can change the result message by using the "puc_manual_check_message-$slug" filter.
204
+ */
205
+ public function displayManualCheckResult() {
206
+ if ( isset($_GET['puc_update_check_result'], $_GET['puc_slug']) && ($_GET['puc_slug'] == $this->updateChecker->slug) ) {
207
+ $status = strval($_GET['puc_update_check_result']);
208
+ $title = $this->updateChecker->getInstalledPackage()->getPluginTitle();
209
+ $noticeClass = 'updated notice-success';
210
+ $details = '';
211
+
212
+ if ( $status == 'no_update' ) {
213
+ $message = sprintf(_x('The %s plugin is up to date.', 'the plugin title', 'plugin-update-checker'), $title);
214
+ } else if ( $status == 'update_available' ) {
215
+ $message = sprintf(_x('A new version of the %s plugin is available.', 'the plugin title', 'plugin-update-checker'), $title);
216
+ } else if ( $status === 'error' ) {
217
+ $message = sprintf(_x('Could not determine if updates are available for %s.', 'the plugin title', 'plugin-update-checker'), $title);
218
+ $noticeClass = 'error notice-error';
219
+
220
+ $details = $this->formatManualCheckErrors(get_site_transient($this->manualCheckErrorTransient));
221
+ delete_site_transient($this->manualCheckErrorTransient);
222
+ } else {
223
+ $message = sprintf(__('Unknown update checker status "%s"', 'plugin-update-checker'), htmlentities($status));
224
+ $noticeClass = 'error notice-error';
225
+ }
226
+ printf(
227
+ '<div class="notice %s is-dismissible"><p>%s</p>%s</div>',
228
+ $noticeClass,
229
+ apply_filters($this->updateChecker->getUniqueName('manual_check_message'), $message, $status),
230
+ $details
231
+ );
232
+ }
233
+ }
234
+
235
+ /**
236
+ * Format the list of errors that were thrown during an update check.
237
+ *
238
+ * @param array $errors
239
+ * @return string
240
+ */
241
+ protected function formatManualCheckErrors($errors) {
242
+ if ( empty($errors) ) {
243
+ return '';
244
+ }
245
+ $output = '';
246
+
247
+ $showAsList = count($errors) > 1;
248
+ if ( $showAsList ) {
249
+ $output .= '<ol>';
250
+ $formatString = '<li>%1$s <code>%2$s</code></li>';
251
+ } else {
252
+ $formatString = '<p>%1$s <code>%2$s</code></p>';
253
+ }
254
+ foreach ($errors as $item) {
255
+ $wpError = $item['error'];
256
+ /** @var WP_Error $wpError */
257
+ $output .= sprintf(
258
+ $formatString,
259
+ $wpError->get_error_message(),
260
+ $wpError->get_error_code()
261
+ );
262
+ }
263
+ if ( $showAsList ) {
264
+ $output .= '</ol>';
265
+ }
266
+
267
+ return $output;
268
+ }
269
+
270
+ public function removeHooks() {
271
+ remove_action('admin_init', array($this, 'onAdminInit'));
272
+ remove_filter('plugin_row_meta', array($this, 'addViewDetailsLink'), 10);
273
+ remove_filter('plugin_row_meta', array($this, 'addCheckForUpdatesLink'), 10);
274
+ remove_action('all_admin_notices', array($this, 'displayManualCheckResult'));
275
+ }
276
+ }
277
+ endif;
lib/plugin-update-checker/Puc/v4p8/Plugin/Update.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p8_Plugin_Update', false) ):
3
+
4
+ /**
5
+ * A simple container class for holding information about an available update.
6
+ *
7
+ * @author Janis Elsts
8
+ * @copyright 2016
9
+ * @access public
10
+ */
11
+ class Puc_v4p8_Plugin_Update extends Puc_v4p8_Update {
12
+ public $id = 0;
13
+ public $homepage;
14
+ public $upgrade_notice;
15
+ public $tested;
16
+ public $icons = array();
17
+ public $filename; //Plugin filename relative to the plugins directory.
18
+
19
+ protected static $extraFields = array(
20
+ 'id', 'homepage', 'tested', 'upgrade_notice', 'icons', 'filename',
21
+ );
22
+
23
+ /**
24
+ * Create a new instance of PluginUpdate from its JSON-encoded representation.
25
+ *
26
+ * @param string $json
27
+ * @return Puc_v4p8_Plugin_Update|null
28
+ */
29
+ public static function fromJson($json){
30
+ //Since update-related information is simply a subset of the full plugin info,
31
+ //we can parse the update JSON as if it was a plugin info string, then copy over
32
+ //the parts that we care about.
33
+ $pluginInfo = Puc_v4p8_Plugin_Info::fromJson($json);
34
+ if ( $pluginInfo !== null ) {
35
+ return self::fromPluginInfo($pluginInfo);
36
+ } else {
37
+ return null;
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Create a new instance of PluginUpdate based on an instance of PluginInfo.
43
+ * Basically, this just copies a subset of fields from one object to another.
44
+ *
45
+ * @param Puc_v4p8_Plugin_Info $info
46
+ * @return Puc_v4p8_Plugin_Update
47
+ */
48
+ public static function fromPluginInfo($info){
49
+ return self::fromObject($info);
50
+ }
51
+
52
+ /**
53
+ * Create a new instance by copying the necessary fields from another object.
54
+ *
55
+ * @param StdClass|Puc_v4p8_Plugin_Info|Puc_v4p8_Plugin_Update $object The source object.
56
+ * @return Puc_v4p8_Plugin_Update The new copy.
57
+ */
58
+ public static function fromObject($object) {
59
+ $update = new self();
60
+ $update->copyFields($object, $update);
61
+ return $update;
62
+ }
63
+
64
+ /**
65
+ * @return string[]
66
+ */
67
+ protected function getFieldNames() {
68
+ return array_merge(parent::getFieldNames(), self::$extraFields);
69
+ }
70
+
71
+ /**
72
+ * Transform the update into the format used by WordPress native plugin API.
73
+ *
74
+ * @return object
75
+ */
76
+ public function toWpFormat() {
77
+ $update = parent::toWpFormat();
78
+
79
+ $update->id = $this->id;
80
+ $update->url = $this->homepage;
81
+ $update->tested = $this->tested;
82
+ $update->plugin = $this->filename;
83
+
84
+ if ( !empty($this->upgrade_notice) ) {
85
+ $update->upgrade_notice = $this->upgrade_notice;
86
+ }
87
+
88
+ if ( !empty($this->icons) && is_array($this->icons) ) {
89
+ //This should be an array with up to 4 keys: 'svg', '1x', '2x' and 'default'.
90
+ //Docs: https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/#plugin-icons
91
+ $icons = array_intersect_key(
92
+ $this->icons,
93
+ array('svg' => true, '1x' => true, '2x' => true, 'default' => true)
94
+ );
95
+ if ( !empty($icons) ) {
96
+ $update->icons = $icons;
97
+
98
+ //It appears that the 'default' icon isn't used anywhere in WordPress 4.9,
99
+ //but lets set it just in case a future release needs it.
100
+ if ( !isset($update->icons['default']) ) {
101
+ $update->icons['default'] = current($update->icons);
102
+ }
103
+ }
104
+ }
105
+
106
+ return $update;
107
+ }
108
+ }
109
+
110
+ endif;
lib/plugin-update-checker/Puc/v4p8/Plugin/UpdateChecker.php ADDED
@@ -0,0 +1,398 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p8_Plugin_UpdateChecker', false) ):
3
+
4
+ /**
5
+ * A custom plugin update checker.
6
+ *
7
+ * @author Janis Elsts
8
+ * @copyright 2018
9
+ * @access public
10
+ */
11
+ class Puc_v4p8_Plugin_UpdateChecker extends Puc_v4p8_UpdateChecker {
12
+ protected $updateTransient = 'update_plugins';
13
+ protected $translationType = 'plugin';
14
+
15
+ public $pluginAbsolutePath = ''; //Full path of the main plugin file.
16
+ public $pluginFile = ''; //Plugin filename relative to the plugins directory. Many WP APIs use this to identify plugins.
17
+ public $muPluginFile = ''; //For MU plugins, the plugin filename relative to the mu-plugins directory.
18
+
19
+ /**
20
+ * @var Puc_v4p8_Plugin_Package
21
+ */
22
+ protected $package;
23
+
24
+ private $extraUi = null;
25
+
26
+ /**
27
+ * Class constructor.
28
+ *
29
+ * @param string $metadataUrl The URL of the plugin's metadata file.
30
+ * @param string $pluginFile Fully qualified path to the main plugin file.
31
+ * @param string $slug The plugin's 'slug'. If not specified, the filename part of $pluginFile sans '.php' will be used as the slug.
32
+ * @param integer $checkPeriod How often to check for updates (in hours). Defaults to checking every 12 hours. Set to 0 to disable automatic update checks.
33
+ * @param string $optionName Where to store book-keeping info about update checks. Defaults to 'external_updates-$slug'.
34
+ * @param string $muPluginFile Optional. The plugin filename relative to the mu-plugins directory.
35
+ */
36
+ public function __construct($metadataUrl, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = ''){
37
+ $this->pluginAbsolutePath = $pluginFile;
38
+ $this->pluginFile = plugin_basename($this->pluginAbsolutePath);
39
+ $this->muPluginFile = $muPluginFile;
40
+
41
+ //If no slug is specified, use the name of the main plugin file as the slug.
42
+ //For example, 'my-cool-plugin/cool-plugin.php' becomes 'cool-plugin'.
43
+ if ( empty($slug) ){
44
+ $slug = basename($this->pluginFile, '.php');
45
+ }
46
+
47
+ //Plugin slugs must be unique.
48
+ $slugCheckFilter = 'puc_is_slug_in_use-' . $slug;
49
+ $slugUsedBy = apply_filters($slugCheckFilter, false);
50
+ if ( $slugUsedBy ) {
51
+ $this->triggerError(sprintf(
52
+ 'Plugin slug "%s" is already in use by %s. Slugs must be unique.',
53
+ htmlentities($slug),
54
+ htmlentities($slugUsedBy)
55
+ ), E_USER_ERROR);
56
+ }
57
+ add_filter($slugCheckFilter, array($this, 'getAbsolutePath'));
58
+
59
+ //Backwards compatibility: If the plugin is a mu-plugin but no $muPluginFile is specified, assume
60
+ //it's the same as $pluginFile given that it's not in a subdirectory (WP only looks in the base dir).
61
+ if ( (strpbrk($this->pluginFile, '/\\') === false) && $this->isUnknownMuPlugin() ) {
62
+ $this->muPluginFile = $this->pluginFile;
63
+ }
64
+
65
+ //To prevent a crash during plugin uninstallation, remove updater hooks when the user removes the plugin.
66
+ //Details: https://github.com/YahnisElsts/plugin-update-checker/issues/138#issuecomment-335590964
67
+ add_action('uninstall_' . $this->pluginFile, array($this, 'removeHooks'));
68
+
69
+ parent::__construct($metadataUrl, dirname($this->pluginFile), $slug, $checkPeriod, $optionName);
70
+
71
+ $this->extraUi = new Puc_v4p8_Plugin_Ui($this);
72
+ }
73
+
74
+ /**
75
+ * Create an instance of the scheduler.
76
+ *
77
+ * @param int $checkPeriod
78
+ * @return Puc_v4p8_Scheduler
79
+ */
80
+ protected function createScheduler($checkPeriod) {
81
+ $scheduler = new Puc_v4p8_Scheduler($this, $checkPeriod, array('load-plugins.php'));
82
+ register_deactivation_hook($this->pluginFile, array($scheduler, 'removeUpdaterCron'));
83
+ return $scheduler;
84
+ }
85
+
86
+ /**
87
+ * Install the hooks required to run periodic update checks and inject update info
88
+ * into WP data structures.
89
+ *
90
+ * @return void
91
+ */
92
+ protected function installHooks(){
93
+ //Override requests for plugin information
94
+ add_filter('plugins_api', array($this, 'injectInfo'), 20, 3);
95
+
96
+ parent::installHooks();
97
+ }
98
+
99
+ /**
100
+ * Remove update checker hooks.
101
+ *
102
+ * The intent is to prevent a fatal error that can happen if the plugin has an uninstall
103
+ * hook. During uninstallation, WP includes the main plugin file (which creates a PUC instance),
104
+ * the uninstall hook runs, WP deletes the plugin files and then updates some transients.
105
+ * If PUC hooks are still around at this time, they could throw an error while trying to
106
+ * autoload classes from files that no longer exist.
107
+ *
108
+ * The "site_transient_{$transient}" filter is the main problem here, but let's also remove
109
+ * most other PUC hooks to be safe.
110
+ *
111
+ * @internal
112
+ */
113
+ public function removeHooks() {
114
+ parent::removeHooks();
115
+ $this->extraUi->removeHooks();
116
+ $this->package->removeHooks();
117
+
118
+ remove_filter('plugins_api', array($this, 'injectInfo'), 20);
119
+ }
120
+
121
+ /**
122
+ * Retrieve plugin info from the configured API endpoint.
123
+ *
124
+ * @uses wp_remote_get()
125
+ *
126
+ * @param array $queryArgs Additional query arguments to append to the request. Optional.
127
+ * @return Puc_v4p8_Plugin_Info
128
+ */
129
+ public function requestInfo($queryArgs = array()) {
130
+ list($pluginInfo, $result) = $this->requestMetadata('Puc_v4p8_Plugin_Info', 'request_info', $queryArgs);
131
+
132
+ if ( $pluginInfo !== null ) {
133
+ /** @var Puc_v4p8_Plugin_Info $pluginInfo */
134
+ $pluginInfo->filename = $this->pluginFile;
135
+ $pluginInfo->slug = $this->slug;
136
+ }
137
+
138
+ $pluginInfo = apply_filters($this->getUniqueName('request_info_result'), $pluginInfo, $result);
139
+ return $pluginInfo;
140
+ }
141
+
142
+ /**
143
+ * Retrieve the latest update (if any) from the configured API endpoint.
144
+ *
145
+ * @uses PluginUpdateChecker::requestInfo()
146
+ *
147
+ * @return Puc_v4p8_Update|null An instance of Plugin_Update, or NULL when no updates are available.
148
+ */
149
+ public function requestUpdate() {
150
+ //For the sake of simplicity, this function just calls requestInfo()
151
+ //and transforms the result accordingly.
152
+ $pluginInfo = $this->requestInfo(array('checking_for_updates' => '1'));
153
+ if ( $pluginInfo === null ){
154
+ return null;
155
+ }
156
+ $update = Puc_v4p8_Plugin_Update::fromPluginInfo($pluginInfo);
157
+
158
+ $update = $this->filterUpdateResult($update);
159
+
160
+ return $update;
161
+ }
162
+
163
+ /**
164
+ * Intercept plugins_api() calls that request information about our plugin and
165
+ * use the configured API endpoint to satisfy them.
166
+ *
167
+ * @see plugins_api()
168
+ *
169
+ * @param mixed $result
170
+ * @param string $action
171
+ * @param array|object $args
172
+ * @return mixed
173
+ */
174
+ public function injectInfo($result, $action = null, $args = null){
175
+ $relevant = ($action == 'plugin_information') && isset($args->slug) && (
176
+ ($args->slug == $this->slug) || ($args->slug == dirname($this->pluginFile))
177
+ );
178
+ if ( !$relevant ) {
179
+ return $result;
180
+ }
181
+
182
+ $pluginInfo = $this->requestInfo();
183
+ $this->fixSupportedWordpressVersion($pluginInfo);
184
+
185
+ $pluginInfo = apply_filters($this->getUniqueName('pre_inject_info'), $pluginInfo);
186
+ if ( $pluginInfo ) {
187
+ return $pluginInfo->toWpFormat();
188
+ }
189
+
190
+ return $result;
191
+ }
192
+
193
+ protected function shouldShowUpdates() {
194
+ //No update notifications for mu-plugins unless explicitly enabled. The MU plugin file
195
+ //is usually different from the main plugin file so the update wouldn't show up properly anyway.
196
+ return !$this->isUnknownMuPlugin();
197
+ }
198
+
199
+ /**
200
+ * @param stdClass|null $updates
201
+ * @param stdClass $updateToAdd
202
+ * @return stdClass
203
+ */
204
+ protected function addUpdateToList($updates, $updateToAdd) {
205
+ if ( $this->package->isMuPlugin() ) {
206
+ //WP does not support automatic update installation for mu-plugins, but we can
207
+ //still display a notice.
208
+ $updateToAdd->package = null;
209
+ }
210
+ return parent::addUpdateToList($updates, $updateToAdd);
211
+ }
212
+
213
+ /**
214
+ * @param stdClass|null $updates
215
+ * @return stdClass|null
216
+ */
217
+ protected function removeUpdateFromList($updates) {
218
+ $updates = parent::removeUpdateFromList($updates);
219
+ if ( !empty($this->muPluginFile) && isset($updates, $updates->response) ) {
220
+ unset($updates->response[$this->muPluginFile]);
221
+ }
222
+ return $updates;
223
+ }
224
+
225
+ /**
226
+ * For plugins, the update array is indexed by the plugin filename relative to the "plugins"
227
+ * directory. Example: "plugin-name/plugin.php".
228
+ *
229
+ * @return string
230
+ */
231
+ protected function getUpdateListKey() {
232
+ if ( $this->package->isMuPlugin() ) {
233
+ return $this->muPluginFile;
234
+ }
235
+ return $this->pluginFile;
236
+ }
237
+
238
+ /**
239
+ * Alias for isBeingUpgraded().
240
+ *
241
+ * @deprecated
242
+ * @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
243
+ * @return bool
244
+ */
245
+ public function isPluginBeingUpgraded($upgrader = null) {
246
+ return $this->isBeingUpgraded($upgrader);
247
+ }
248
+
249
+ /**
250
+ * Is there an update being installed for this plugin, right now?
251
+ *
252
+ * @param WP_Upgrader|null $upgrader
253
+ * @return bool
254
+ */
255
+ public function isBeingUpgraded($upgrader = null) {
256
+ return $this->upgraderStatus->isPluginBeingUpgraded($this->pluginFile, $upgrader);
257
+ }
258
+
259
+ /**
260
+ * Get the details of the currently available update, if any.
261
+ *
262
+ * If no updates are available, or if the last known update version is below or equal
263
+ * to the currently installed version, this method will return NULL.
264
+ *
265
+ * Uses cached update data. To retrieve update information straight from
266
+ * the metadata URL, call requestUpdate() instead.
267
+ *
268
+ * @return Puc_v4p8_Plugin_Update|null
269
+ */
270
+ public function getUpdate() {
271
+ $update = parent::getUpdate();
272
+ if ( isset($update) ) {
273
+ /** @var Puc_v4p8_Plugin_Update $update */
274
+ $update->filename = $this->pluginFile;
275
+ }
276
+ return $update;
277
+ }
278
+
279
+ /**
280
+ * Get the translated plugin title.
281
+ *
282
+ * @deprecated
283
+ * @return string
284
+ */
285
+ public function getPluginTitle() {
286
+ return $this->package->getPluginTitle();
287
+ }
288
+
289
+ /**
290
+ * Check if the current user has the required permissions to install updates.
291
+ *
292
+ * @return bool
293
+ */
294
+ public function userCanInstallUpdates() {
295
+ return current_user_can('update_plugins');
296
+ }
297
+
298
+ /**
299
+ * Check if the plugin file is inside the mu-plugins directory.
300
+ *
301
+ * @deprecated
302
+ * @return bool
303
+ */
304
+ protected function isMuPlugin() {
305
+ return $this->package->isMuPlugin();
306
+ }
307
+
308
+ /**
309
+ * MU plugins are partially supported, but only when we know which file in mu-plugins
310
+ * corresponds to this plugin.
311
+ *
312
+ * @return bool
313
+ */
314
+ protected function isUnknownMuPlugin() {
315
+ return empty($this->muPluginFile) && $this->package->isMuPlugin();
316
+ }
317
+
318
+ /**
319
+ * Get absolute path to the main plugin file.
320
+ *
321
+ * @return string
322
+ */
323
+ public function getAbsolutePath() {
324
+ return $this->pluginAbsolutePath;
325
+ }
326
+
327
+ /**
328
+ * Register a callback for filtering query arguments.
329
+ *
330
+ * The callback function should take one argument - an associative array of query arguments.
331
+ * It should return a modified array of query arguments.
332
+ *
333
+ * @uses add_filter() This method is a convenience wrapper for add_filter().
334
+ *
335
+ * @param callable $callback
336
+ * @return void
337
+ */
338
+ public function addQueryArgFilter($callback){
339
+ $this->addFilter('request_info_query_args', $callback);
340
+ }
341
+
342
+ /**
343
+ * Register a callback for filtering arguments passed to wp_remote_get().
344
+ *
345
+ * The callback function should take one argument - an associative array of arguments -
346
+ * and return a modified array or arguments. See the WP documentation on wp_remote_get()
347
+ * for details on what arguments are available and how they work.
348
+ *
349
+ * @uses add_filter() This method is a convenience wrapper for add_filter().
350
+ *
351
+ * @param callable $callback
352
+ * @return void
353
+ */
354
+ public function addHttpRequestArgFilter($callback) {
355
+ $this->addFilter('request_info_options', $callback);
356
+ }
357
+
358
+ /**
359
+ * Register a callback for filtering the plugin info retrieved from the external API.
360
+ *
361
+ * The callback function should take two arguments. If the plugin info was retrieved
362
+ * successfully, the first argument passed will be an instance of PluginInfo. Otherwise,
363
+ * it will be NULL. The second argument will be the corresponding return value of
364
+ * wp_remote_get (see WP docs for details).
365
+ *
366
+ * The callback function should return a new or modified instance of PluginInfo or NULL.
367
+ *
368
+ * @uses add_filter() This method is a convenience wrapper for add_filter().
369
+ *
370
+ * @param callable $callback
371
+ * @return void
372
+ */
373
+ public function addResultFilter($callback) {
374
+ $this->addFilter('request_info_result', $callback, 10, 2);
375
+ }
376
+
377
+ protected function createDebugBarExtension() {
378
+ return new Puc_v4p8_DebugBar_PluginExtension($this);
379
+ }
380
+
381
+ /**
382
+ * Create a package instance that represents this plugin or theme.
383
+ *
384
+ * @return Puc_v4p8_InstalledPackage
385
+ */
386
+ protected function createInstalledPackage() {
387
+ return new Puc_v4p8_Plugin_Package($this->pluginAbsolutePath, $this);
388
+ }
389
+
390
+ /**
391
+ * @return Puc_v4p8_Plugin_Package
392
+ */
393
+ public function getInstalledPackage() {
394
+ return $this->package;
395
+ }
396
+ }
397
+
398
+ endif;
lib/plugin-update-checker/Puc/v4p8/Scheduler.php ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p8_Scheduler', false) ):
3
+
4
+ /**
5
+ * The scheduler decides when and how often to check for updates.
6
+ * It calls @see Puc_v4p8_UpdateChecker::checkForUpdates() to perform the actual checks.
7
+ */
8
+ class Puc_v4p8_Scheduler {
9
+ public $checkPeriod = 12; //How often to check for updates (in hours).
10
+ public $throttleRedundantChecks = false; //Check less often if we already know that an update is available.
11
+ public $throttledCheckPeriod = 72;
12
+
13
+ protected $hourlyCheckHooks = array('load-update.php');
14
+
15
+ /**
16
+ * @var Puc_v4p8_UpdateChecker
17
+ */
18
+ protected $updateChecker;
19
+
20
+ private $cronHook = null;
21
+
22
+ /**
23
+ * Scheduler constructor.
24
+ *
25
+ * @param Puc_v4p8_UpdateChecker $updateChecker
26
+ * @param int $checkPeriod How often to check for updates (in hours).
27
+ * @param array $hourlyHooks
28
+ */
29
+ public function __construct($updateChecker, $checkPeriod, $hourlyHooks = array('load-plugins.php')) {
30
+ $this->updateChecker = $updateChecker;
31
+ $this->checkPeriod = $checkPeriod;
32
+
33
+ //Set up the periodic update checks
34
+ $this->cronHook = $this->updateChecker->getUniqueName('cron_check_updates');
35
+ if ( $this->checkPeriod > 0 ){
36
+
37
+ //Trigger the check via Cron.
38
+ //Try to use one of the default schedules if possible as it's less likely to conflict
39
+ //with other plugins and their custom schedules.
40
+ $defaultSchedules = array(
41
+ 1 => 'hourly',
42
+ 12 => 'twicedaily',
43
+ 24 => 'daily',
44
+ );
45
+ if ( array_key_exists($this->checkPeriod, $defaultSchedules) ) {
46
+ $scheduleName = $defaultSchedules[$this->checkPeriod];
47
+ } else {
48
+ //Use a custom cron schedule.
49
+ $scheduleName = 'every' . $this->checkPeriod . 'hours';
50
+ add_filter('cron_schedules', array($this, '_addCustomSchedule'));
51
+ }
52
+
53
+ if ( !wp_next_scheduled($this->cronHook) && !defined('WP_INSTALLING') ) {
54
+ //Randomly offset the schedule to help prevent update server traffic spikes. Without this
55
+ //most checks may happen during times of day when people are most likely to install new plugins.
56
+ $firstCheckTime = time() - rand(0, max($this->checkPeriod * 3600 - 15 * 60, 1));
57
+ $firstCheckTime = apply_filters(
58
+ $this->updateChecker->getUniqueName('first_check_time'),
59
+ $firstCheckTime
60
+ );
61
+ wp_schedule_event($firstCheckTime, $scheduleName, $this->cronHook);
62
+ }
63
+ add_action($this->cronHook, array($this, 'maybeCheckForUpdates'));
64
+
65
+ //In case Cron is disabled or unreliable, we also manually trigger
66
+ //the periodic checks while the user is browsing the Dashboard.
67
+ add_action( 'admin_init', array($this, 'maybeCheckForUpdates') );
68
+
69
+ //Like WordPress itself, we check more often on certain pages.
70
+ /** @see wp_update_plugins */
71
+ add_action('load-update-core.php', array($this, 'maybeCheckForUpdates'));
72
+ //"load-update.php" and "load-plugins.php" or "load-themes.php".
73
+ $this->hourlyCheckHooks = array_merge($this->hourlyCheckHooks, $hourlyHooks);
74
+ foreach($this->hourlyCheckHooks as $hook) {
75
+ add_action($hook, array($this, 'maybeCheckForUpdates'));
76
+ }
77
+ //This hook fires after a bulk update is complete.
78
+ add_action('upgrader_process_complete', array($this, 'upgraderProcessComplete'), 11, 2);
79
+
80
+ } else {
81
+ //Periodic checks are disabled.
82
+ wp_clear_scheduled_hook($this->cronHook);
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Runs upon the WP action upgrader_process_complete.
88
+ *
89
+ * We look at the parameters to decide whether to call maybeCheckForUpdates() or not.
90
+ *
91
+ * @param WP_Upgrader $upgrader WP_Upgrader instance
92
+ * @param array $upgradeInfo extra information about the upgrade
93
+ */
94
+ public function upgraderProcessComplete(
95
+ /** @noinspection PhpUnusedParameterInspection */
96
+ $upgrader, $upgradeInfo
97
+ ) {
98
+
99
+ //Sanity check and limitation to relevant types.
100
+ if (
101
+ !is_array($upgradeInfo) || !isset($upgradeInfo['type'], $upgradeInfo['action'])
102
+ || 'update' !== $upgradeInfo['action'] || !in_array($upgradeInfo['type'], array('plugin', 'theme'))
103
+ ) {
104
+ return;
105
+ }
106
+
107
+ //Filter out notifications of upgrades that should have no bearing upon whether or not our
108
+ //current info is up-to-date.
109
+ if ( is_a($this->updateChecker, 'Puc_v4p8_Theme_UpdateChecker') ) {
110
+ if ( 'theme' !== $upgradeInfo['type'] || !isset($upgradeInfo['themes']) ) {
111
+ return;
112
+ }
113
+
114
+ //Letting too many things going through for checks is not a real problem, so we compare widely.
115
+ if ( !in_array(
116
+ strtolower($this->updateChecker->directoryName),
117
+ array_map('strtolower', $upgradeInfo['themes'])
118
+ ) ) {
119
+ return;
120
+ }
121
+ }
122
+
123
+ if ( is_a($this->updateChecker, 'Puc_v4p8_Plugin_UpdateChecker') ) {
124
+ if ( 'plugin' !== $upgradeInfo['type'] || !isset($upgradeInfo['plugins']) ) {
125
+ return;
126
+ }
127
+
128
+ //Themes pass in directory names in the information array, but plugins use the relative plugin path.
129
+ if ( !in_array(
130
+ strtolower($this->updateChecker->directoryName),
131
+ array_map('dirname', array_map('strtolower', $upgradeInfo['plugins']))
132
+ ) ) {
133
+ return;
134
+ }
135
+ }
136
+
137
+ $this->maybeCheckForUpdates();
138
+ }
139
+
140
+ /**
141
+ * Check for updates if the configured check interval has already elapsed.
142
+ * Will use a shorter check interval on certain admin pages like "Dashboard -> Updates" or when doing cron.
143
+ *
144
+ * You can override the default behaviour by using the "puc_check_now-$slug" filter.
145
+ * The filter callback will be passed three parameters:
146
+ * - Current decision. TRUE = check updates now, FALSE = don't check now.
147
+ * - Last check time as a Unix timestamp.
148
+ * - Configured check period in hours.
149
+ * Return TRUE to check for updates immediately, or FALSE to cancel.
150
+ *
151
+ * This method is declared public because it's a hook callback. Calling it directly is not recommended.
152
+ */
153
+ public function maybeCheckForUpdates() {
154
+ if ( empty($this->checkPeriod) ){
155
+ return;
156
+ }
157
+
158
+ $state = $this->updateChecker->getUpdateState();
159
+ $shouldCheck = ($state->timeSinceLastCheck() >= $this->getEffectiveCheckPeriod());
160
+
161
+ //Let plugin authors substitute their own algorithm.
162
+ $shouldCheck = apply_filters(
163
+ $this->updateChecker->getUniqueName('check_now'),
164
+ $shouldCheck,
165
+ $state->getLastCheck(),
166
+ $this->checkPeriod
167
+ );
168
+
169
+ if ( $shouldCheck ) {
170
+ $this->updateChecker->checkForUpdates();
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Calculate the actual check period based on the current status and environment.
176
+ *
177
+ * @return int Check period in seconds.
178
+ */
179
+ protected function getEffectiveCheckPeriod() {
180
+ $currentFilter = current_filter();
181
+ if ( in_array($currentFilter, array('load-update-core.php', 'upgrader_process_complete')) ) {
182
+ //Check more often when the user visits "Dashboard -> Updates" or does a bulk update.
183
+ $period = 60;
184
+ } else if ( in_array($currentFilter, $this->hourlyCheckHooks) ) {
185
+ //Also check more often on /wp-admin/update.php and the "Plugins" or "Themes" page.
186
+ $period = 3600;
187
+ } else if ( $this->throttleRedundantChecks && ($this->updateChecker->getUpdate() !== null) ) {
188
+ //Check less frequently if it's already known that an update is available.
189
+ $period = $this->throttledCheckPeriod * 3600;
190
+ } else if ( defined('DOING_CRON') && constant('DOING_CRON') ) {
191
+ //WordPress cron schedules are not exact, so lets do an update check even
192
+ //if slightly less than $checkPeriod hours have elapsed since the last check.
193
+ $cronFuzziness = 20 * 60;
194
+ $period = $this->checkPeriod * 3600 - $cronFuzziness;
195
+ } else {
196
+ $period = $this->checkPeriod * 3600;
197
+ }
198
+
199
+ return $period;
200
+ }
201
+
202
+ /**
203
+ * Add our custom schedule to the array of Cron schedules used by WP.
204
+ *
205
+ * @param array $schedules
206
+ * @return array
207
+ */
208
+ public function _addCustomSchedule($schedules) {
209
+ if ( $this->checkPeriod && ($this->checkPeriod > 0) ){
210
+ $scheduleName = 'every' . $this->checkPeriod . 'hours';
211
+ $schedules[$scheduleName] = array(
212
+ 'interval' => $this->checkPeriod * 3600,
213
+ 'display' => sprintf('Every %d hours', $this->checkPeriod),
214
+ );
215
+ }
216
+ return $schedules;
217
+ }
218
+
219
+ /**
220
+ * Remove the scheduled cron event that the library uses to check for updates.
221
+ *
222
+ * @return void
223
+ */
224
+ public function removeUpdaterCron() {
225
+ wp_clear_scheduled_hook($this->cronHook);
226
+ }
227
+
228
+ /**
229
+ * Get the name of the update checker's WP-cron hook. Mostly useful for debugging.
230
+ *
231
+ * @return string
232
+ */
233
+ public function getCronHookName() {
234
+ return $this->cronHook;
235
+ }
236
+ }
237
+
238
+ endif;
lib/plugin-update-checker/Puc/v4p8/StateStore.php ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p8_StateStore', false) ):
4
+
5
+ class Puc_v4p8_StateStore {
6
+ /**
7
+ * @var int Last update check timestamp.
8
+ */
9
+ protected $lastCheck = 0;
10
+
11
+ /**
12
+ * @var string Version number.
13
+ */
14
+ protected $checkedVersion = '';
15
+
16
+ /**
17
+ * @var Puc_v4p8_Update|null Cached update.
18
+ */
19
+ protected $update = null;
20
+
21
+ /**
22
+ * @var string Site option name.
23
+ */
24
+ private $optionName = '';
25
+
26
+ /**
27
+ * @var bool Whether we've already tried to load the state from the database.
28
+ */
29
+ private $isLoaded = false;
30
+
31
+ public function __construct($optionName) {
32
+ $this->optionName = $optionName;
33
+ }
34
+
35
+ /**
36
+ * Get time elapsed since the last update check.
37
+ *
38
+ * If there are no recorded update checks, this method returns a large arbitrary number
39
+ * (i.e. time since the Unix epoch).
40
+ *
41
+ * @return int Elapsed time in seconds.
42
+ */
43
+ public function timeSinceLastCheck() {
44
+ $this->lazyLoad();
45
+ return time() - $this->lastCheck;
46
+ }
47
+
48
+ /**
49
+ * @return int
50
+ */
51
+ public function getLastCheck() {
52
+ $this->lazyLoad();
53
+ return $this->lastCheck;
54
+ }
55
+
56
+ /**
57
+ * Set the time of the last update check to the current timestamp.
58
+ *
59
+ * @return $this
60
+ */
61
+ public function setLastCheckToNow() {
62
+ $this->lazyLoad();
63
+ $this->lastCheck = time();
64
+ return $this;
65
+ }
66
+
67
+ /**
68
+ * @return null|Puc_v4p8_Update
69
+ */
70
+ public function getUpdate() {
71
+ $this->lazyLoad();
72
+ return $this->update;
73
+ }
74
+
75
+ /**
76
+ * @param Puc_v4p8_Update|null $update
77
+ * @return $this
78
+ */
79
+ public function setUpdate(Puc_v4p8_Update $update = null) {
80
+ $this->lazyLoad();
81
+ $this->update = $update;
82
+ return $this;
83
+ }
84
+
85
+ /**
86
+ * @return string
87
+ */
88
+ public function getCheckedVersion() {
89
+ $this->lazyLoad();
90
+ return $this->checkedVersion;
91
+ }
92
+
93
+ /**
94
+ * @param string $version
95
+ * @return $this
96
+ */
97
+ public function setCheckedVersion($version) {
98
+ $this->lazyLoad();
99
+ $this->checkedVersion = strval($version);
100
+ return $this;
101
+ }
102
+
103
+ /**
104
+ * Get translation updates.
105
+ *
106
+ * @return array
107
+ */
108
+ public function getTranslations() {
109
+ $this->lazyLoad();
110
+ if ( isset($this->update, $this->update->translations) ) {
111
+ return $this->update->translations;
112
+ }
113
+ return array();
114
+ }
115
+
116
+ /**
117
+ * Set translation updates.
118
+ *
119
+ * @param array $translationUpdates
120
+ */
121
+ public function setTranslations($translationUpdates) {
122
+ $this->lazyLoad();
123
+ if ( isset($this->update) ) {
124
+ $this->update->translations = $translationUpdates;
125
+ $this->save();
126
+ }
127
+ }
128
+
129
+ public function save() {
130
+ $state = new stdClass();
131
+
132
+ $state->lastCheck = $this->lastCheck;
133
+ $state->checkedVersion = $this->checkedVersion;
134
+
135
+ if ( isset($this->update)) {
136
+ $state->update = $this->update->toStdClass();
137
+
138
+ $updateClass = get_class($this->update);
139
+ $state->updateClass = $updateClass;
140
+ $prefix = $this->getLibPrefix();
141
+ if ( Puc_v4p8_Utils::startsWith($updateClass, $prefix) ) {
142
+ $state->updateBaseClass = substr($updateClass, strlen($prefix));
143
+ }
144
+ }
145
+
146
+ update_site_option($this->optionName, $state);
147
+ $this->isLoaded = true;
148
+ }
149
+
150
+ /**
151
+ * @return $this
152
+ */
153
+ public function lazyLoad() {
154
+ if ( !$this->isLoaded ) {
155
+ $this->load();
156
+ }
157
+ return $this;
158
+ }
159
+
160
+ protected function load() {
161
+ $this->isLoaded = true;
162
+
163
+ $state = get_site_option($this->optionName, null);
164
+
165
+ if ( !is_object($state) ) {
166
+ $this->lastCheck = 0;
167
+ $this->checkedVersion = '';
168
+ $this->update = null;
169
+ return;
170
+ }
171
+
172
+ $this->lastCheck = intval(Puc_v4p8_Utils::get($state, 'lastCheck', 0));
173
+ $this->checkedVersion = Puc_v4p8_Utils::get($state, 'checkedVersion', '');
174
+ $this->update = null;
175
+
176
+ if ( isset($state->update) ) {
177
+ //This mess is due to the fact that the want the update class from this version
178
+ //of the library, not the version that saved the update.
179
+
180
+ $updateClass = null;
181
+ if ( isset($state->updateBaseClass) ) {
182
+ $updateClass = $this->getLibPrefix() . $state->updateBaseClass;
183
+ } else if ( isset($state->updateClass) && class_exists($state->updateClass) ) {
184
+ $updateClass = $state->updateClass;
185
+ }
186
+
187
+ if ( $updateClass !== null ) {
188
+ $this->update = call_user_func(array($updateClass, 'fromObject'), $state->update);
189
+ }
190
+ }
191
+ }
192
+
193
+ public function delete() {
194
+ delete_site_option($this->optionName);
195
+
196
+ $this->lastCheck = 0;
197
+ $this->checkedVersion = '';
198
+ $this->update = null;
199
+ }
200
+
201
+ private function getLibPrefix() {
202
+ $parts = explode('_', __CLASS__, 3);
203
+ return $parts[0] . '_' . $parts[1] . '_';
204
+ }
205
+ }
206
+
207
+ endif;
lib/plugin-update-checker/Puc/v4p8/Theme/Package.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p8_Theme_Package', false) ):
3
+
4
+ class Puc_v4p8_Theme_Package extends Puc_v4p8_InstalledPackage {
5
+ /**
6
+ * @var string Theme directory name.
7
+ */
8
+ protected $stylesheet;
9
+
10
+ /**
11
+ * @var WP_Theme Theme object.
12
+ */
13
+ protected $theme;
14
+
15
+ public function __construct($stylesheet, $updateChecker) {
16
+ $this->stylesheet = $stylesheet;
17
+ $this->theme = wp_get_theme($this->stylesheet);
18
+
19
+ parent::__construct($updateChecker);
20
+ }
21
+
22
+ public function getInstalledVersion() {
23
+ return $this->theme->get('Version');
24
+ }
25
+
26
+ public function getAbsoluteDirectoryPath() {
27
+ if ( method_exists($this->theme, 'get_stylesheet_directory') ) {
28
+ return $this->theme->get_stylesheet_directory(); //Available since WP 3.4.
29
+ }
30
+ return get_theme_root($this->stylesheet) . '/' . $this->stylesheet;
31
+ }
32
+
33
+ /**
34
+ * Get the value of a specific plugin or theme header.
35
+ *
36
+ * @param string $headerName
37
+ * @param string $defaultValue
38
+ * @return string Either the value of the header, or $defaultValue if the header doesn't exist or is empty.
39
+ */
40
+ public function getHeaderValue($headerName, $defaultValue = '') {
41
+ $value = $this->theme->get($headerName);
42
+ if ( ($headerName === false) || ($headerName === '') ) {
43
+ return $defaultValue;
44
+ }
45
+ return $value;
46
+ }
47
+
48
+ protected function getHeaderNames() {
49
+ return array(
50
+ 'Name' => 'Theme Name',
51
+ 'ThemeURI' => 'Theme URI',
52
+ 'Description' => 'Description',
53
+ 'Author' => 'Author',
54
+ 'AuthorURI' => 'Author URI',
55
+ 'Version' => 'Version',
56
+ 'Template' => 'Template',
57
+ 'Status' => 'Status',
58
+ 'Tags' => 'Tags',
59
+ 'TextDomain' => 'Text Domain',
60
+ 'DomainPath' => 'Domain Path',
61
+ );
62
+ }
63
+ }
64
+
65
+ endif;
lib/plugin-update-checker/Puc/v4p8/Theme/Update.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p8_Theme_Update', false) ):
4
+
5
+ class Puc_v4p8_Theme_Update extends Puc_v4p8_Update {
6
+ public $details_url = '';
7
+
8
+ protected static $extraFields = array('details_url');
9
+
10
+ /**
11
+ * Transform the metadata into the format used by WordPress core.
12
+ * Note the inconsistency: WP stores plugin updates as objects and theme updates as arrays.
13
+ *
14
+ * @return array
15
+ */
16
+ public function toWpFormat() {
17
+ $update = array(
18
+ 'theme' => $this->slug,
19
+ 'new_version' => $this->version,
20
+ 'url' => $this->details_url,
21
+ );
22
+
23
+ if ( !empty($this->download_url) ) {
24
+ $update['package'] = $this->download_url;
25
+ }
26
+
27
+ return $update;
28
+ }
29
+
30
+ /**
31
+ * Create a new instance of Theme_Update from its JSON-encoded representation.
32
+ *
33
+ * @param string $json Valid JSON string representing a theme information object.
34
+ * @return self New instance of ThemeUpdate, or NULL on error.
35
+ */
36
+ public static function fromJson($json) {
37
+ $instance = new self();
38
+ if ( !parent::createFromJson($json, $instance) ) {
39
+ return null;
40
+ }
41
+ return $instance;
42
+ }
43
+
44
+ /**
45
+ * Create a new instance by copying the necessary fields from another object.
46
+ *
47
+ * @param StdClass|Puc_v4p8_Theme_Update $object The source object.
48
+ * @return Puc_v4p8_Theme_Update The new copy.
49
+ */
50
+ public static function fromObject($object) {
51
+ $update = new self();
52
+ $update->copyFields($object, $update);
53
+ return $update;
54
+ }
55
+
56
+ /**
57
+ * Basic validation.
58
+ *
59
+ * @param StdClass $apiResponse
60
+ * @return bool|WP_Error
61
+ */
62
+ protected function validateMetadata($apiResponse) {
63
+ $required = array('version', 'details_url');
64
+ foreach($required as $key) {
65
+ if ( !isset($apiResponse->$key) || empty($apiResponse->$key) ) {
66
+ return new WP_Error(
67
+ 'tuc-invalid-metadata',
68
+ sprintf('The theme metadata is missing the required "%s" key.', $key)
69
+ );
70
+ }
71
+ }
72
+ return true;
73
+ }
74
+
75
+ protected function getFieldNames() {
76
+ return array_merge(parent::getFieldNames(), self::$extraFields);
77
+ }
78
+
79
+ protected function getPrefixedFilter($tag) {
80
+ return parent::getPrefixedFilter($tag) . '_theme';
81
+ }
82
+ }
83
+
84
+ endif;
lib/plugin-update-checker/Puc/v4p8/Theme/UpdateChecker.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p8_Theme_UpdateChecker', false) ):
4
+
5
+ class Puc_v4p8_Theme_UpdateChecker extends Puc_v4p8_UpdateChecker {
6
+ protected $filterSuffix = 'theme';
7
+ protected $updateTransient = 'update_themes';
8
+ protected $translationType = 'theme';
9
+
10
+ /**
11
+ * @var string Theme directory name.
12
+ */
13
+ protected $stylesheet;
14
+
15
+ public function __construct($metadataUrl, $stylesheet = null, $customSlug = null, $checkPeriod = 12, $optionName = '') {
16
+ if ( $stylesheet === null ) {
17
+ $stylesheet = get_stylesheet();
18
+ }
19
+ $this->stylesheet = $stylesheet;
20
+
21
+ parent::__construct(
22
+ $metadataUrl,
23
+ $stylesheet,
24
+ $customSlug ? $customSlug : $stylesheet,
25
+ $checkPeriod,
26
+ $optionName
27
+ );
28
+ }
29
+
30
+ /**
31
+ * For themes, the update array is indexed by theme directory name.
32
+ *
33
+ * @return string
34
+ */
35
+ protected function getUpdateListKey() {
36
+ return $this->directoryName;
37
+ }
38
+
39
+ /**
40
+ * Retrieve the latest update (if any) from the configured API endpoint.
41
+ *
42
+ * @return Puc_v4p8_Update|null An instance of Update, or NULL when no updates are available.
43
+ */
44
+ public function requestUpdate() {
45
+ list($themeUpdate, $result) = $this->requestMetadata('Puc_v4p8_Theme_Update', 'request_update');
46
+
47
+ if ( $themeUpdate !== null ) {
48
+ /** @var Puc_v4p8_Theme_Update $themeUpdate */
49
+ $themeUpdate->slug = $this->slug;
50
+ }
51
+
52
+ $themeUpdate = $this->filterUpdateResult($themeUpdate, $result);
53
+ return $themeUpdate;
54
+ }
55
+
56
+ public function userCanInstallUpdates() {
57
+ return current_user_can('update_themes');
58
+ }
59
+
60
+ /**
61
+ * Create an instance of the scheduler.
62
+ *
63
+ * @param int $checkPeriod
64
+ * @return Puc_v4p8_Scheduler
65
+ */
66
+ protected function createScheduler($checkPeriod) {
67
+ return new Puc_v4p8_Scheduler($this, $checkPeriod, array('load-themes.php'));
68
+ }
69
+
70
+ /**
71
+ * Is there an update being installed right now for this theme?
72
+ *
73
+ * @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
74
+ * @return bool
75
+ */
76
+ public function isBeingUpgraded($upgrader = null) {
77
+ return $this->upgraderStatus->isThemeBeingUpgraded($this->stylesheet, $upgrader);
78
+ }
79
+
80
+ protected function createDebugBarExtension() {
81
+ return new Puc_v4p8_DebugBar_Extension($this, 'Puc_v4p8_DebugBar_ThemePanel');
82
+ }
83
+
84
+ /**
85
+ * Register a callback for filtering query arguments.
86
+ *
87
+ * The callback function should take one argument - an associative array of query arguments.
88
+ * It should return a modified array of query arguments.
89
+ *
90
+ * @param callable $callback
91
+ * @return void
92
+ */
93
+ public function addQueryArgFilter($callback){
94
+ $this->addFilter('request_update_query_args', $callback);
95
+ }
96
+
97
+ /**
98
+ * Register a callback for filtering arguments passed to wp_remote_get().
99
+ *
100
+ * The callback function should take one argument - an associative array of arguments -
101
+ * and return a modified array or arguments. See the WP documentation on wp_remote_get()
102
+ * for details on what arguments are available and how they work.
103
+ *
104
+ * @uses add_filter() This method is a convenience wrapper for add_filter().
105
+ *
106
+ * @param callable $callback
107
+ * @return void
108
+ */
109
+ public function addHttpRequestArgFilter($callback) {
110
+ $this->addFilter('request_update_options', $callback);
111
+ }
112
+
113
+ /**
114
+ * Register a callback for filtering theme updates retrieved from the external API.
115
+ *
116
+ * The callback function should take two arguments. If the theme update was retrieved
117
+ * successfully, the first argument passed will be an instance of Theme_Update. Otherwise,
118
+ * it will be NULL. The second argument will be the corresponding return value of
119
+ * wp_remote_get (see WP docs for details).
120
+ *
121
+ * The callback function should return a new or modified instance of Theme_Update or NULL.
122
+ *
123
+ * @uses add_filter() This method is a convenience wrapper for add_filter().
124
+ *
125
+ * @param callable $callback
126
+ * @return void
127
+ */
128
+ public function addResultFilter($callback) {
129
+ $this->addFilter('request_update_result', $callback, 10, 2);
130
+ }
131
+
132
+ /**
133
+ * Create a package instance that represents this plugin or theme.
134
+ *
135
+ * @return Puc_v4p8_InstalledPackage
136
+ */
137
+ protected function createInstalledPackage() {
138
+ return new Puc_v4p8_Theme_Package($this->stylesheet, $this);
139
+ }
140
+ }
141
+
142
+ endif;
lib/plugin-update-checker/Puc/v4p8/Update.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p8_Update', false) ):
3
+
4
+ /**
5
+ * A simple container class for holding information about an available update.
6
+ *
7
+ * @author Janis Elsts
8
+ * @access public
9
+ */
10
+ abstract class Puc_v4p8_Update extends Puc_v4p8_Metadata {
11
+ public $slug;
12
+ public $version;
13
+ public $download_url;
14
+ public $translations = array();
15
+
16
+ /**
17
+ * @return string[]
18
+ */
19
+ protected function getFieldNames() {
20
+ return array('slug', 'version', 'download_url', 'translations');
21
+ }
22
+
23
+ public function toWpFormat() {
24
+ $update = new stdClass();
25
+
26
+ $update->slug = $this->slug;
27
+ $update->new_version = $this->version;
28
+ $update->package = $this->download_url;
29
+
30
+ return $update;
31
+ }
32
+ }
33
+
34
+ endif;
lib/plugin-update-checker/Puc/v4p8/UpdateChecker.php ADDED
@@ -0,0 +1,926 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p8_UpdateChecker', false) ):
4
+
5
+ abstract class Puc_v4p8_UpdateChecker {
6
+ protected $filterSuffix = '';
7
+ protected $updateTransient = '';
8
+ protected $translationType = ''; //"plugin" or "theme".
9
+
10
+ /**
11
+ * Set to TRUE to enable error reporting. Errors are raised using trigger_error()
12
+ * and should be logged to the standard PHP error log.
13
+ * @var bool
14
+ */
15
+ public $debugMode = null;
16
+
17
+ /**
18
+ * @var string Where to store the update info.
19
+ */
20
+ public $optionName = '';
21
+
22
+ /**
23
+ * @var string The URL of the metadata file.
24
+ */
25
+ public $metadataUrl = '';
26
+
27
+ /**
28
+ * @var string Plugin or theme directory name.
29
+ */
30
+ public $directoryName = '';
31
+
32
+ /**
33
+ * @var string The slug that will be used in update checker hooks and remote API requests.
34
+ * Usually matches the directory name unless the plugin/theme directory has been renamed.
35
+ */
36
+ public $slug = '';
37
+
38
+ /**
39
+ * @var Puc_v4p8_InstalledPackage
40
+ */
41
+ protected $package;
42
+
43
+ /**
44
+ * @var Puc_v4p8_Scheduler
45
+ */
46
+ public $scheduler;
47
+
48
+ /**
49
+ * @var Puc_v4p8_UpgraderStatus
50
+ */
51
+ protected $upgraderStatus;
52
+
53
+ /**
54
+ * @var Puc_v4p8_StateStore
55
+ */
56
+ protected $updateState;
57
+
58
+ /**
59
+ * @var array List of API errors triggered during the last checkForUpdates() call.
60
+ */
61
+ protected $lastRequestApiErrors = array();
62
+
63
+ public function __construct($metadataUrl, $directoryName, $slug = null, $checkPeriod = 12, $optionName = '') {
64
+ $this->debugMode = (bool)(constant('WP_DEBUG'));
65
+ $this->metadataUrl = $metadataUrl;
66
+ $this->directoryName = $directoryName;
67
+ $this->slug = !empty($slug) ? $slug : $this->directoryName;
68
+
69
+ $this->optionName = $optionName;
70
+ if ( empty($this->optionName) ) {
71
+ //BC: Initially the library only supported plugin updates and didn't use type prefixes
72
+ //in the option name. Lets use the same prefix-less name when possible.
73
+ if ( $this->filterSuffix === '' ) {
74
+ $this->optionName = 'external_updates-' . $this->slug;
75
+ } else {
76
+ $this->optionName = $this->getUniqueName('external_updates');
77
+ }
78
+ }
79
+
80
+ $this->package = $this->createInstalledPackage();
81
+ $this->scheduler = $this->createScheduler($checkPeriod);
82
+ $this->upgraderStatus = new Puc_v4p8_UpgraderStatus();
83
+ $this->updateState = new Puc_v4p8_StateStore($this->optionName);
84
+
85
+ if ( did_action('init') ) {
86
+ $this->loadTextDomain();
87
+ } else {
88
+ add_action('init', array($this, 'loadTextDomain'));
89
+ }
90
+
91
+ $this->installHooks();
92
+ }
93
+
94
+ /**
95
+ * @internal
96
+ */
97
+ public function loadTextDomain() {
98
+ //We're not using load_plugin_textdomain() or its siblings because figuring out where
99
+ //the library is located (plugin, mu-plugin, theme, custom wp-content paths) is messy.
100
+ $domain = 'plugin-update-checker';
101
+ $locale = apply_filters(
102
+ 'plugin_locale',
103
+ (is_admin() && function_exists('get_user_locale')) ? get_user_locale() : get_locale(),
104
+ $domain
105
+ );
106
+
107
+ $moFile = $domain . '-' . $locale . '.mo';
108
+ $path = realpath(dirname(__FILE__) . '/../../languages');
109
+
110
+ if ($path && file_exists($path)) {
111
+ load_textdomain($domain, $path . '/' . $moFile);
112
+ }
113
+ }
114
+
115
+ protected function installHooks() {
116
+ //Insert our update info into the update array maintained by WP.
117
+ add_filter('site_transient_' . $this->updateTransient, array($this,'injectUpdate'));
118
+
119
+ //Insert translation updates into the update list.
120
+ add_filter('site_transient_' . $this->updateTransient, array($this, 'injectTranslationUpdates'));
121
+
122
+ //Clear translation updates when WP clears the update cache.
123
+ //This needs to be done directly because the library doesn't actually remove obsolete plugin updates,
124
+ //it just hides them (see getUpdate()). We can't do that with translations - too much disk I/O.
125
+ add_action(
126
+ 'delete_site_transient_' . $this->updateTransient,
127
+ array($this, 'clearCachedTranslationUpdates')
128
+ );
129
+
130
+ //Rename the update directory to be the same as the existing directory.
131
+ if ( $this->directoryName !== '.' ) {
132
+ add_filter('upgrader_source_selection', array($this, 'fixDirectoryName'), 10, 3);
133
+ }
134
+
135
+ //Allow HTTP requests to the metadata URL even if it's on a local host.
136
+ add_filter('http_request_host_is_external', array($this, 'allowMetadataHost'), 10, 2);
137
+
138
+ //DebugBar integration.
139
+ if ( did_action('plugins_loaded') ) {
140
+ $this->maybeInitDebugBar();
141
+ } else {
142
+ add_action('plugins_loaded', array($this, 'maybeInitDebugBar'));
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Remove hooks that were added by this update checker instance.
148
+ */
149
+ protected function removeHooks() {
150
+ remove_filter('site_transient_' . $this->updateTransient, array($this,'injectUpdate'));
151
+ remove_filter('site_transient_' . $this->updateTransient, array($this, 'injectTranslationUpdates'));
152
+ remove_action(
153
+ 'delete_site_transient_' . $this->updateTransient,
154
+ array($this, 'clearCachedTranslationUpdates')
155
+ );
156
+
157
+ remove_filter('upgrader_source_selection', array($this, 'fixDirectoryName'), 10);
158
+ remove_filter('http_request_host_is_external', array($this, 'allowMetadataHost'), 10);
159
+ remove_action('plugins_loaded', array($this, 'maybeInitDebugBar'));
160
+
161
+ remove_action('init', array($this, 'loadTextDomain'));
162
+ }
163
+
164
+ /**
165
+ * Check if the current user has the required permissions to install updates.
166
+ *
167
+ * @return bool
168
+ */
169
+ abstract public function userCanInstallUpdates();
170
+
171
+ /**
172
+ * Explicitly allow HTTP requests to the metadata URL.
173
+ *
174
+ * WordPress has a security feature where the HTTP API will reject all requests that are sent to
175
+ * another site hosted on the same server as the current site (IP match), a local host, or a local
176
+ * IP, unless the host exactly matches the current site.
177
+ *
178
+ * This feature is opt-in (at least in WP 4.4). Apparently some people enable it.
179
+ *
180
+ * That can be a problem when you're developing your plugin and you decide to host the update information
181
+ * on the same server as your test site. Update requests will mysteriously fail.
182
+ *
183
+ * We fix that by adding an exception for the metadata host.
184
+ *
185
+ * @param bool $allow
186
+ * @param string $host
187
+ * @return bool
188
+ */
189
+ public function allowMetadataHost($allow, $host) {
190
+ static $metadataHost = 0; //Using 0 instead of NULL because parse_url can return NULL.
191
+ if ( $metadataHost === 0 ) {
192
+ $metadataHost = parse_url($this->metadataUrl, PHP_URL_HOST);
193
+ }
194
+
195
+ if ( is_string($metadataHost) && (strtolower($host) === strtolower($metadataHost)) ) {
196
+ return true;
197
+ }
198
+ return $allow;
199
+ }
200
+
201
+ /**
202
+ * Create a package instance that represents this plugin or theme.
203
+ *
204
+ * @return Puc_v4p8_InstalledPackage
205
+ */
206
+ abstract protected function createInstalledPackage();
207
+
208
+ /**
209
+ * @return Puc_v4p8_InstalledPackage
210
+ */
211
+ public function getInstalledPackage() {
212
+ return $this->package;
213
+ }
214
+
215
+ /**
216
+ * Create an instance of the scheduler.
217
+ *
218
+ * This is implemented as a method to make it possible for plugins to subclass the update checker
219
+ * and substitute their own scheduler.
220
+ *
221
+ * @param int $checkPeriod
222
+ * @return Puc_v4p8_Scheduler
223
+ */
224
+ abstract protected function createScheduler($checkPeriod);
225
+
226
+ /**
227
+ * Check for updates. The results are stored in the DB option specified in $optionName.
228
+ *
229
+ * @return Puc_v4p8_Update|null
230
+ */
231
+ public function checkForUpdates() {
232
+ $installedVersion = $this->getInstalledVersion();
233
+ //Fail silently if we can't find the plugin/theme or read its header.
234
+ if ( $installedVersion === null ) {
235
+ $this->triggerError(
236
+ sprintf('Skipping update check for %s - installed version unknown.', $this->slug),
237
+ E_USER_WARNING
238
+ );
239
+ return null;
240
+ }
241
+
242
+ //Start collecting API errors.
243
+ $this->lastRequestApiErrors = array();
244
+ add_action('puc_api_error', array($this, 'collectApiErrors'), 10, 4);
245
+
246
+ $state = $this->updateState;
247
+ $state->setLastCheckToNow()
248
+ ->setCheckedVersion($installedVersion)
249
+ ->save(); //Save before checking in case something goes wrong
250
+
251
+ $state->setUpdate($this->requestUpdate());
252
+ $state->save();
253
+
254
+ //Stop collecting API errors.
255
+ remove_action('puc_api_error', array($this, 'collectApiErrors'), 10);
256
+
257
+ return $this->getUpdate();
258
+ }
259
+
260
+ /**
261
+ * Load the update checker state from the DB.
262
+ *
263
+ * @return Puc_v4p8_StateStore
264
+ */
265
+ public function getUpdateState() {
266
+ return $this->updateState->lazyLoad();
267
+ }
268
+
269
+ /**
270
+ * Reset update checker state - i.e. last check time, cached update data and so on.
271
+ *
272
+ * Call this when your plugin is being uninstalled, or if you want to
273
+ * clear the update cache.
274
+ */
275
+ public function resetUpdateState() {
276
+ $this->updateState->delete();
277
+ }
278
+
279
+ /**
280
+ * Get the details of the currently available update, if any.
281
+ *
282
+ * If no updates are available, or if the last known update version is below or equal
283
+ * to the currently installed version, this method will return NULL.
284
+ *
285
+ * Uses cached update data. To retrieve update information straight from
286
+ * the metadata URL, call requestUpdate() instead.
287
+ *
288
+ * @return Puc_v4p8_Update|null
289
+ */
290
+ public function getUpdate() {
291
+ $update = $this->updateState->getUpdate();
292
+
293
+ //Is there an update available?
294
+ if ( isset($update) ) {
295
+ //Check if the update is actually newer than the currently installed version.
296
+ $installedVersion = $this->getInstalledVersion();
297
+ if ( ($installedVersion !== null) && version_compare($update->version, $installedVersion, '>') ){
298
+ return $update;
299
+ }
300
+ }
301
+ return null;
302
+ }
303
+
304
+ /**
305
+ * Retrieve the latest update (if any) from the configured API endpoint.
306
+ *
307
+ * Subclasses should run the update through filterUpdateResult before returning it.
308
+ *
309
+ * @return Puc_v4p8_Update An instance of Update, or NULL when no updates are available.
310
+ */
311
+ abstract public function requestUpdate();
312
+
313
+ /**
314
+ * Filter the result of a requestUpdate() call.
315
+ *
316
+ * @param Puc_v4p8_Update|null $update
317
+ * @param array|WP_Error|null $httpResult The value returned by wp_remote_get(), if any.
318
+ * @return Puc_v4p8_Update
319
+ */
320
+ protected function filterUpdateResult($update, $httpResult = null) {
321
+ //Let plugins/themes modify the update.
322
+ $update = apply_filters($this->getUniqueName('request_update_result'), $update, $httpResult);
323
+
324
+ $this->fixSupportedWordpressVersion($update);
325
+
326
+ if ( isset($update, $update->translations) ) {
327
+ //Keep only those translation updates that apply to this site.
328
+ $update->translations = $this->filterApplicableTranslations($update->translations);
329
+ }
330
+
331
+ return $update;
332
+ }
333
+
334
+ /**
335
+ * The "Tested up to" field in the plugin metadata is supposed to be in the form of "major.minor",
336
+ * while WordPress core's list_plugin_updates() expects the $update->tested field to be an exact
337
+ * version, e.g. "major.minor.patch", to say it's compatible. In other case it shows
338
+ * "Compatibility: Unknown".
339
+ * The function mimics how wordpress.org API crafts the "tested" field out of "Tested up to".
340
+ *
341
+ * @param Puc_v4p8_Metadata|null $update
342
+ */
343
+ protected function fixSupportedWordpressVersion(Puc_v4p8_Metadata $update = null) {
344
+ if ( !isset($update->tested) || !preg_match('/^\d++\.\d++$/', $update->tested) ) {
345
+ return;
346
+ }
347
+
348
+ $actualWpVersions = array();
349
+
350
+ $wpVersion = $GLOBALS['wp_version'];
351
+
352
+ if ( function_exists('get_preferred_from_update_core') ) {
353
+ $coreUpdate = get_preferred_from_update_core();
354
+ if ( isset($coreUpdate->current) && version_compare($coreUpdate->current, $wpVersion, '>') ) {
355
+ $actualWpVersions[] = $coreUpdate->current;
356
+ }
357
+ }
358
+
359
+ $actualWpVersions[] = $wpVersion;
360
+
361
+ $actualWpPatchNumber = "999";
362
+ foreach ($actualWpVersions as $version) {
363
+ if ( preg_match('/^(?P<majorMinor>\d++\.\d++)\.(?P<patch>\d++)/', $version, $versionParts) ) {
364
+ if ( $versionParts['majorMinor'] === $update->tested ) {
365
+ $actualWpPatchNumber = $versionParts['patch'];
366
+ break;
367
+ }
368
+ }
369
+ }
370
+
371
+ $update->tested .= '.' . $actualWpPatchNumber;
372
+ }
373
+
374
+ /**
375
+ * Get the currently installed version of the plugin or theme.
376
+ *
377
+ * @return string|null Version number.
378
+ */
379
+ public function getInstalledVersion() {
380
+ return $this->package->getInstalledVersion();
381
+ }
382
+
383
+ /**
384
+ * Get the full path of the plugin or theme directory.
385
+ *
386
+ * @return string
387
+ */
388
+ public function getAbsoluteDirectoryPath() {
389
+ return $this->package->getAbsoluteDirectoryPath();
390
+ }
391
+
392
+ /**
393
+ * Trigger a PHP error, but only when $debugMode is enabled.
394
+ *
395
+ * @param string $message
396
+ * @param int $errorType
397
+ */
398
+ public function triggerError($message, $errorType) {
399
+ if ( $this->isDebugModeEnabled() ) {
400
+ trigger_error($message, $errorType);
401
+ }
402
+ }
403
+
404
+ /**
405
+ * @return bool
406
+ */
407
+ protected function isDebugModeEnabled() {
408
+ if ( $this->debugMode === null ) {
409
+ $this->debugMode = (bool)(constant('WP_DEBUG'));
410
+ }
411
+ return $this->debugMode;
412
+ }
413
+
414
+ /**
415
+ * Get the full name of an update checker filter, action or DB entry.
416
+ *
417
+ * This method adds the "puc_" prefix and the "-$slug" suffix to the filter name.
418
+ * For example, "pre_inject_update" becomes "puc_pre_inject_update-plugin-slug".
419
+ *
420
+ * @param string $baseTag
421
+ * @return string
422
+ */
423
+ public function getUniqueName($baseTag) {
424
+ $name = 'puc_' . $baseTag;
425
+ if ( $this->filterSuffix !== '' ) {
426
+ $name .= '_' . $this->filterSuffix;
427
+ }
428
+ return $name . '-' . $this->slug;
429
+ }
430
+
431
+ /**
432
+ * Store API errors that are generated when checking for updates.
433
+ *
434
+ * @internal
435
+ * @param WP_Error $error
436
+ * @param array|null $httpResponse
437
+ * @param string|null $url
438
+ * @param string|null $slug
439
+ */
440
+ public function collectApiErrors($error, $httpResponse = null, $url = null, $slug = null) {
441
+ if ( isset($slug) && ($slug !== $this->slug) ) {
442
+ return;
443
+ }
444
+
445
+ $this->lastRequestApiErrors[] = array(
446
+ 'error' => $error,
447
+ 'httpResponse' => $httpResponse,
448
+ 'url' => $url,
449
+ );
450
+ }
451
+
452
+ /**
453
+ * @return array
454
+ */
455
+ public function getLastRequestApiErrors() {
456
+ return $this->lastRequestApiErrors;
457
+ }
458
+
459
+ /* -------------------------------------------------------------------
460
+ * PUC filters and filter utilities
461
+ * -------------------------------------------------------------------
462
+ */
463
+
464
+ /**
465
+ * Register a callback for one of the update checker filters.
466
+ *
467
+ * Identical to add_filter(), except it automatically adds the "puc_" prefix
468
+ * and the "-$slug" suffix to the filter name. For example, "request_info_result"
469
+ * becomes "puc_request_info_result-your_plugin_slug".
470
+ *
471
+ * @param string $tag
472
+ * @param callable $callback
473
+ * @param int $priority
474
+ * @param int $acceptedArgs
475
+ */
476
+ public function addFilter($tag, $callback, $priority = 10, $acceptedArgs = 1) {
477
+ add_filter($this->getUniqueName($tag), $callback, $priority, $acceptedArgs);
478
+ }
479
+
480
+ /* -------------------------------------------------------------------
481
+ * Inject updates
482
+ * -------------------------------------------------------------------
483
+ */
484
+
485
+ /**
486
+ * Insert the latest update (if any) into the update list maintained by WP.
487
+ *
488
+ * @param stdClass $updates Update list.
489
+ * @return stdClass Modified update list.
490
+ */
491
+ public function injectUpdate($updates) {
492
+ //Is there an update to insert?
493
+ $update = $this->getUpdate();
494
+
495
+ if ( !$this->shouldShowUpdates() ) {
496
+ $update = null;
497
+ }
498
+
499
+ if ( !empty($update) ) {
500
+ //Let plugins filter the update info before it's passed on to WordPress.
501
+ $update = apply_filters($this->getUniqueName('pre_inject_update'), $update);
502
+ $updates = $this->addUpdateToList($updates, $update->toWpFormat());
503
+ } else {
504
+ //Clean up any stale update info.
505
+ $updates = $this->removeUpdateFromList($updates);
506
+ }
507
+
508
+ return $updates;
509
+ }
510
+
511
+ /**
512
+ * @param stdClass|null $updates
513
+ * @param stdClass|array $updateToAdd
514
+ * @return stdClass
515
+ */
516
+ protected function addUpdateToList($updates, $updateToAdd) {
517
+ if ( !is_object($updates) ) {
518
+ $updates = new stdClass();
519
+ $updates->response = array();
520
+ }
521
+
522
+ $updates->response[$this->getUpdateListKey()] = $updateToAdd;
523
+ return $updates;
524
+ }
525
+
526
+ /**
527
+ * @param stdClass|null $updates
528
+ * @return stdClass|null
529
+ */
530
+ protected function removeUpdateFromList($updates) {
531
+ if ( isset($updates, $updates->response) ) {
532
+ unset($updates->response[$this->getUpdateListKey()]);
533
+ }
534
+ return $updates;
535
+ }
536
+
537
+ /**
538
+ * Get the key that will be used when adding updates to the update list that's maintained
539
+ * by the WordPress core. The list is always an associative array, but the key is different
540
+ * for plugins and themes.
541
+ *
542
+ * @return string
543
+ */
544
+ abstract protected function getUpdateListKey();
545
+
546
+ /**
547
+ * Should we show available updates?
548
+ *
549
+ * Usually the answer is "yes", but there are exceptions. For example, WordPress doesn't
550
+ * support automatic updates installation for mu-plugins, so PUC usually won't show update
551
+ * notifications in that case. See the plugin-specific subclass for details.
552
+ *
553
+ * Note: This method only applies to updates that are displayed (or not) in the WordPress
554
+ * admin. It doesn't affect APIs like requestUpdate and getUpdate.
555
+ *
556
+ * @return bool
557
+ */
558
+ protected function shouldShowUpdates() {
559
+ return true;
560
+ }
561
+
562
+ /* -------------------------------------------------------------------
563
+ * JSON-based update API
564
+ * -------------------------------------------------------------------
565
+ */
566
+
567
+ /**
568
+ * Retrieve plugin or theme metadata from the JSON document at $this->metadataUrl.
569
+ *
570
+ * @param string $metaClass Parse the JSON as an instance of this class. It must have a static fromJson method.
571
+ * @param string $filterRoot
572
+ * @param array $queryArgs Additional query arguments.
573
+ * @return array [Puc_v4p8_Metadata|null, array|WP_Error] A metadata instance and the value returned by wp_remote_get().
574
+ */
575
+ protected function requestMetadata($metaClass, $filterRoot, $queryArgs = array()) {
576
+ //Query args to append to the URL. Plugins can add their own by using a filter callback (see addQueryArgFilter()).
577
+ $queryArgs = array_merge(
578
+ array(
579
+ 'installed_version' => strval($this->getInstalledVersion()),
580
+ 'php' => phpversion(),
581
+ 'locale' => get_locale(),
582
+ ),
583
+ $queryArgs
584
+ );
585
+ $queryArgs = apply_filters($this->getUniqueName($filterRoot . '_query_args'), $queryArgs);
586
+
587
+ //Various options for the wp_remote_get() call. Plugins can filter these, too.
588
+ $options = array(
589
+ 'timeout' => 10, //seconds
590
+ 'headers' => array(
591
+ 'Accept' => 'application/json',
592
+ ),
593
+ );
594
+ $options = apply_filters($this->getUniqueName($filterRoot . '_options'), $options);
595
+
596
+ //The metadata file should be at 'http://your-api.com/url/here/$slug/info.json'
597
+ $url = $this->metadataUrl;
598
+ if ( !empty($queryArgs) ){
599
+ $url = add_query_arg($queryArgs, $url);
600
+ }
601
+
602
+ $result = wp_remote_get($url, $options);
603
+
604
+ $result = apply_filters($this->getUniqueName('request_metadata_http_result'), $result, $url, $options);
605
+
606
+ //Try to parse the response
607
+ $status = $this->validateApiResponse($result);
608
+ $metadata = null;
609
+ if ( !is_wp_error($status) ){
610
+ $metadata = call_user_func(array($metaClass, 'fromJson'), $result['body']);
611
+ } else {
612
+ do_action('puc_api_error', $status, $result, $url, $this->slug);
613
+ $this->triggerError(
614
+ sprintf('The URL %s does not point to a valid metadata file. ', $url)
615
+ . $status->get_error_message(),
616
+ E_USER_WARNING
617
+ );
618
+ }
619
+
620
+ return array($metadata, $result);
621
+ }
622
+
623
+ /**
624
+ * Check if $result is a successful update API response.
625
+ *
626
+ * @param array|WP_Error $result
627
+ * @return true|WP_Error
628
+ */
629
+ protected function validateApiResponse($result) {
630
+ if ( is_wp_error($result) ) { /** @var WP_Error $result */
631
+ return new WP_Error($result->get_error_code(), 'WP HTTP Error: ' . $result->get_error_message());
632
+ }
633
+
634
+ if ( !isset($result['response']['code']) ) {
635
+ return new WP_Error(
636
+ 'puc_no_response_code',
637
+ 'wp_remote_get() returned an unexpected result.'
638
+ );
639
+ }
640
+
641
+ if ( $result['response']['code'] !== 200 ) {
642
+ return new WP_Error(
643
+ 'puc_unexpected_response_code',
644
+ 'HTTP response code is ' . $result['response']['code'] . ' (expected: 200)'
645
+ );
646
+ }
647
+
648
+ if ( empty($result['body']) ) {
649
+ return new WP_Error('puc_empty_response', 'The metadata file appears to be empty.');
650
+ }
651
+
652
+ return true;
653
+ }
654
+
655
+ /* -------------------------------------------------------------------
656
+ * Language packs / Translation updates
657
+ * -------------------------------------------------------------------
658
+ */
659
+
660
+ /**
661
+ * Filter a list of translation updates and return a new list that contains only updates
662
+ * that apply to the current site.
663
+ *
664
+ * @param array $translations
665
+ * @return array
666
+ */
667
+ protected function filterApplicableTranslations($translations) {
668
+ $languages = array_flip(array_values(get_available_languages()));
669
+ $installedTranslations = $this->getInstalledTranslations();
670
+
671
+ $applicableTranslations = array();
672
+ foreach ($translations as $translation) {
673
+ //Does it match one of the available core languages?
674
+ $isApplicable = array_key_exists($translation->language, $languages);
675
+ //Is it more recent than an already-installed translation?
676
+ if ( isset($installedTranslations[$translation->language]) ) {
677
+ $updateTimestamp = strtotime($translation->updated);
678
+ $installedTimestamp = strtotime($installedTranslations[$translation->language]['PO-Revision-Date']);
679
+ $isApplicable = $updateTimestamp > $installedTimestamp;
680
+ }
681
+
682
+ if ( $isApplicable ) {
683
+ $applicableTranslations[] = $translation;
684
+ }
685
+ }
686
+
687
+ return $applicableTranslations;
688
+ }
689
+
690
+ /**
691
+ * Get a list of installed translations for this plugin or theme.
692
+ *
693
+ * @return array
694
+ */
695
+ protected function getInstalledTranslations() {
696
+ if ( !function_exists('wp_get_installed_translations') ) {
697
+ return array();
698
+ }
699
+ $installedTranslations = wp_get_installed_translations($this->translationType . 's');
700
+ if ( isset($installedTranslations[$this->directoryName]) ) {
701
+ $installedTranslations = $installedTranslations[$this->directoryName];
702
+ } else {
703
+ $installedTranslations = array();
704
+ }
705
+ return $installedTranslations;
706
+ }
707
+
708
+ /**
709
+ * Insert translation updates into the list maintained by WordPress.
710
+ *
711
+ * @param stdClass $updates
712
+ * @return stdClass
713
+ */
714
+ public function injectTranslationUpdates($updates) {
715
+ $translationUpdates = $this->getTranslationUpdates();
716
+ if ( empty($translationUpdates) ) {
717
+ return $updates;
718
+ }
719
+
720
+ //Being defensive.
721
+ if ( !is_object($updates) ) {
722
+ $updates = new stdClass();
723
+ }
724
+ if ( !isset($updates->translations) ) {
725
+ $updates->translations = array();
726
+ }
727
+
728
+ //In case there's a name collision with a plugin or theme hosted on wordpress.org,
729
+ //remove any preexisting updates that match our thing.
730
+ $updates->translations = array_values(array_filter(
731
+ $updates->translations,
732
+ array($this, 'isNotMyTranslation')
733
+ ));
734
+
735
+ //Add our updates to the list.
736
+ foreach($translationUpdates as $update) {
737
+ $convertedUpdate = array_merge(
738
+ array(
739
+ 'type' => $this->translationType,
740
+ 'slug' => $this->directoryName,
741
+ 'autoupdate' => 0,
742
+ //AFAICT, WordPress doesn't actually use the "version" field for anything.
743
+ //But lets make sure it's there, just in case.
744
+ 'version' => isset($update->version) ? $update->version : ('1.' . strtotime($update->updated)),
745
+ ),
746
+ (array)$update
747
+ );
748
+
749
+ $updates->translations[] = $convertedUpdate;
750
+ }
751
+
752
+ return $updates;
753
+ }
754
+
755
+ /**
756
+ * Get a list of available translation updates.
757
+ *
758
+ * This method will return an empty array if there are no updates.
759
+ * Uses cached update data.
760
+ *
761
+ * @return array
762
+ */
763
+ public function getTranslationUpdates() {
764
+ return $this->updateState->getTranslations();
765
+ }
766
+
767
+ /**
768
+ * Remove all cached translation updates.
769
+ *
770
+ * @see wp_clean_update_cache
771
+ */
772
+ public function clearCachedTranslationUpdates() {
773
+ $this->updateState->setTranslations(array());
774
+ }
775
+
776
+ /**
777
+ * Filter callback. Keeps only translations that *don't* match this plugin or theme.
778
+ *
779
+ * @param array $translation
780
+ * @return bool
781
+ */
782
+ protected function isNotMyTranslation($translation) {
783
+ $isMatch = isset($translation['type'], $translation['slug'])
784
+ && ($translation['type'] === $this->translationType)
785
+ && ($translation['slug'] === $this->directoryName);
786
+
787
+ return !$isMatch;
788
+ }
789
+
790
+ /* -------------------------------------------------------------------
791
+ * Fix directory name when installing updates
792
+ * -------------------------------------------------------------------
793
+ */
794
+
795
+ /**
796
+ * Rename the update directory to match the existing plugin/theme directory.
797
+ *
798
+ * When WordPress installs a plugin or theme update, it assumes that the ZIP file will contain
799
+ * exactly one directory, and that the directory name will be the same as the directory where
800
+ * the plugin or theme is currently installed.
801
+ *
802
+ * GitHub and other repositories provide ZIP downloads, but they often use directory names like
803
+ * "project-branch" or "project-tag-hash". We need to change the name to the actual plugin folder.
804
+ *
805
+ * This is a hook callback. Don't call it from a plugin.
806
+ *
807
+ * @access protected
808
+ *
809
+ * @param string $source The directory to copy to /wp-content/plugins or /wp-content/themes. Usually a subdirectory of $remoteSource.
810
+ * @param string $remoteSource WordPress has extracted the update to this directory.
811
+ * @param WP_Upgrader $upgrader
812
+ * @return string|WP_Error
813
+ */
814
+ public function fixDirectoryName($source, $remoteSource, $upgrader) {
815
+ global $wp_filesystem;
816
+ /** @var WP_Filesystem_Base $wp_filesystem */
817
+
818
+ //Basic sanity checks.
819
+ if ( !isset($source, $remoteSource, $upgrader, $upgrader->skin, $wp_filesystem) ) {
820
+ return $source;
821
+ }
822
+
823
+ //If WordPress is upgrading anything other than our plugin/theme, leave the directory name unchanged.
824
+ if ( !$this->isBeingUpgraded($upgrader) ) {
825
+ return $source;
826
+ }
827
+
828
+ //Rename the source to match the existing directory.
829
+ $correctedSource = trailingslashit($remoteSource) . $this->directoryName . '/';
830
+ if ( $source !== $correctedSource ) {
831
+ //The update archive should contain a single directory that contains the rest of plugin/theme files.
832
+ //Otherwise, WordPress will try to copy the entire working directory ($source == $remoteSource).
833
+ //We can't rename $remoteSource because that would break WordPress code that cleans up temporary files
834
+ //after update.
835
+ if ( $this->isBadDirectoryStructure($remoteSource) ) {
836
+ return new WP_Error(
837
+ 'puc-incorrect-directory-structure',
838
+ sprintf(
839
+ 'The directory structure of the update is incorrect. All files should be inside ' .
840
+ 'a directory named <span class="code">%s</span>, not at the root of the ZIP archive.',
841
+ htmlentities($this->slug)
842
+ )
843
+ );
844
+ }
845
+
846
+ /** @var WP_Upgrader_Skin $upgrader ->skin */
847
+ $upgrader->skin->feedback(sprintf(
848
+ 'Renaming %s to %s&#8230;',
849
+ '<span class="code">' . basename($source) . '</span>',
850
+ '<span class="code">' . $this->directoryName . '</span>'
851
+ ));
852
+
853
+ if ( $wp_filesystem->move($source, $correctedSource, true) ) {
854
+ $upgrader->skin->feedback('Directory successfully renamed.');
855
+ return $correctedSource;
856
+ } else {
857
+ return new WP_Error(
858
+ 'puc-rename-failed',
859
+ 'Unable to rename the update to match the existing directory.'
860
+ );
861
+ }
862
+ }
863
+
864
+ return $source;
865
+ }
866
+
867
+ /**
868
+ * Is there an update being installed right now, for this plugin or theme?
869
+ *
870
+ * @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
871
+ * @return bool
872
+ */
873
+ abstract public function isBeingUpgraded($upgrader = null);
874
+
875
+ /**
876
+ * Check for incorrect update directory structure. An update must contain a single directory,
877
+ * all other files should be inside that directory.
878
+ *
879
+ * @param string $remoteSource Directory path.
880
+ * @return bool
881
+ */
882
+ protected function isBadDirectoryStructure($remoteSource) {
883
+ global $wp_filesystem;
884
+ /** @var WP_Filesystem_Base $wp_filesystem */
885
+
886
+ $sourceFiles = $wp_filesystem->dirlist($remoteSource);
887
+ if ( is_array($sourceFiles) ) {
888
+ $sourceFiles = array_keys($sourceFiles);
889
+ $firstFilePath = trailingslashit($remoteSource) . $sourceFiles[0];
890
+ return (count($sourceFiles) > 1) || (!$wp_filesystem->is_dir($firstFilePath));
891
+ }
892
+
893
+ //Assume it's fine.
894
+ return false;
895
+ }
896
+
897
+ /* -------------------------------------------------------------------
898
+ * DebugBar integration
899
+ * -------------------------------------------------------------------
900
+ */
901
+
902
+ /**
903
+ * Initialize the update checker Debug Bar plugin/add-on thingy.
904
+ */
905
+ public function maybeInitDebugBar() {
906
+ if ( class_exists('Debug_Bar', false) && file_exists(dirname(__FILE__) . '/DebugBar') ) {
907
+ $this->createDebugBarExtension();
908
+ }
909
+ }
910
+
911
+ protected function createDebugBarExtension() {
912
+ return new Puc_v4p8_DebugBar_Extension($this);
913
+ }
914
+
915
+ /**
916
+ * Display additional configuration details in the Debug Bar panel.
917
+ *
918
+ * @param Puc_v4p8_DebugBar_Panel $panel
919
+ */
920
+ public function onDisplayConfiguration($panel) {
921
+ //Do nothing. Subclasses can use this to add additional info to the panel.
922
+ }
923
+
924
+ }
925
+
926
+ endif;
lib/plugin-update-checker/Puc/v4p8/UpgraderStatus.php ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p8_UpgraderStatus', false) ):
3
+
4
+ /**
5
+ * A utility class that helps figure out which plugin or theme WordPress is upgrading.
6
+ *
7
+ * It may seem strange to have a separate class just for that, but the task is surprisingly complicated.
8
+ * Core classes like Plugin_Upgrader don't expose the plugin file name during an in-progress update (AFAICT).
9
+ * This class uses a few workarounds and heuristics to get the file name.
10
+ */
11
+ class Puc_v4p8_UpgraderStatus {
12
+ private $currentType = null; //"plugin" or "theme".
13
+ private $currentId = null; //Plugin basename or theme directory name.
14
+
15
+ public function __construct() {
16
+ //Keep track of which plugin/theme WordPress is currently upgrading.
17
+ add_filter('upgrader_pre_install', array($this, 'setUpgradedThing'), 10, 2);
18
+ add_filter('upgrader_package_options', array($this, 'setUpgradedPluginFromOptions'), 10, 1);
19
+ add_filter('upgrader_post_install', array($this, 'clearUpgradedThing'), 10, 1);
20
+ add_action('upgrader_process_complete', array($this, 'clearUpgradedThing'), 10, 1);
21
+ }
22
+
23
+ /**
24
+ * Is there and update being installed RIGHT NOW, for a specific plugin?
25
+ *
26
+ * Caution: This method is unreliable. WordPress doesn't make it easy to figure out what it is upgrading,
27
+ * and upgrader implementations are liable to change without notice.
28
+ *
29
+ * @param string $pluginFile The plugin to check.
30
+ * @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
31
+ * @return bool True if the plugin identified by $pluginFile is being upgraded.
32
+ */
33
+ public function isPluginBeingUpgraded($pluginFile, $upgrader = null) {
34
+ return $this->isBeingUpgraded('plugin', $pluginFile, $upgrader);
35
+ }
36
+
37
+ /**
38
+ * Is there an update being installed for a specific theme?
39
+ *
40
+ * @param string $stylesheet Theme directory name.
41
+ * @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
42
+ * @return bool
43
+ */
44
+ public function isThemeBeingUpgraded($stylesheet, $upgrader = null) {
45
+ return $this->isBeingUpgraded('theme', $stylesheet, $upgrader);
46
+ }
47
+
48
+ /**
49
+ * Check if a specific theme or plugin is being upgraded.
50
+ *
51
+ * @param string $type
52
+ * @param string $id
53
+ * @param Plugin_Upgrader|WP_Upgrader|null $upgrader
54
+ * @return bool
55
+ */
56
+ protected function isBeingUpgraded($type, $id, $upgrader = null) {
57
+ if ( isset($upgrader) ) {
58
+ list($currentType, $currentId) = $this->getThingBeingUpgradedBy($upgrader);
59
+ if ( $currentType !== null ) {
60
+ $this->currentType = $currentType;
61
+ $this->currentId = $currentId;
62
+ }
63
+ }
64
+ return ($this->currentType === $type) && ($this->currentId === $id);
65
+ }
66
+
67
+ /**
68
+ * Figure out which theme or plugin is being upgraded by a WP_Upgrader instance.
69
+ *
70
+ * Returns an array with two items. The first item is the type of the thing that's being
71
+ * upgraded: "plugin" or "theme". The second item is either the plugin basename or
72
+ * the theme directory name. If we can't determine what the upgrader is doing, both items
73
+ * will be NULL.
74
+ *
75
+ * Examples:
76
+ * ['plugin', 'plugin-dir-name/plugin.php']
77
+ * ['theme', 'theme-dir-name']
78
+ *
79
+ * @param Plugin_Upgrader|WP_Upgrader $upgrader
80
+ * @return array
81
+ */
82
+ private function getThingBeingUpgradedBy($upgrader) {
83
+ if ( !isset($upgrader, $upgrader->skin) ) {
84
+ return array(null, null);
85
+ }
86
+
87
+ //Figure out which plugin or theme is being upgraded.
88
+ $pluginFile = null;
89
+ $themeDirectoryName = null;
90
+
91
+ $skin = $upgrader->skin;
92
+ if ( isset($skin->theme_info) && ($skin->theme_info instanceof WP_Theme) ) {
93
+ $themeDirectoryName = $skin->theme_info->get_stylesheet();
94
+ } elseif ( $skin instanceof Plugin_Upgrader_Skin ) {
95
+ if ( isset($skin->plugin) && is_string($skin->plugin) && ($skin->plugin !== '') ) {
96
+ $pluginFile = $skin->plugin;
97
+ }
98
+ } elseif ( $skin instanceof Theme_Upgrader_Skin ) {
99
+ if ( isset($skin->theme) && is_string($skin->theme) && ($skin->theme !== '') ) {
100
+ $themeDirectoryName = $skin->theme;
101
+ }
102
+ } elseif ( isset($skin->plugin_info) && is_array($skin->plugin_info) ) {
103
+ //This case is tricky because Bulk_Plugin_Upgrader_Skin (etc) doesn't actually store the plugin
104
+ //filename anywhere. Instead, it has the plugin headers in $plugin_info. So the best we can
105
+ //do is compare those headers to the headers of installed plugins.
106
+ $pluginFile = $this->identifyPluginByHeaders($skin->plugin_info);
107
+ }
108
+
109
+ if ( $pluginFile !== null ) {
110
+ return array('plugin', $pluginFile);
111
+ } elseif ( $themeDirectoryName !== null ) {
112
+ return array('theme', $themeDirectoryName);
113
+ }
114
+ return array(null, null);
115
+ }
116
+
117
+ /**
118
+ * Identify an installed plugin based on its headers.
119
+ *
120
+ * @param array $searchHeaders The plugin file header to look for.
121
+ * @return string|null Plugin basename ("foo/bar.php"), or NULL if we can't identify the plugin.
122
+ */
123
+ private function identifyPluginByHeaders($searchHeaders) {
124
+ if ( !function_exists('get_plugins') ){
125
+ /** @noinspection PhpIncludeInspection */
126
+ require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
127
+ }
128
+
129
+ $installedPlugins = get_plugins();
130
+ $matches = array();
131
+ foreach($installedPlugins as $pluginBasename => $headers) {
132
+ $diff1 = array_diff_assoc($headers, $searchHeaders);
133
+ $diff2 = array_diff_assoc($searchHeaders, $headers);
134
+ if ( empty($diff1) && empty($diff2) ) {
135
+ $matches[] = $pluginBasename;
136
+ }
137
+ }
138
+
139
+ //It's possible (though very unlikely) that there could be two plugins with identical
140
+ //headers. In that case, we can't unambiguously identify the plugin that's being upgraded.
141
+ if ( count($matches) !== 1 ) {
142
+ return null;
143
+ }
144
+
145
+ return reset($matches);
146
+ }
147
+
148
+ /**
149
+ * @access private
150
+ *
151
+ * @param mixed $input
152
+ * @param array $hookExtra
153
+ * @return mixed Returns $input unaltered.
154
+ */
155
+ public function setUpgradedThing($input, $hookExtra) {
156
+ if ( !empty($hookExtra['plugin']) && is_string($hookExtra['plugin']) ) {
157
+ $this->currentId = $hookExtra['plugin'];
158
+ $this->currentType = 'plugin';
159
+ } elseif ( !empty($hookExtra['theme']) && is_string($hookExtra['theme']) ) {
160
+ $this->currentId = $hookExtra['theme'];
161
+ $this->currentType = 'theme';
162
+ } else {
163
+ $this->currentType = null;
164
+ $this->currentId = null;
165
+ }
166
+ return $input;
167
+ }
168
+
169
+ /**
170
+ * @access private
171
+ *
172
+ * @param array $options
173
+ * @return array
174
+ */
175
+ public function setUpgradedPluginFromOptions($options) {
176
+ if ( isset($options['hook_extra']['plugin']) && is_string($options['hook_extra']['plugin']) ) {
177
+ $this->currentType = 'plugin';
178
+ $this->currentId = $options['hook_extra']['plugin'];
179
+ } else {
180
+ $this->currentType = null;
181
+ $this->currentId = null;
182
+ }
183
+ return $options;
184
+ }
185
+
186
+ /**
187
+ * @access private
188
+ *
189
+ * @param mixed $input
190
+ * @return mixed Returns $input unaltered.
191
+ */
192
+ public function clearUpgradedThing($input = null) {
193
+ $this->currentId = null;
194
+ $this->currentType = null;
195
+ return $input;
196
+ }
197
+ }
198
+
199
+ endif;
lib/plugin-update-checker/Puc/v4p8/Utils.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p8_Utils', false) ):
4
+
5
+ class Puc_v4p8_Utils {
6
+ /**
7
+ * Get a value from a nested array or object based on a path.
8
+ *
9
+ * @param array|object|null $collection Get an entry from this array.
10
+ * @param array|string $path A list of array keys in hierarchy order, or a string path like "foo.bar.baz".
11
+ * @param mixed $default The value to return if the specified path is not found.
12
+ * @param string $separator Path element separator. Only applies to string paths.
13
+ * @return mixed
14
+ */
15
+ public static function get($collection, $path, $default = null, $separator = '.') {
16
+ if ( is_string($path) ) {
17
+ $path = explode($separator, $path);
18
+ }
19
+
20
+ //Follow the $path into $input as far as possible.
21
+ $currentValue = $collection;
22
+ foreach ($path as $node) {
23
+ if ( is_array($currentValue) && isset($currentValue[$node]) ) {
24
+ $currentValue = $currentValue[$node];
25
+ } else if ( is_object($currentValue) && isset($currentValue->$node) ) {
26
+ $currentValue = $currentValue->$node;
27
+ } else {
28
+ return $default;
29
+ }
30
+ }
31
+
32
+ return $currentValue;
33
+ }
34
+
35
+ /**
36
+ * Get the first array element that is not empty.
37
+ *
38
+ * @param array $values
39
+ * @param mixed|null $default Returns this value if there are no non-empty elements.
40
+ * @return mixed|null
41
+ */
42
+ public static function findNotEmpty($values, $default = null) {
43
+ if ( empty($values) ) {
44
+ return $default;
45
+ }
46
+
47
+ foreach ($values as $value) {
48
+ if ( !empty($value) ) {
49
+ return $value;
50
+ }
51
+ }
52
+
53
+ return $default;
54
+ }
55
+
56
+ /**
57
+ * Check if the input string starts with the specified prefix.
58
+ *
59
+ * @param string $input
60
+ * @param string $prefix
61
+ * @return bool
62
+ */
63
+ public static function startsWith($input, $prefix) {
64
+ $length = strlen($prefix);
65
+ return (substr($input, 0, $length) === $prefix);
66
+ }
67
+ }
68
+
69
+ endif;
lib/plugin-update-checker/Puc/v4p8/Vcs/Api.php ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p8_Vcs_Api') ):
3
+
4
+ abstract class Puc_v4p8_Vcs_Api {
5
+ protected $tagNameProperty = 'name';
6
+ protected $slug = '';
7
+
8
+ /**
9
+ * @var string
10
+ */
11
+ protected $repositoryUrl = '';
12
+
13
+ /**
14
+ * @var mixed Authentication details for private repositories. Format depends on service.
15
+ */
16
+ protected $credentials = null;
17
+
18
+ /**
19
+ * @var string The filter tag that's used to filter options passed to wp_remote_get.
20
+ * For example, "puc_request_info_options-slug" or "puc_request_update_options_theme-slug".
21
+ */
22
+ protected $httpFilterName = '';
23
+
24
+ /**
25
+ * @var string|null
26
+ */
27
+ protected $localDirectory = null;
28
+
29
+ /**
30
+ * Puc_v4p8_Vcs_Api constructor.
31
+ *
32
+ * @param string $repositoryUrl
33
+ * @param array|string|null $credentials
34
+ */
35
+ public function __construct($repositoryUrl, $credentials = null) {
36
+ $this->repositoryUrl = $repositoryUrl;
37
+ $this->setAuthentication($credentials);
38
+ }
39
+
40
+ /**
41
+ * @return string
42
+ */
43
+ public function getRepositoryUrl() {
44
+ return $this->repositoryUrl;
45
+ }
46
+
47
+ /**
48
+ * Figure out which reference (i.e tag or branch) contains the latest version.
49
+ *
50
+ * @param string $configBranch Start looking in this branch.
51
+ * @return null|Puc_v4p8_Vcs_Reference
52
+ */
53
+ abstract public function chooseReference($configBranch);
54
+
55
+ /**
56
+ * Get the readme.txt file from the remote repository and parse it
57
+ * according to the plugin readme standard.
58
+ *
59
+ * @param string $ref Tag or branch name.
60
+ * @return array Parsed readme.
61
+ */
62
+ public function getRemoteReadme($ref = 'master') {
63
+ $fileContents = $this->getRemoteFile($this->getLocalReadmeName(), $ref);
64
+ if ( empty($fileContents) ) {
65
+ return array();
66
+ }
67
+
68
+ $parser = new PucReadmeParser();
69
+ return $parser->parse_readme_contents($fileContents);
70
+ }
71
+
72
+ /**
73
+ * Get the case-sensitive name of the local readme.txt file.
74
+ *
75
+ * In most cases it should just be called "readme.txt", but some plugins call it "README.txt",
76
+ * "README.TXT", or even "Readme.txt". Most VCS are case-sensitive so we need to know the correct
77
+ * capitalization.
78
+ *
79
+ * Defaults to "readme.txt" (all lowercase).
80
+ *
81
+ * @return string
82
+ */
83
+ public function getLocalReadmeName() {
84
+ static $fileName = null;
85
+ if ( $fileName !== null ) {
86
+ return $fileName;
87
+ }
88
+
89
+ $fileName = 'readme.txt';
90
+ if ( isset($this->localDirectory) ) {
91
+ $files = scandir($this->localDirectory);
92
+ if ( !empty($files) ) {
93
+ foreach ($files as $possibleFileName) {
94
+ if ( strcasecmp($possibleFileName, 'readme.txt') === 0 ) {
95
+ $fileName = $possibleFileName;
96
+ break;
97
+ }
98
+ }
99
+ }
100
+ }
101
+ return $fileName;
102
+ }
103
+
104
+ /**
105
+ * Get a branch.
106
+ *
107
+ * @param string $branchName
108
+ * @return Puc_v4p8_Vcs_Reference|null
109
+ */
110
+ abstract public function getBranch($branchName);
111
+
112
+ /**
113
+ * Get a specific tag.
114
+ *
115
+ * @param string $tagName
116
+ * @return Puc_v4p8_Vcs_Reference|null
117
+ */
118
+ abstract public function getTag($tagName);
119
+
120
+ /**
121
+ * Get the tag that looks like the highest version number.
122
+ * (Implementations should skip pre-release versions if possible.)
123
+ *
124
+ * @return Puc_v4p8_Vcs_Reference|null
125
+ */
126
+ abstract public function getLatestTag();
127
+
128
+ /**
129
+ * Check if a tag name string looks like a version number.
130
+ *
131
+ * @param string $name
132
+ * @return bool
133
+ */
134
+ protected function looksLikeVersion($name) {
135
+ //Tag names may be prefixed with "v", e.g. "v1.2.3".
136
+ $name = ltrim($name, 'v');
137
+
138
+ //The version string must start with a number.
139
+ if ( !is_numeric(substr($name, 0, 1)) ) {
140
+ return false;
141
+ }
142
+
143
+ //The goal is to accept any SemVer-compatible or "PHP-standardized" version number.
144
+ return (preg_match('@^(\d{1,5}?)(\.\d{1,10}?){0,4}?($|[abrdp+_\-]|\s)@i', $name) === 1);
145
+ }
146
+
147
+ /**
148
+ * Check if a tag appears to be named like a version number.
149
+ *
150
+ * @param stdClass $tag
151
+ * @return bool
152
+ */
153
+ protected function isVersionTag($tag) {
154
+ $property = $this->tagNameProperty;
155
+ return isset($tag->$property) && $this->looksLikeVersion($tag->$property);
156
+ }
157
+
158
+ /**
159
+ * Sort a list of tags as if they were version numbers.
160
+ * Tags that don't look like version number will be removed.
161
+ *
162
+ * @param stdClass[] $tags Array of tag objects.
163
+ * @return stdClass[] Filtered array of tags sorted in descending order.
164
+ */
165
+ protected function sortTagsByVersion($tags) {
166
+ //Keep only those tags that look like version numbers.
167
+ $versionTags = array_filter($tags, array($this, 'isVersionTag'));
168
+ //Sort them in descending order.
169
+ usort($versionTags, array($this, 'compareTagNames'));
170
+
171
+ return $versionTags;
172
+ }
173
+
174
+ /**
175
+ * Compare two tags as if they were version number.
176
+ *
177
+ * @param stdClass $tag1 Tag object.
178
+ * @param stdClass $tag2 Another tag object.
179
+ * @return int
180
+ */
181
+ protected function compareTagNames($tag1, $tag2) {
182
+ $property = $this->tagNameProperty;
183
+ if ( !isset($tag1->$property) ) {
184
+ return 1;
185
+ }
186
+ if ( !isset($tag2->$property) ) {
187
+ return -1;
188
+ }
189
+ return -version_compare(ltrim($tag1->$property, 'v'), ltrim($tag2->$property, 'v'));
190
+ }
191
+
192
+ /**
193
+ * Get the contents of a file from a specific branch or tag.
194
+ *
195
+ * @param string $path File name.
196
+ * @param string $ref
197
+ * @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error.
198
+ */
199
+ abstract public function getRemoteFile($path, $ref = 'master');
200
+
201
+ /**
202
+ * Get the timestamp of the latest commit that changed the specified branch or tag.
203
+ *
204
+ * @param string $ref Reference name (e.g. branch or tag).
205
+ * @return string|null
206
+ */
207
+ abstract public function getLatestCommitTime($ref);
208
+
209
+ /**
210
+ * Get the contents of the changelog file from the repository.
211
+ *
212
+ * @param string $ref
213
+ * @param string $localDirectory Full path to the local plugin or theme directory.
214
+ * @return null|string The HTML contents of the changelog.
215
+ */
216
+ public function getRemoteChangelog($ref, $localDirectory) {
217
+ $filename = $this->findChangelogName($localDirectory);
218
+ if ( empty($filename) ) {
219
+ return null;
220
+ }
221
+
222
+ $changelog = $this->getRemoteFile($filename, $ref);
223
+ if ( $changelog === null ) {
224
+ return null;
225
+ }
226
+
227
+ /** @noinspection PhpUndefinedClassInspection */
228
+ return Parsedown::instance()->text($changelog);
229
+ }
230
+
231
+ /**
232
+ * Guess the name of the changelog file.
233
+ *
234
+ * @param string $directory
235
+ * @return string|null
236
+ */
237
+ protected function findChangelogName($directory = null) {
238
+ if ( !isset($directory) ) {
239
+ $directory = $this->localDirectory;
240
+ }
241
+ if ( empty($directory) || !is_dir($directory) || ($directory === '.') ) {
242
+ return null;
243
+ }
244
+
245
+ $possibleNames = array('CHANGES.md', 'CHANGELOG.md', 'changes.md', 'changelog.md');
246
+ $files = scandir($directory);
247
+ $foundNames = array_intersect($possibleNames, $files);
248
+
249
+ if ( !empty($foundNames) ) {
250
+ return reset($foundNames);
251
+ }
252
+ return null;
253
+ }
254
+
255
+ /**
256
+ * Set authentication credentials.
257
+ *
258
+ * @param $credentials
259
+ */
260
+ public function setAuthentication($credentials) {
261
+ $this->credentials = $credentials;
262
+ }
263
+
264
+ public function isAuthenticationEnabled() {
265
+ return !empty($this->credentials);
266
+ }
267
+
268
+ /**
269
+ * @param string $url
270
+ * @return string
271
+ */
272
+ public function signDownloadUrl($url) {
273
+ return $url;
274
+ }
275
+
276
+ /**
277
+ * @param string $filterName
278
+ */
279
+ public function setHttpFilterName($filterName) {
280
+ $this->httpFilterName = $filterName;
281
+ }
282
+
283
+ /**
284
+ * @param string $directory
285
+ */
286
+ public function setLocalDirectory($directory) {
287
+ if ( empty($directory) || !is_dir($directory) || ($directory === '.') ) {
288
+ $this->localDirectory = null;
289
+ } else {
290
+ $this->localDirectory = $directory;
291
+ }
292
+ }
293
+
294
+ /**
295
+ * @param string $slug
296
+ */
297
+ public function setSlug($slug) {
298
+ $this->slug = $slug;
299
+ }
300
+ }
301
+
302
+ endif;
lib/plugin-update-checker/Puc/v4p8/Vcs/BaseChecker.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !interface_exists('Puc_v4p8_Vcs_BaseChecker', false) ):
3
+
4
+ interface Puc_v4p8_Vcs_BaseChecker {
5
+ /**
6
+ * Set the repository branch to use for updates. Defaults to 'master'.
7
+ *
8
+ * @param string $branch
9
+ * @return $this
10
+ */
11
+ public function setBranch($branch);
12
+
13
+ /**
14
+ * Set authentication credentials.
15
+ *
16
+ * @param array|string $credentials
17
+ * @return $this
18
+ */
19
+ public function setAuthentication($credentials);
20
+
21
+ /**
22
+ * @return Puc_v4p8_Vcs_Api
23
+ */
24
+ public function getVcsApi();
25
+ }
26
+
27
+ endif;
lib/plugin-update-checker/Puc/v4p8/Vcs/BitBucketApi.php ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p8_Vcs_BitBucketApi', false) ):
3
+
4
+ class Puc_v4p8_Vcs_BitBucketApi extends Puc_v4p8_Vcs_Api {
5
+ /**
6
+ * @var Puc_v4p8_OAuthSignature
7
+ */
8
+ private $oauth = null;
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ private $username;
14
+
15
+ /**
16
+ * @var string
17
+ */
18
+ private $repository;
19
+
20
+ public function __construct($repositoryUrl, $credentials = array()) {
21
+ $path = parse_url($repositoryUrl, PHP_URL_PATH);
22
+ if ( preg_match('@^/?(?P<username>[^/]+?)/(?P<repository>[^/#?&]+?)/?$@', $path, $matches) ) {
23
+ $this->username = $matches['username'];
24
+ $this->repository = $matches['repository'];
25
+ } else {
26
+ throw new InvalidArgumentException('Invalid BitBucket repository URL: "' . $repositoryUrl . '"');
27
+ }
28
+
29
+ parent::__construct($repositoryUrl, $credentials);
30
+ }
31
+
32
+ /**
33
+ * Figure out which reference (i.e tag or branch) contains the latest version.
34
+ *
35
+ * @param string $configBranch Start looking in this branch.
36
+ * @return null|Puc_v4p8_Vcs_Reference
37
+ */
38
+ public function chooseReference($configBranch) {
39
+ $updateSource = null;
40
+
41
+ //Check if there's a "Stable tag: 1.2.3" header that points to a valid tag.
42
+ $updateSource = $this->getStableTag($configBranch);
43
+
44
+ //Look for version-like tags.
45
+ if ( !$updateSource && ($configBranch === 'master') ) {
46
+ $updateSource = $this->getLatestTag();
47
+ }
48
+ //If all else fails, use the specified branch itself.
49
+ if ( !$updateSource ) {
50
+ $updateSource = $this->getBranch($configBranch);
51
+ }
52
+
53
+ return $updateSource;
54
+ }
55
+
56
+ public function getBranch($branchName) {
57
+ $branch = $this->api('/refs/branches/' . $branchName);
58
+ if ( is_wp_error($branch) || empty($branch) ) {
59
+ return null;
60
+ }
61
+
62
+ return new Puc_v4p8_Vcs_Reference(array(
63
+ 'name' => $branch->name,
64
+ 'updated' => $branch->target->date,
65
+ 'downloadUrl' => $this->getDownloadUrl($branch->name),
66
+ ));
67
+ }
68
+
69
+ /**
70
+ * Get a specific tag.
71
+ *
72
+ * @param string $tagName
73
+ * @return Puc_v4p8_Vcs_Reference|null
74
+ */
75
+ public function getTag($tagName) {
76
+ $tag = $this->api('/refs/tags/' . $tagName);
77
+ if ( is_wp_error($tag) || empty($tag) ) {
78
+ return null;
79
+ }
80
+
81
+ return new Puc_v4p8_Vcs_Reference(array(
82
+ 'name' => $tag->name,
83
+ 'version' => ltrim($tag->name, 'v'),
84
+ 'updated' => $tag->target->date,
85
+ 'downloadUrl' => $this->getDownloadUrl($tag->name),
86
+ ));
87
+ }
88
+
89
+ /**
90
+ * Get the tag that looks like the highest version number.
91
+ *
92
+ * @return Puc_v4p8_Vcs_Reference|null
93
+ */
94
+ public function getLatestTag() {
95
+ $tags = $this->api('/refs/tags?sort=-target.date');
96
+ if ( !isset($tags, $tags->values) || !is_array($tags->values) ) {
97
+ return null;
98
+ }
99
+
100
+ //Filter and sort the list of tags.
101
+ $versionTags = $this->sortTagsByVersion($tags->values);
102
+
103
+ //Return the first result.
104
+ if ( !empty($versionTags) ) {
105
+ $tag = $versionTags[0];
106
+ return new Puc_v4p8_Vcs_Reference(array(
107
+ 'name' => $tag->name,
108
+ 'version' => ltrim($tag->name, 'v'),
109
+ 'updated' => $tag->target->date,
110
+ 'downloadUrl' => $this->getDownloadUrl($tag->name),
111
+ ));
112
+ }
113
+ return null;
114
+ }
115
+
116
+ /**
117
+ * Get the tag/ref specified by the "Stable tag" header in the readme.txt of a given branch.
118
+ *
119
+ * @param string $branch
120
+ * @return null|Puc_v4p8_Vcs_Reference
121
+ */
122
+ protected function getStableTag($branch) {
123
+ $remoteReadme = $this->getRemoteReadme($branch);
124
+ if ( !empty($remoteReadme['stable_tag']) ) {
125
+ $tag = $remoteReadme['stable_tag'];
126
+
127
+ //You can explicitly opt out of using tags by setting "Stable tag" to
128
+ //"trunk" or the name of the current branch.
129
+ if ( ($tag === $branch) || ($tag === 'trunk') ) {
130
+ return $this->getBranch($branch);
131
+ }
132
+
133
+ return $this->getTag($tag);
134
+ }
135
+
136
+ return null;
137
+ }
138
+
139
+ /**
140
+ * @param string $ref
141
+ * @return string
142
+ */
143
+ protected function getDownloadUrl($ref) {
144
+ return sprintf(
145
+ 'https://bitbucket.org/%s/%s/get/%s.zip',
146
+ $this->username,
147
+ $this->repository,
148
+ $ref
149
+ );
150
+ }
151
+
152
+ /**
153
+ * Get the contents of a file from a specific branch or tag.
154
+ *
155
+ * @param string $path File name.
156
+ * @param string $ref
157
+ * @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error.
158
+ */
159
+ public function getRemoteFile($path, $ref = 'master') {
160
+ $response = $this->api('src/' . $ref . '/' . ltrim($path));
161
+ if ( is_wp_error($response) || !is_string($response) ) {
162
+ return null;
163
+ }
164
+ return $response;
165
+ }
166
+
167
+ /**
168
+ * Get the timestamp of the latest commit that changed the specified branch or tag.
169
+ *
170
+ * @param string $ref Reference name (e.g. branch or tag).
171
+ * @return string|null
172
+ */
173
+ public function getLatestCommitTime($ref) {
174
+ $response = $this->api('commits/' . $ref);
175
+ if ( isset($response->values, $response->values[0], $response->values[0]->date) ) {
176
+ return $response->values[0]->date;
177
+ }
178
+ return null;
179
+ }
180
+
181
+ /**
182
+ * Perform a BitBucket API 2.0 request.
183
+ *
184
+ * @param string $url
185
+ * @param string $version
186
+ * @return mixed|WP_Error
187
+ */
188
+ public function api($url, $version = '2.0') {
189
+ $url = ltrim($url, '/');
190
+ $isSrcResource = Puc_v4p8_Utils::startsWith($url, 'src/');
191
+
192
+ $url = implode('/', array(
193
+ 'https://api.bitbucket.org',
194
+ $version,
195
+ 'repositories',
196
+ $this->username,
197
+ $this->repository,
198
+ $url
199
+ ));
200
+ $baseUrl = $url;
201
+
202
+ if ( $this->oauth ) {
203
+ $url = $this->oauth->sign($url,'GET');
204
+ }
205
+
206
+ $options = array('timeout' => 10);
207
+ if ( !empty($this->httpFilterName) ) {
208
+ $options = apply_filters($this->httpFilterName, $options);
209
+ }
210
+ $response = wp_remote_get($url, $options);
211
+ if ( is_wp_error($response) ) {
212
+ do_action('puc_api_error', $response, null, $url, $this->slug);
213
+ return $response;
214
+ }
215
+
216
+ $code = wp_remote_retrieve_response_code($response);
217
+ $body = wp_remote_retrieve_body($response);
218
+ if ( $code === 200 ) {
219
+ if ( $isSrcResource ) {
220
+ //Most responses are JSON-encoded, but src resources just
221
+ //return raw file contents.
222
+ $document = $body;
223
+ } else {
224
+ $document = json_decode($body);
225
+ }
226
+ return $document;
227
+ }
228
+
229
+ $error = new WP_Error(
230
+ 'puc-bitbucket-http-error',
231
+ sprintf('BitBucket API error. Base URL: "%s", HTTP status code: %d.', $baseUrl, $code)
232
+ );
233
+ do_action('puc_api_error', $error, $response, $url, $this->slug);
234
+
235
+ return $error;
236
+ }
237
+
238
+ /**
239
+ * @param array $credentials
240
+ */
241
+ public function setAuthentication($credentials) {
242
+ parent::setAuthentication($credentials);
243
+
244
+ if ( !empty($credentials) && !empty($credentials['consumer_key']) ) {
245
+ $this->oauth = new Puc_v4p8_OAuthSignature(
246
+ $credentials['consumer_key'],
247
+ $credentials['consumer_secret']
248
+ );
249
+ } else {
250
+ $this->oauth = null;
251
+ }
252
+ }
253
+
254
+ public function signDownloadUrl($url) {
255
+ //Add authentication data to download URLs. Since OAuth signatures incorporate
256
+ //timestamps, we have to do this immediately before inserting the update. Otherwise
257
+ //authentication could fail due to a stale timestamp.
258
+ if ( $this->oauth ) {
259
+ $url = $this->oauth->sign($url);
260
+ }
261
+ return $url;
262
+ }
263
+ }
264
+
265
+ endif;
lib/plugin-update-checker/Puc/v4p8/Vcs/GitHubApi.php ADDED
@@ -0,0 +1,417 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p8_Vcs_GitHubApi', false) ):
4
+
5
+ class Puc_v4p8_Vcs_GitHubApi extends Puc_v4p8_Vcs_Api {
6
+ /**
7
+ * @var string GitHub username.
8
+ */
9
+ protected $userName;
10
+ /**
11
+ * @var string GitHub repository name.
12
+ */
13
+ protected $repositoryName;
14
+
15
+ /**
16
+ * @var string Either a fully qualified repository URL, or just "user/repo-name".
17
+ */
18
+ protected $repositoryUrl;
19
+
20
+ /**
21
+ * @var string GitHub authentication token. Optional.
22
+ */
23
+ protected $accessToken;
24
+
25
+ /**
26
+ * @var bool Whether to download release assets instead of the auto-generated source code archives.
27
+ */
28
+ protected $releaseAssetsEnabled = false;
29
+
30
+ /**
31
+ * @var string|null Regular expression that's used to filter release assets by name. Optional.
32
+ */
33
+ protected $assetFilterRegex = null;
34
+
35
+ /**
36
+ * @var string|null The unchanging part of a release asset URL. Used to identify download attempts.
37
+ */
38
+ protected $assetApiBaseUrl = null;
39
+
40
+ /**
41
+ * @var bool
42
+ */
43
+ private $downloadFilterAdded = false;
44
+
45
+ public function __construct($repositoryUrl, $accessToken = null) {
46
+ $path = parse_url($repositoryUrl, PHP_URL_PATH);
47
+ if ( preg_match('@^/?(?P<username>[^/]+?)/(?P<repository>[^/#?&]+?)/?$@', $path, $matches) ) {
48
+ $this->userName = $matches['username'];
49
+ $this->repositoryName = $matches['repository'];
50
+ } else {
51
+ throw new InvalidArgumentException('Invalid GitHub repository URL: "' . $repositoryUrl . '"');
52
+ }
53
+
54
+ parent::__construct($repositoryUrl, $accessToken);
55
+ }
56
+
57
+ /**
58
+ * Get the latest release from GitHub.
59
+ *
60
+ * @return Puc_v4p8_Vcs_Reference|null
61
+ */
62
+ public function getLatestRelease() {
63
+ $release = $this->api('/repos/:user/:repo/releases/latest');
64
+ if ( is_wp_error($release) || !is_object($release) || !isset($release->tag_name) ) {
65
+ return null;
66
+ }
67
+
68
+ $reference = new Puc_v4p8_Vcs_Reference(array(
69
+ 'name' => $release->tag_name,
70
+ 'version' => ltrim($release->tag_name, 'v'), //Remove the "v" prefix from "v1.2.3".
71
+ 'downloadUrl' => $this->signDownloadUrl($release->zipball_url),
72
+ 'updated' => $release->created_at,
73
+ 'apiResponse' => $release,
74
+ ));
75
+
76
+ if ( isset($release->assets[0]) ) {
77
+ $reference->downloadCount = $release->assets[0]->download_count;
78
+ }
79
+
80
+ if ( $this->releaseAssetsEnabled && isset($release->assets, $release->assets[0]) ) {
81
+ //Use the first release asset that matches the specified regular expression.
82
+ $matchingAssets = array_filter($release->assets, array($this, 'matchesAssetFilter'));
83
+ if ( !empty($matchingAssets) ) {
84
+ if ( $this->isAuthenticationEnabled() ) {
85
+ /**
86
+ * Keep in mind that we'll need to add an "Accept" header to download this asset.
87
+ * @see setReleaseDownloadHeader()
88
+ */
89
+ $reference->downloadUrl = $this->signDownloadUrl($matchingAssets[0]->url);
90
+ } else {
91
+ //It seems that browser_download_url only works for public repositories.
92
+ //Using an access_token doesn't help. Maybe OAuth would work?
93
+ $reference->downloadUrl = $matchingAssets[0]->browser_download_url;
94
+ }
95
+
96
+ $reference->downloadCount = $matchingAssets[0]->download_count;
97
+ }
98
+ }
99
+
100
+ if ( !empty($release->body) ) {
101
+ /** @noinspection PhpUndefinedClassInspection */
102
+ $reference->changelog = Parsedown::instance()->text($release->body);
103
+ }
104
+
105
+ return $reference;
106
+ }
107
+
108
+ /**
109
+ * Get the tag that looks like the highest version number.
110
+ *
111
+ * @return Puc_v4p8_Vcs_Reference|null
112
+ */
113
+ public function getLatestTag() {
114
+ $tags = $this->api('/repos/:user/:repo/tags');
115
+
116
+ if ( is_wp_error($tags) || !is_array($tags) ) {
117
+ return null;
118
+ }
119
+
120
+ $versionTags = $this->sortTagsByVersion($tags);
121
+ if ( empty($versionTags) ) {
122
+ return null;
123
+ }
124
+
125
+ $tag = $versionTags[0];
126
+ return new Puc_v4p8_Vcs_Reference(array(
127
+ 'name' => $tag->name,
128
+ 'version' => ltrim($tag->name, 'v'),
129
+ 'downloadUrl' => $this->signDownloadUrl($tag->zipball_url),
130
+ 'apiResponse' => $tag,
131
+ ));
132
+ }
133
+
134
+ /**
135
+ * Get a branch by name.
136
+ *
137
+ * @param string $branchName
138
+ * @return null|Puc_v4p8_Vcs_Reference
139
+ */
140
+ public function getBranch($branchName) {
141
+ $branch = $this->api('/repos/:user/:repo/branches/' . $branchName);
142
+ if ( is_wp_error($branch) || empty($branch) ) {
143
+ return null;
144
+ }
145
+
146
+ $reference = new Puc_v4p8_Vcs_Reference(array(
147
+ 'name' => $branch->name,
148
+ 'downloadUrl' => $this->buildArchiveDownloadUrl($branch->name),
149
+ 'apiResponse' => $branch,
150
+ ));
151
+
152
+ if ( isset($branch->commit, $branch->commit->commit, $branch->commit->commit->author->date) ) {
153
+ $reference->updated = $branch->commit->commit->author->date;
154
+ }
155
+
156
+ return $reference;
157
+ }
158
+
159
+ /**
160
+ * Get the latest commit that changed the specified file.
161
+ *
162
+ * @param string $filename
163
+ * @param string $ref Reference name (e.g. branch or tag).
164
+ * @return StdClass|null
165
+ */
166
+ public function getLatestCommit($filename, $ref = 'master') {
167
+ $commits = $this->api(
168
+ '/repos/:user/:repo/commits',
169
+ array(
170
+ 'path' => $filename,
171
+ 'sha' => $ref,
172
+ )
173
+ );
174
+ if ( !is_wp_error($commits) && isset($commits[0]) ) {
175
+ return $commits[0];
176
+ }
177
+ return null;
178
+ }
179
+
180
+ /**
181
+ * Get the timestamp of the latest commit that changed the specified branch or tag.
182
+ *
183
+ * @param string $ref Reference name (e.g. branch or tag).
184
+ * @return string|null
185
+ */
186
+ public function getLatestCommitTime($ref) {
187
+ $commits = $this->api('/repos/:user/:repo/commits', array('sha' => $ref));
188
+ if ( !is_wp_error($commits) && isset($commits[0]) ) {
189
+ return $commits[0]->commit->author->date;
190
+ }
191
+ return null;
192
+ }
193
+
194
+ /**
195
+ * Perform a GitHub API request.
196
+ *
197
+ * @param string $url
198
+ * @param array $queryParams
199
+ * @return mixed|WP_Error
200
+ */
201
+ protected function api($url, $queryParams = array()) {
202
+ $baseUrl = $url;
203
+ $url = $this->buildApiUrl($url, $queryParams);
204
+
205
+ $options = array('timeout' => 10);
206
+ if ( !empty($this->httpFilterName) ) {
207
+ $options = apply_filters($this->httpFilterName, $options);
208
+ }
209
+ $response = wp_remote_get($url, $options);
210
+ if ( is_wp_error($response) ) {
211
+ do_action('puc_api_error', $response, null, $url, $this->slug);
212
+ return $response;
213
+ }
214
+
215
+ $code = wp_remote_retrieve_response_code($response);
216
+ $body = wp_remote_retrieve_body($response);
217
+ if ( $code === 200 ) {
218
+ $document = json_decode($body);
219
+ return $document;
220
+ }
221
+
222
+ $error = new WP_Error(
223
+ 'puc-github-http-error',
224
+ sprintf('GitHub API error. Base URL: "%s", HTTP status code: %d.', $baseUrl, $code)
225
+ );
226
+ do_action('puc_api_error', $error, $response, $url, $this->slug);
227
+
228
+ return $error;
229
+ }
230
+
231
+ /**
232
+ * Build a fully qualified URL for an API request.
233
+ *
234
+ * @param string $url
235
+ * @param array $queryParams
236
+ * @return string
237
+ */
238
+ protected function buildApiUrl($url, $queryParams) {
239
+ $variables = array(
240
+ 'user' => $this->userName,
241
+ 'repo' => $this->repositoryName,
242
+ );
243
+ foreach ($variables as $name => $value) {
244
+ $url = str_replace('/:' . $name, '/' . urlencode($value), $url);
245
+ }
246
+ $url = 'https://api.github.com' . $url;
247
+
248
+ if ( !empty($this->accessToken) ) {
249
+ $queryParams['access_token'] = $this->accessToken;
250
+ }
251
+ if ( !empty($queryParams) ) {
252
+ $url = add_query_arg($queryParams, $url);
253
+ }
254
+
255
+ return $url;
256
+ }
257
+
258
+ /**
259
+ * Get the contents of a file from a specific branch or tag.
260
+ *
261
+ * @param string $path File name.
262
+ * @param string $ref
263
+ * @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error.
264
+ */
265
+ public function getRemoteFile($path, $ref = 'master') {
266
+ $apiUrl = '/repos/:user/:repo/contents/' . $path;
267
+ $response = $this->api($apiUrl, array('ref' => $ref));
268
+
269
+ if ( is_wp_error($response) || !isset($response->content) || ($response->encoding !== 'base64') ) {
270
+ return null;
271
+ }
272
+ return base64_decode($response->content);
273
+ }
274
+
275
+ /**
276
+ * Generate a URL to download a ZIP archive of the specified branch/tag/etc.
277
+ *
278
+ * @param string $ref
279
+ * @return string
280
+ */
281
+ public function buildArchiveDownloadUrl($ref = 'master') {
282
+ $url = sprintf(
283
+ 'https://api.github.com/repos/%1$s/%2$s/zipball/%3$s',
284
+ urlencode($this->userName),
285
+ urlencode($this->repositoryName),
286
+ urlencode($ref)
287
+ );
288
+ if ( !empty($this->accessToken) ) {
289
+ $url = $this->signDownloadUrl($url);
290
+ }
291
+ return $url;
292
+ }
293
+
294
+ /**
295
+ * Get a specific tag.
296
+ *
297
+ * @param string $tagName
298
+ * @return void
299
+ */
300
+ public function getTag($tagName) {
301
+ //The current GitHub update checker doesn't use getTag, so I didn't bother to implement it.
302
+ throw new LogicException('The ' . __METHOD__ . ' method is not implemented and should not be used.');
303
+ }
304
+
305
+ public function setAuthentication($credentials) {
306
+ parent::setAuthentication($credentials);
307
+ $this->accessToken = is_string($credentials) ? $credentials : null;
308
+ }
309
+
310
+ /**
311
+ * Figure out which reference (i.e tag or branch) contains the latest version.
312
+ *
313
+ * @param string $configBranch Start looking in this branch.
314
+ * @return null|Puc_v4p8_Vcs_Reference
315
+ */
316
+ public function chooseReference($configBranch) {
317
+ $updateSource = null;
318
+
319
+ if ( $configBranch === 'master' ) {
320
+ //Use the latest release.
321
+ $updateSource = $this->getLatestRelease();
322
+ if ( $updateSource === null ) {
323
+ //Failing that, use the tag with the highest version number.
324
+ $updateSource = $this->getLatestTag();
325
+ }
326
+ }
327
+ //Alternatively, just use the branch itself.
328
+ if ( empty($updateSource) ) {
329
+ $updateSource = $this->getBranch($configBranch);
330
+ }
331
+
332
+ return $updateSource;
333
+ }
334
+
335
+ /**
336
+ * @param string $url
337
+ * @return string
338
+ */
339
+ public function signDownloadUrl($url) {
340
+ if ( empty($this->credentials) ) {
341
+ return $url;
342
+ }
343
+ return add_query_arg('access_token', $this->credentials, $url);
344
+ }
345
+
346
+ /**
347
+ * Enable updating via release assets.
348
+ *
349
+ * If the latest release contains no usable assets, the update checker
350
+ * will fall back to using the automatically generated ZIP archive.
351
+ *
352
+ * Private repositories will only work with WordPress 3.7 or later.
353
+ *
354
+ * @param string|null $fileNameRegex Optional. Use only those assets where the file name matches this regex.
355
+ */
356
+ public function enableReleaseAssets($fileNameRegex = null) {
357
+ $this->releaseAssetsEnabled = true;
358
+ $this->assetFilterRegex = $fileNameRegex;
359
+ $this->assetApiBaseUrl = sprintf(
360
+ '//api.github.com/repos/%1$s/%2$s/releases/assets/',
361
+ $this->userName,
362
+ $this->repositoryName
363
+ );
364
+
365
+ //Optimization: Instead of filtering all HTTP requests, let's do it only when
366
+ //WordPress is about to download an update.
367
+ add_filter('upgrader_pre_download', array($this, 'addHttpRequestFilter'), 10, 1); //WP 3.7+
368
+ }
369
+
370
+ /**
371
+ * Does this asset match the file name regex?
372
+ *
373
+ * @param stdClass $releaseAsset
374
+ * @return bool
375
+ */
376
+ protected function matchesAssetFilter($releaseAsset) {
377
+ if ( $this->assetFilterRegex === null ) {
378
+ //The default is to accept all assets.
379
+ return true;
380
+ }
381
+ return isset($releaseAsset->name) && preg_match($this->assetFilterRegex, $releaseAsset->name);
382
+ }
383
+
384
+ /**
385
+ * @internal
386
+ * @param bool $result
387
+ * @return bool
388
+ */
389
+ public function addHttpRequestFilter($result) {
390
+ if ( $this->releaseAssetsEnabled && !$this->downloadFilterAdded && $this->isAuthenticationEnabled() ) {
391
+ add_filter('http_request_args', array($this, 'setReleaseDownloadHeader'), 10, 2);
392
+ $this->downloadFilterAdded = true;
393
+ }
394
+ return $result;
395
+ }
396
+
397
+ /**
398
+ * Set the HTTP header that's necessary to download private release assets.
399
+ *
400
+ * See GitHub docs:
401
+ * @link https://developer.github.com/v3/repos/releases/#get-a-single-release-asset
402
+ *
403
+ * @internal
404
+ * @param array $requestArgs
405
+ * @param string $url
406
+ * @return array
407
+ */
408
+ public function setReleaseDownloadHeader($requestArgs, $url = '') {
409
+ //Is WordPress trying to download one of our assets?
410
+ if ( strpos($url, $this->assetApiBaseUrl) !== false ) {
411
+ $requestArgs['headers']['accept'] = 'application/octet-stream';
412
+ }
413
+ return $requestArgs;
414
+ }
415
+ }
416
+
417
+ endif;
lib/plugin-update-checker/Puc/v4p8/Vcs/GitLabApi.php ADDED
@@ -0,0 +1,309 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p8_Vcs_GitLabApi', false) ):
4
+
5
+ class Puc_v4p8_Vcs_GitLabApi extends Puc_v4p8_Vcs_Api {
6
+ /**
7
+ * @var string GitLab username.
8
+ */
9
+ protected $userName;
10
+
11
+ /**
12
+ * @var string GitLab server host.
13
+ */
14
+ protected $repositoryHost;
15
+
16
+ /**
17
+ * @var string Protocol used by this GitLab server: "http" or "https".
18
+ */
19
+ protected $repositoryProtocol = 'https';
20
+
21
+ /**
22
+ * @var string GitLab repository name.
23
+ */
24
+ protected $repositoryName;
25
+
26
+ /**
27
+ * @var string GitLab authentication token. Optional.
28
+ */
29
+ protected $accessToken;
30
+
31
+ public function __construct($repositoryUrl, $accessToken = null, $subgroup = null) {
32
+ //Parse the repository host to support custom hosts.
33
+ $port = parse_url($repositoryUrl, PHP_URL_PORT);
34
+ if ( !empty($port) ) {
35
+ $port = ':' . $port;
36
+ }
37
+ $this->repositoryHost = parse_url($repositoryUrl, PHP_URL_HOST) . $port;
38
+
39
+ if ( $this->repositoryHost !== 'gitlab.com' ) {
40
+ $this->repositoryProtocol = parse_url($repositoryUrl, PHP_URL_SCHEME);
41
+ }
42
+
43
+ //Find the repository information
44
+ $path = parse_url($repositoryUrl, PHP_URL_PATH);
45
+ if ( preg_match('@^/?(?P<username>[^/]+?)/(?P<repository>[^/#?&]+?)/?$@', $path, $matches) ) {
46
+ $this->userName = $matches['username'];
47
+ $this->repositoryName = $matches['repository'];
48
+ } elseif ( ($this->repositoryHost === 'gitlab.com') ) {
49
+ //This is probably a repository in a subgroup, e.g. "/organization/category/repo".
50
+ $parts = explode('/', trim($path, '/'));
51
+ if ( count($parts) < 3 ) {
52
+ throw new InvalidArgumentException('Invalid GitLab.com repository URL: "' . $repositoryUrl . '"');
53
+ }
54
+ $lastPart = array_pop($parts);
55
+ $this->userName = implode('/', $parts);
56
+ $this->repositoryName = $lastPart;
57
+ } else {
58
+ //There could be subgroups in the URL: gitlab.domain.com/group/subgroup/subgroup2/repository
59
+ if ( $subgroup !== null ) {
60
+ $path = str_replace(trailingslashit($subgroup), '', $path);
61
+ }
62
+
63
+ //This is not a traditional url, it could be gitlab is in a deeper subdirectory.
64
+ //Get the path segments.
65
+ $segments = explode('/', untrailingslashit(ltrim($path, '/')));
66
+
67
+ //We need at least /user-name/repository-name/
68
+ if ( count($segments) < 2 ) {
69
+ throw new InvalidArgumentException('Invalid GitLab repository URL: "' . $repositoryUrl . '"');
70
+ }
71
+
72
+ //Get the username and repository name.
73
+ $usernameRepo = array_splice($segments, -2, 2);
74
+ $this->userName = $usernameRepo[0];
75
+ $this->repositoryName = $usernameRepo[1];
76
+
77
+ //Append the remaining segments to the host if there are segments left.
78
+ if ( count($segments) > 0 ) {
79
+ $this->repositoryHost = trailingslashit($this->repositoryHost) . implode('/', $segments);
80
+ }
81
+
82
+ //Add subgroups to username.
83
+ if ( $subgroup !== null ) {
84
+ $this->userName = $usernameRepo[0] . '/' . untrailingslashit($subgroup);
85
+ }
86
+ }
87
+
88
+ parent::__construct($repositoryUrl, $accessToken);
89
+ }
90
+
91
+ /**
92
+ * Get the latest release from GitLab.
93
+ *
94
+ * @return Puc_v4p8_Vcs_Reference|null
95
+ */
96
+ public function getLatestRelease() {
97
+ return $this->getLatestTag();
98
+ }
99
+
100
+ /**
101
+ * Get the tag that looks like the highest version number.
102
+ *
103
+ * @return Puc_v4p8_Vcs_Reference|null
104
+ */
105
+ public function getLatestTag() {
106
+ $tags = $this->api('/:id/repository/tags');
107
+ if ( is_wp_error($tags) || empty($tags) || !is_array($tags) ) {
108
+ return null;
109
+ }
110
+
111
+ $versionTags = $this->sortTagsByVersion($tags);
112
+ if ( empty($versionTags) ) {
113
+ return null;
114
+ }
115
+
116
+ $tag = $versionTags[0];
117
+ return new Puc_v4p8_Vcs_Reference(array(
118
+ 'name' => $tag->name,
119
+ 'version' => ltrim($tag->name, 'v'),
120
+ 'downloadUrl' => $this->buildArchiveDownloadUrl($tag->name),
121
+ 'apiResponse' => $tag,
122
+ ));
123
+ }
124
+
125
+ /**
126
+ * Get a branch by name.
127
+ *
128
+ * @param string $branchName
129
+ * @return null|Puc_v4p8_Vcs_Reference
130
+ */
131
+ public function getBranch($branchName) {
132
+ $branch = $this->api('/:id/repository/branches/' . $branchName);
133
+ if ( is_wp_error($branch) || empty($branch) ) {
134
+ return null;
135
+ }
136
+
137
+ $reference = new Puc_v4p8_Vcs_Reference(array(
138
+ 'name' => $branch->name,
139
+ 'downloadUrl' => $this->buildArchiveDownloadUrl($branch->name),
140
+ 'apiResponse' => $branch,
141
+ ));
142
+
143
+ if ( isset($branch->commit, $branch->commit->committed_date) ) {
144
+ $reference->updated = $branch->commit->committed_date;
145
+ }
146
+
147
+ return $reference;
148
+ }
149
+
150
+ /**
151
+ * Get the timestamp of the latest commit that changed the specified branch or tag.
152
+ *
153
+ * @param string $ref Reference name (e.g. branch or tag).
154
+ * @return string|null
155
+ */
156
+ public function getLatestCommitTime($ref) {
157
+ $commits = $this->api('/:id/repository/commits/', array('ref_name' => $ref));
158
+ if ( is_wp_error($commits) || !is_array($commits) || !isset($commits[0]) ) {
159
+ return null;
160
+ }
161
+
162
+ return $commits[0]->committed_date;
163
+ }
164
+
165
+ /**
166
+ * Perform a GitLab API request.
167
+ *
168
+ * @param string $url
169
+ * @param array $queryParams
170
+ * @return mixed|WP_Error
171
+ */
172
+ protected function api($url, $queryParams = array()) {
173
+ $baseUrl = $url;
174
+ $url = $this->buildApiUrl($url, $queryParams);
175
+
176
+ $options = array('timeout' => 10);
177
+ if ( !empty($this->httpFilterName) ) {
178
+ $options = apply_filters($this->httpFilterName, $options);
179
+ }
180
+
181
+ $response = wp_remote_get($url, $options);
182
+ if ( is_wp_error($response) ) {
183
+ do_action('puc_api_error', $response, null, $url, $this->slug);
184
+ return $response;
185
+ }
186
+
187
+ $code = wp_remote_retrieve_response_code($response);
188
+ $body = wp_remote_retrieve_body($response);
189
+ if ( $code === 200 ) {
190
+ return json_decode($body);
191
+ }
192
+
193
+ $error = new WP_Error(
194
+ 'puc-gitlab-http-error',
195
+ sprintf('GitLab API error. URL: "%s", HTTP status code: %d.', $baseUrl, $code)
196
+ );
197
+ do_action('puc_api_error', $error, $response, $url, $this->slug);
198
+
199
+ return $error;
200
+ }
201
+
202
+ /**
203
+ * Build a fully qualified URL for an API request.
204
+ *
205
+ * @param string $url
206
+ * @param array $queryParams
207
+ * @return string
208
+ */
209
+ protected function buildApiUrl($url, $queryParams) {
210
+ $variables = array(
211
+ 'user' => $this->userName,
212
+ 'repo' => $this->repositoryName,
213
+ 'id' => $this->userName . '/' . $this->repositoryName,
214
+ );
215
+
216
+ foreach ($variables as $name => $value) {
217
+ $url = str_replace("/:{$name}", '/' . urlencode($value), $url);
218
+ }
219
+
220
+ $url = substr($url, 1);
221
+ $url = sprintf('%1$s://%2$s/api/v4/projects/%3$s', $this->repositoryProtocol, $this->repositoryHost, $url);
222
+
223
+ if ( !empty($this->accessToken) ) {
224
+ $queryParams['private_token'] = $this->accessToken;
225
+ }
226
+
227
+ if ( !empty($queryParams) ) {
228
+ $url = add_query_arg($queryParams, $url);
229
+ }
230
+
231
+ return $url;
232
+ }
233
+
234
+ /**
235
+ * Get the contents of a file from a specific branch or tag.
236
+ *
237
+ * @param string $path File name.
238
+ * @param string $ref
239
+ * @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error.
240
+ */
241
+ public function getRemoteFile($path, $ref = 'master') {
242
+ $response = $this->api('/:id/repository/files/' . $path, array('ref' => $ref));
243
+ if ( is_wp_error($response) || !isset($response->content) || $response->encoding !== 'base64' ) {
244
+ return null;
245
+ }
246
+
247
+ return base64_decode($response->content);
248
+ }
249
+
250
+ /**
251
+ * Generate a URL to download a ZIP archive of the specified branch/tag/etc.
252
+ *
253
+ * @param string $ref
254
+ * @return string
255
+ */
256
+ public function buildArchiveDownloadUrl($ref = 'master') {
257
+ $url = sprintf(
258
+ '%1$s://%2$s/api/v4/projects/%3$s/repository/archive.zip',
259
+ $this->repositoryProtocol,
260
+ $this->repositoryHost,
261
+ urlencode($this->userName . '/' . $this->repositoryName)
262
+ );
263
+ $url = add_query_arg('sha', urlencode($ref), $url);
264
+
265
+ if ( !empty($this->accessToken) ) {
266
+ $url = add_query_arg('private_token', $this->accessToken, $url);
267
+ }
268
+
269
+ return $url;
270
+ }
271
+
272
+ /**
273
+ * Get a specific tag.
274
+ *
275
+ * @param string $tagName
276
+ * @return void
277
+ */
278
+ public function getTag($tagName) {
279
+ throw new LogicException('The ' . __METHOD__ . ' method is not implemented and should not be used.');
280
+ }
281
+
282
+ /**
283
+ * Figure out which reference (i.e tag or branch) contains the latest version.
284
+ *
285
+ * @param string $configBranch Start looking in this branch.
286
+ * @return null|Puc_v4p8_Vcs_Reference
287
+ */
288
+ public function chooseReference($configBranch) {
289
+ $updateSource = null;
290
+
291
+ // GitLab doesn't handle releases the same as GitHub so just use the latest tag
292
+ if ( $configBranch === 'master' ) {
293
+ $updateSource = $this->getLatestTag();
294
+ }
295
+
296
+ if ( empty($updateSource) ) {
297
+ $updateSource = $this->getBranch($configBranch);
298
+ }
299
+
300
+ return $updateSource;
301
+ }
302
+
303
+ public function setAuthentication($credentials) {
304
+ parent::setAuthentication($credentials);
305
+ $this->accessToken = is_string($credentials) ? $credentials : null;
306
+ }
307
+ }
308
+
309
+ endif;
lib/plugin-update-checker/Puc/v4p8/Vcs/PluginUpdateChecker.php ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p8_Vcs_PluginUpdateChecker') ):
3
+
4
+ class Puc_v4p8_Vcs_PluginUpdateChecker extends Puc_v4p8_Plugin_UpdateChecker implements Puc_v4p8_Vcs_BaseChecker {
5
+ /**
6
+ * @var string The branch where to look for updates. Defaults to "master".
7
+ */
8
+ protected $branch = 'master';
9
+
10
+ /**
11
+ * @var Puc_v4p8_Vcs_Api Repository API client.
12
+ */
13
+ protected $api = null;
14
+
15
+ /**
16
+ * Puc_v4p8_Vcs_PluginUpdateChecker constructor.
17
+ *
18
+ * @param Puc_v4p8_Vcs_Api $api
19
+ * @param string $pluginFile
20
+ * @param string $slug
21
+ * @param int $checkPeriod
22
+ * @param string $optionName
23
+ * @param string $muPluginFile
24
+ */
25
+ public function __construct($api, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') {
26
+ $this->api = $api;
27
+ $this->api->setHttpFilterName($this->getUniqueName('request_info_options'));
28
+
29
+ parent::__construct($api->getRepositoryUrl(), $pluginFile, $slug, $checkPeriod, $optionName, $muPluginFile);
30
+
31
+ $this->api->setSlug($this->slug);
32
+ }
33
+
34
+ public function requestInfo($unusedParameter = null) {
35
+ //We have to make several remote API requests to gather all the necessary info
36
+ //which can take a while on slow networks.
37
+ if ( function_exists('set_time_limit') ) {
38
+ @set_time_limit(60);
39
+ }
40
+
41
+ $api = $this->api;
42
+ $api->setLocalDirectory($this->package->getAbsoluteDirectoryPath());
43
+
44
+ $info = new Puc_v4p8_Plugin_Info();
45
+ $info->filename = $this->pluginFile;
46
+ $info->slug = $this->slug;
47
+
48
+ $this->setInfoFromHeader($this->package->getPluginHeader(), $info);
49
+
50
+ //Pick a branch or tag.
51
+ $updateSource = $api->chooseReference($this->branch);
52
+ if ( $updateSource ) {
53
+ $ref = $updateSource->name;
54
+ $info->version = $updateSource->version;
55
+ $info->last_updated = $updateSource->updated;
56
+ $info->download_url = $updateSource->downloadUrl;
57
+
58
+ if ( !empty($updateSource->changelog) ) {
59
+ $info->sections['changelog'] = $updateSource->changelog;
60
+ }
61
+ if ( isset($updateSource->downloadCount) ) {
62
+ $info->downloaded = $updateSource->downloadCount;
63
+ }
64
+ } else {
65
+ //There's probably a network problem or an authentication error.
66
+ do_action(
67
+ 'puc_api_error',
68
+ new WP_Error(
69
+ 'puc-no-update-source',
70
+ 'Could not retrieve version information from the repository. '
71
+ . 'This usually means that the update checker either can\'t connect '
72
+ . 'to the repository or it\'s configured incorrectly.'
73
+ ),
74
+ null, null, $this->slug
75
+ );
76
+ return null;
77
+ }
78
+
79
+ //Get headers from the main plugin file in this branch/tag. Its "Version" header and other metadata
80
+ //are what the WordPress install will actually see after upgrading, so they take precedence over releases/tags.
81
+ $mainPluginFile = basename($this->pluginFile);
82
+ $remotePlugin = $api->getRemoteFile($mainPluginFile, $ref);
83
+ if ( !empty($remotePlugin) ) {
84
+ $remoteHeader = $this->package->getFileHeader($remotePlugin);
85
+ $this->setInfoFromHeader($remoteHeader, $info);
86
+ }
87
+
88
+ //Try parsing readme.txt. If it's formatted according to WordPress.org standards, it will contain
89
+ //a lot of useful information like the required/tested WP version, changelog, and so on.
90
+ if ( $this->readmeTxtExistsLocally() ) {
91
+ $this->setInfoFromRemoteReadme($ref, $info);
92
+ }
93
+
94
+ //The changelog might be in a separate file.
95
+ if ( empty($info->sections['changelog']) ) {
96
+ $info->sections['changelog'] = $api->getRemoteChangelog($ref, $this->package->getAbsoluteDirectoryPath());
97
+ if ( empty($info->sections['changelog']) ) {
98
+ $info->sections['changelog'] = __('There is no changelog available.', 'plugin-update-checker');
99
+ }
100
+ }
101
+
102
+ if ( empty($info->last_updated) ) {
103
+ //Fetch the latest commit that changed the tag or branch and use it as the "last_updated" date.
104
+ $latestCommitTime = $api->getLatestCommitTime($ref);
105
+ if ( $latestCommitTime !== null ) {
106
+ $info->last_updated = $latestCommitTime;
107
+ }
108
+ }
109
+
110
+ $info = apply_filters($this->getUniqueName('request_info_result'), $info, null);
111
+ return $info;
112
+ }
113
+
114
+ /**
115
+ * Check if the currently installed version has a readme.txt file.
116
+ *
117
+ * @return bool
118
+ */
119
+ protected function readmeTxtExistsLocally() {
120
+ return $this->package->fileExists($this->api->getLocalReadmeName());
121
+ }
122
+
123
+ /**
124
+ * Copy plugin metadata from a file header to a Plugin Info object.
125
+ *
126
+ * @param array $fileHeader
127
+ * @param Puc_v4p8_Plugin_Info $pluginInfo
128
+ */
129
+ protected function setInfoFromHeader($fileHeader, $pluginInfo) {
130
+ $headerToPropertyMap = array(
131
+ 'Version' => 'version',
132
+ 'Name' => 'name',
133
+ 'PluginURI' => 'homepage',
134
+ 'Author' => 'author',
135
+ 'AuthorName' => 'author',
136
+ 'AuthorURI' => 'author_homepage',
137
+
138
+ 'Requires WP' => 'requires',
139
+ 'Tested WP' => 'tested',
140
+ 'Requires at least' => 'requires',
141
+ 'Tested up to' => 'tested',
142
+ );
143
+ foreach ($headerToPropertyMap as $headerName => $property) {
144
+ if ( isset($fileHeader[$headerName]) && !empty($fileHeader[$headerName]) ) {
145
+ $pluginInfo->$property = $fileHeader[$headerName];
146
+ }
147
+ }
148
+
149
+ if ( !empty($fileHeader['Description']) ) {
150
+ $pluginInfo->sections['description'] = $fileHeader['Description'];
151
+ }
152
+ }
153
+
154
+ /**
155
+ * Copy plugin metadata from the remote readme.txt file.
156
+ *
157
+ * @param string $ref GitHub tag or branch where to look for the readme.
158
+ * @param Puc_v4p8_Plugin_Info $pluginInfo
159
+ */
160
+ protected function setInfoFromRemoteReadme($ref, $pluginInfo) {
161
+ $readme = $this->api->getRemoteReadme($ref);
162
+ if ( empty($readme) ) {
163
+ return;
164
+ }
165
+
166
+ if ( isset($readme['sections']) ) {
167
+ $pluginInfo->sections = array_merge($pluginInfo->sections, $readme['sections']);
168
+ }
169
+ if ( !empty($readme['tested_up_to']) ) {
170
+ $pluginInfo->tested = $readme['tested_up_to'];
171
+ }
172
+ if ( !empty($readme['requires_at_least']) ) {
173
+ $pluginInfo->requires = $readme['requires_at_least'];
174
+ }
175
+
176
+ if ( isset($readme['upgrade_notice'], $readme['upgrade_notice'][$pluginInfo->version]) ) {
177
+ $pluginInfo->upgrade_notice = $readme['upgrade_notice'][$pluginInfo->version];
178
+ }
179
+ }
180
+
181
+ public function setBranch($branch) {
182
+ $this->branch = $branch;
183
+ return $this;
184
+ }
185
+
186
+ public function setAuthentication($credentials) {
187
+ $this->api->setAuthentication($credentials);
188
+ return $this;
189
+ }
190
+
191
+ public function getVcsApi() {
192
+ return $this->api;
193
+ }
194
+
195
+ public function getUpdate() {
196
+ $update = parent::getUpdate();
197
+
198
+ if ( isset($update) && !empty($update->download_url) ) {
199
+ $update->download_url = $this->api->signDownloadUrl($update->download_url);
200
+ }
201
+
202
+ return $update;
203
+ }
204
+
205
+ public function onDisplayConfiguration($panel) {
206
+ parent::onDisplayConfiguration($panel);
207
+ $panel->row('Branch', $this->branch);
208
+ $panel->row('Authentication enabled', $this->api->isAuthenticationEnabled() ? 'Yes' : 'No');
209
+ $panel->row('API client', get_class($this->api));
210
+ }
211
+ }
212
+
213
+ endif;
lib/plugin-update-checker/Puc/v4p8/Vcs/Reference.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p8_Vcs_Reference', false) ):
3
+
4
+ /**
5
+ * This class represents a VCS branch or tag. It's intended as a read only, short-lived container
6
+ * that only exists to provide a limited degree of type checking.
7
+ *
8
+ * @property string $name
9
+ * @property string|null version
10
+ * @property string $downloadUrl
11
+ * @property string $updated
12
+ *
13
+ * @property string|null $changelog
14
+ * @property int|null $downloadCount
15
+ */
16
+ class Puc_v4p8_Vcs_Reference {
17
+ private $properties = array();
18
+
19
+ public function __construct($properties = array()) {
20
+ $this->properties = $properties;
21
+ }
22
+
23
+ /**
24
+ * @param string $name
25
+ * @return mixed|null
26
+ */
27
+ public function __get($name) {
28
+ return array_key_exists($name, $this->properties) ? $this->properties[$name] : null;
29
+ }
30
+
31
+ /**
32
+ * @param string $name
33
+ * @param mixed $value
34
+ */
35
+ public function __set($name, $value) {
36
+ $this->properties[$name] = $value;
37
+ }
38
+
39
+ /**
40
+ * @param string $name
41
+ * @return bool
42
+ */
43
+ public function __isset($name) {
44
+ return isset($this->properties[$name]);
45
+ }
46
+
47
+ }
48
+
49
+ endif;
lib/plugin-update-checker/Puc/v4p8/Vcs/ThemeUpdateChecker.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p8_Vcs_ThemeUpdateChecker', false) ):
4
+
5
+ class Puc_v4p8_Vcs_ThemeUpdateChecker extends Puc_v4p8_Theme_UpdateChecker implements Puc_v4p8_Vcs_BaseChecker {
6
+ /**
7
+ * @var string The branch where to look for updates. Defaults to "master".
8
+ */
9
+ protected $branch = 'master';
10
+
11
+ /**
12
+ * @var Puc_v4p8_Vcs_Api Repository API client.
13
+ */
14
+ protected $api = null;
15
+
16
+ /**
17
+ * Puc_v4p8_Vcs_ThemeUpdateChecker constructor.
18
+ *
19
+ * @param Puc_v4p8_Vcs_Api $api
20
+ * @param null $stylesheet
21
+ * @param null $customSlug
22
+ * @param int $checkPeriod
23
+ * @param string $optionName
24
+ */
25
+ public function __construct($api, $stylesheet = null, $customSlug = null, $checkPeriod = 12, $optionName = '') {
26
+ $this->api = $api;
27
+ $this->api->setHttpFilterName($this->getUniqueName('request_update_options'));
28
+
29
+ parent::__construct($api->getRepositoryUrl(), $stylesheet, $customSlug, $checkPeriod, $optionName);
30
+
31
+ $this->api->setSlug($this->slug);
32
+ }
33
+
34
+ public function requestUpdate() {
35
+ $api = $this->api;
36
+ $api->setLocalDirectory($this->package->getAbsoluteDirectoryPath());
37
+
38
+ $update = new Puc_v4p8_Theme_Update();
39
+ $update->slug = $this->slug;
40
+
41
+ //Figure out which reference (tag or branch) we'll use to get the latest version of the theme.
42
+ $updateSource = $api->chooseReference($this->branch);
43
+ if ( $updateSource ) {
44
+ $ref = $updateSource->name;
45
+ $update->download_url = $updateSource->downloadUrl;
46
+ } else {
47
+ do_action(
48
+ 'puc_api_error',
49
+ new WP_Error(
50
+ 'puc-no-update-source',
51
+ 'Could not retrieve version information from the repository. '
52
+ . 'This usually means that the update checker either can\'t connect '
53
+ . 'to the repository or it\'s configured incorrectly.'
54
+ ),
55
+ null, null, $this->slug
56
+ );
57
+ $ref = $this->branch;
58
+ }
59
+
60
+ //Get headers from the main stylesheet in this branch/tag. Its "Version" header and other metadata
61
+ //are what the WordPress install will actually see after upgrading, so they take precedence over releases/tags.
62
+ $remoteHeader = $this->package->getFileHeader($api->getRemoteFile('style.css', $ref));
63
+ $update->version = Puc_v4p8_Utils::findNotEmpty(array(
64
+ $remoteHeader['Version'],
65
+ Puc_v4p8_Utils::get($updateSource, 'version'),
66
+ ));
67
+
68
+ //The details URL defaults to the Theme URI header or the repository URL.
69
+ $update->details_url = Puc_v4p8_Utils::findNotEmpty(array(
70
+ $remoteHeader['ThemeURI'],
71
+ $this->package->getHeaderValue('ThemeURI'),
72
+ $this->metadataUrl,
73
+ ));
74
+
75
+ if ( empty($update->version) ) {
76
+ //It looks like we didn't find a valid update after all.
77
+ $update = null;
78
+ }
79
+
80
+ $update = $this->filterUpdateResult($update);
81
+ return $update;
82
+ }
83
+
84
+ //FIXME: This is duplicated code. Both theme and plugin subclasses that use VCS share these methods.
85
+
86
+ public function setBranch($branch) {
87
+ $this->branch = $branch;
88
+ return $this;
89
+ }
90
+
91
+ public function setAuthentication($credentials) {
92
+ $this->api->setAuthentication($credentials);
93
+ return $this;
94
+ }
95
+
96
+ public function getVcsApi() {
97
+ return $this->api;
98
+ }
99
+
100
+ public function getUpdate() {
101
+ $update = parent::getUpdate();
102
+
103
+ if ( isset($update) && !empty($update->download_url) ) {
104
+ $update->download_url = $this->api->signDownloadUrl($update->download_url);
105
+ }
106
+
107
+ return $update;
108
+ }
109
+
110
+ public function onDisplayConfiguration($panel) {
111
+ parent::onDisplayConfiguration($panel);
112
+ $panel->row('Branch', $this->branch);
113
+ $panel->row('Authentication enabled', $this->api->isAuthenticationEnabled() ? 'Yes' : 'No');
114
+ $panel->row('API client', get_class($this->api));
115
+ }
116
+ }
117
+
118
+ endif;
lib/plugin-update-checker/README.md ADDED
@@ -0,0 +1,299 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Plugin Update Checker
2
+ =====================
3
+
4
+ This is a custom update checker library for WordPress plugins and themes. It lets you add automatic update notifications and one-click upgrades to your commercial plugins, private themes, and so on. All you need to do is put your plugin/theme details in a JSON file, place the file on your server, and pass the URL to the library. The library periodically checks the URL to see if there's a new version available and displays an update notification to the user if necessary.
5
+
6
+ From the users' perspective, it works just like with plugins and themes hosted on WordPress.org. The update checker uses the default upgrade UI that is familiar to most WordPress users.
7
+
8
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
9
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
10
+ **Table of Contents**
11
+
12
+ - [Getting Started](#getting-started)
13
+ - [Self-hosted Plugins and Themes](#self-hosted-plugins-and-themes)
14
+ - [How to Release an Update](#how-to-release-an-update)
15
+ - [Notes](#notes)
16
+ - [GitHub Integration](#github-integration)
17
+ - [How to Release an Update](#how-to-release-an-update-1)
18
+ - [Notes](#notes-1)
19
+ - [BitBucket Integration](#bitbucket-integration)
20
+ - [How to Release an Update](#how-to-release-an-update-2)
21
+ - [GitLab Integration](#gitlab-integration)
22
+ - [How to Release an Update](#how-to-release-an-update-3)
23
+ - [License Management](#license-management)
24
+ - [Resources](#resources)
25
+
26
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
27
+
28
+ Getting Started
29
+ ---------------
30
+
31
+ ### Self-hosted Plugins and Themes
32
+
33
+ 1. Download [the latest release](https://github.com/YahnisElsts/plugin-update-checker/releases/latest) and copy the `plugin-update-checker` directory to your plugin or theme.
34
+ 2. Go to the `examples` subdirectory and open the .json file that fits your project type. Replace the placeholder data with your plugin/theme details.
35
+ - Plugin example:
36
+
37
+ ```json
38
+ {
39
+ "name" : "Plugin Name",
40
+ "version" : "2.0",
41
+ "download_url" : "http://example.com/plugin-name-2.0.zip",
42
+ "sections" : {
43
+ "description" : "Plugin description here. You can use HTML."
44
+ }
45
+ }
46
+ ```
47
+
48
+ This is a minimal example that leaves out optional fields. See [this table](https://docs.google.com/spreadsheets/d/1eOBbW7Go2qEQXReOOCdidMTf_tDYRq4JfegcO1CBPIs/edit?usp=sharing) for a full list of supported fields and their descriptions.
49
+ - Theme example:
50
+
51
+ ```json
52
+ {
53
+ "version": "2.0",
54
+ "details_url": "http://example.com/version-2.0-details.html",
55
+ "download_url": "http://example.com/example-theme-2.0.zip"
56
+ }
57
+ ```
58
+
59
+ This is actually a complete example that shows all theme-related fields. `version` and `download_url` should be self-explanatory. The `details_url` key specifies the page that the user will see if they click the "View version 1.2.3 details" link in an update notification.
60
+ 3. Upload the JSON file to a publicly accessible location.
61
+ 4. Add the following code to the main plugin file or to the `functions.php` file:
62
+
63
+ ```php
64
+ require 'path/to/plugin-update-checker/plugin-update-checker.php';
65
+ $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
66
+ 'http://example.com/path/to/details.json',
67
+ __FILE__, //Full path to the main plugin file or functions.php.
68
+ 'unique-plugin-or-theme-slug'
69
+ );
70
+ ```
71
+ Note: If you're using the Composer autoloader, you don't need to explicitly `require` the library.
72
+
73
+ #### How to Release an Update
74
+
75
+ Change the `version` number in the JSON file and make sure that `download_url` points to the latest version. Update the other fields if necessary. Tip: You can use [wp-update-server](https://github.com/YahnisElsts/wp-update-server) to automate this process.
76
+
77
+ By default, the library will check the specified URL for changes every 12 hours. You can force it to check immediately by clicking the "Check for updates" link on the "Plugins" page (it's next to the "Visit plugin site" link). Themes don't have that link, but you can also trigger an update check like this:
78
+
79
+ 1. Install [Debug Bar](https://srd.wordpress.org/plugins/debug-bar/).
80
+ 2. Click the "Debug" menu in the Admin Bar (a.k.a Toolbar).
81
+ 3. Open the "PUC (your-slug)" panel.
82
+ 4. Click the "Check Now" button.
83
+
84
+ #### Notes
85
+ - The second argument passed to `buildUpdateChecker` must be the absolute path to the main plugin file or any file in the theme directory. If you followed the "getting started" instructions, you can just use the `__FILE__` constant.
86
+ - The third argument - i.e. the slug - is optional but recommended. In most cases, the slug should be the same as the name of your plugin directory. For example, if your plugin lives in `/wp-content/plugins/my-plugin`, set the slug to `my-plugin`. If the slug is omitted, the update checker will use the name of the main plugin file as the slug (e.g. `my-cool-plugin.php` &rarr; `my-cool-plugin`). This can lead to conflicts if your plugin has a generic file name like `plugin.php`.
87
+
88
+ This doesn't affect themes because PUC uses the theme directory name as the default slug. Still, if you're planning to use the slug in your own code - e.g. to filter updates or override update checker behaviour - it can be a good idea to set it explicitly.
89
+
90
+ ### GitHub Integration
91
+
92
+ 1. Download [the latest release](https://github.com/YahnisElsts/plugin-update-checker/releases/latest) and copy the `plugin-update-checker` directory to your plugin or theme.
93
+ 2. Add the following code to the main plugin file or `functions.php`:
94
+
95
+ ```php
96
+ require 'plugin-update-checker/plugin-update-checker.php';
97
+ $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
98
+ 'https://github.com/user-name/repo-name/',
99
+ __FILE__,
100
+ 'unique-plugin-or-theme-slug'
101
+ );
102
+
103
+ //Optional: If you're using a private repository, specify the access token like this:
104
+ $myUpdateChecker->setAuthentication('your-token-here');
105
+
106
+ //Optional: Set the branch that contains the stable release.
107
+ $myUpdateChecker->setBranch('stable-branch-name');
108
+ ```
109
+ 3. Plugins only: Add a `readme.txt` file formatted according to the [WordPress.org plugin readme standard](https://wordpress.org/plugins/readme.txt) to your repository. The contents of this file will be shown when the user clicks the "View version 1.2.3 details" link.
110
+
111
+ #### How to Release an Update
112
+
113
+ This library supports a couple of different ways to release updates on GitHub. Pick the one that best fits your workflow.
114
+
115
+ - **GitHub releases**
116
+
117
+ Create a new release using the "Releases" feature on GitHub. The tag name and release title don't matter. The description is optional, but if you do provide one, it will be displayed when the user clicks the "View version x.y.z details" link on the "Plugins" page. Note that PUC ignores releases marked as "This is a pre-release".
118
+
119
+ If you want to use release assets, call the `enableReleaseAssets()` method after creating the update checker instance:
120
+ ```php
121
+ $myUpdateChecker->getVcsApi()->enableReleaseAssets();
122
+ ```
123
+
124
+ - **Tags**
125
+
126
+ To release version 1.2.3, create a new Git tag named `v1.2.3` or `1.2.3`. That's it.
127
+
128
+ PUC doesn't require strict adherence to [SemVer](http://semver.org/). These are all valid tag names: `v1.2.3`, `v1.2-foo`, `1.2.3_rc1-ABC`, `1.2.3.4.5`. However, be warned that it's not smart enough to filter out alpha/beta/RC versions. If that's a problem, you might want to use GitHub releases or branches instead.
129
+
130
+ - **Stable branch**
131
+
132
+ Point the update checker at a stable, production-ready branch:
133
+ ```php
134
+ $updateChecker->setBranch('branch-name');
135
+ ```
136
+ PUC will periodically check the `Version` header in the main plugin file or `style.css` and display a notification if it's greater than the installed version.
137
+
138
+ Caveat: If you set the branch to `master` (the default), the update checker will look for recent releases and tags first. It'll only use the `master` branch if it doesn't find anything else suitable.
139
+
140
+ #### Notes
141
+
142
+ The library will pull update details from the following parts of a release/tag/branch:
143
+
144
+ - Version number
145
+ - The "Version" plugin header.
146
+ - The latest GitHub release or tag name.
147
+ - Changelog
148
+ - The "Changelog" section of `readme.txt`.
149
+ - One of the following files:
150
+ CHANGES.md, CHANGELOG.md, changes.md, changelog.md
151
+ - GitHub release notes.
152
+ - Required and tested WordPress versions
153
+ - The "Requires at least" and "Tested up to" fields in `readme.txt`.
154
+ - The following plugin headers:
155
+ `Required WP`, `Tested WP`, `Requires at least`, `Tested up to`
156
+ - "Last updated" timestamp
157
+ - The creation timestamp of the latest GitHub release.
158
+ - The latest commit in the selected tag or branch.
159
+ - Number of downloads
160
+ - The `download_count` statistic of the latest release.
161
+ - If you're not using GitHub releases, there will be no download stats.
162
+ - Other plugin details - author, homepage URL, description
163
+ - The "Description" section of `readme.txt`.
164
+ - Remote plugin headers (i.e. the latest version on GitHub).
165
+ - Local plugin headers (i.e. the currently installed version).
166
+ - Ratings, banners, screenshots
167
+ - Not supported.
168
+
169
+ ### BitBucket Integration
170
+
171
+ 1. Download [the latest release](https://github.com/YahnisElsts/plugin-update-checker/releases/latest) and copy the `plugin-update-checker` directory to your plugin or theme.
172
+ 2. Add the following code to the main plugin file or `functions.php`:
173
+
174
+ ```php
175
+ require 'plugin-update-checker/plugin-update-checker.php';
176
+ $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
177
+ 'https://bitbucket.org/user-name/repo-name',
178
+ __FILE__,
179
+ 'unique-plugin-or-theme-slug'
180
+ );
181
+
182
+ //Optional: If you're using a private repository, create an OAuth consumer
183
+ //and set the authentication credentials like this:
184
+ //Note: For now you need to check "This is a private consumer" when
185
+ //creating the consumer to work around #134:
186
+ // https://github.com/YahnisElsts/plugin-update-checker/issues/134
187
+ $myUpdateChecker->setAuthentication(array(
188
+ 'consumer_key' => '...',
189
+ 'consumer_secret' => '...',
190
+ ));
191
+
192
+ //Optional: Set the branch that contains the stable release.
193
+ $myUpdateChecker->setBranch('stable-branch-name');
194
+ ```
195
+ 3. Optional: Add a `readme.txt` file formatted according to the [WordPress.org plugin readme standard](https://wordpress.org/plugins/readme.txt) to your repository. For plugins, the contents of this file will be shown when the user clicks the "View version 1.2.3 details" link.
196
+
197
+ #### How to Release an Update
198
+
199
+ BitBucket doesn't have an equivalent to GitHub's releases, so the process is slightly different. You can use any of the following approaches:
200
+
201
+ - **`Stable tag` header**
202
+
203
+ This is the recommended approach if you're using tags to mark each version. Add a `readme.txt` file formatted according to the [WordPress.org plugin readme standard](https://wordpress.org/plugins/readme.txt) to your repository. Set the "stable tag" header to the tag that represents the latest release. Example:
204
+ ```text
205
+ Stable tag: v1.2.3
206
+ ```
207
+ The tag doesn't have to start with a "v" or follow any particular format. You can use any name you like as long as it's a valid Git tag.
208
+
209
+ Tip: If you explicitly set a stable branch, the update checker will look for a `readme.txt` in that branch. Otherwise it will only look at the `master` branch.
210
+
211
+ - **Tags**
212
+
213
+ You can skip the "stable tag" bit and just create a new Git tag named `v1.2.3` or `1.2.3`. The update checker will look at the most recent tags and pick the one that looks like the highest version number.
214
+
215
+ PUC doesn't require strict adherence to [SemVer](http://semver.org/). These are all valid tag names: `v1.2.3`, `v1.2-foo`, `1.2.3_rc1-ABC`, `1.2.3.4.5`. However, be warned that it's not smart enough to filter out alpha/beta/RC versions.
216
+
217
+ - **Stable branch**
218
+
219
+ Point the update checker at a stable, production-ready branch:
220
+ ```php
221
+ $updateChecker->setBranch('branch-name');
222
+ ```
223
+ PUC will periodically check the `Version` header in the main plugin file or `style.css` and display a notification if it's greater than the installed version. Caveat: If you set the branch to `master`, the update checker will still look for tags first.
224
+
225
+ ### GitLab Integration
226
+
227
+ 1. Download [the latest release](https://github.com/YahnisElsts/plugin-update-checker/releases/latest) and copy the `plugin-update-checker` directory to your plugin or theme.
228
+ 2. Add the following code to the main plugin file or `functions.php`:
229
+
230
+ ```php
231
+ require 'plugin-update-checker/plugin-update-checker.php';
232
+ $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
233
+ 'https://gitlab.com/user-name/repo-name/',
234
+ __FILE__,
235
+ 'unique-plugin-or-theme-slug'
236
+ );
237
+
238
+ //Optional: If you're using a private repository, specify the access token like this:
239
+ $myUpdateChecker->setAuthentication('your-token-here');
240
+
241
+ //Optional: Set the branch that contains the stable release.
242
+ $myUpdateChecker->setBranch('stable-branch-name');
243
+ ```
244
+
245
+ Alternatively, if you're using a self-hosted GitLab instance, initialize the update checker like this:
246
+ ```php
247
+ $myUpdateChecker = new Puc_v4p8_Vcs_PluginUpdateChecker(
248
+ new Puc_v4p8_Vcs_GitLabApi('https://myserver.com/user-name/repo-name/'),
249
+ __FILE__,
250
+ 'unique-plugin-or-theme-slug'
251
+ );
252
+ //Optional: Add setAuthentication(...) and setBranch(...) as shown above.
253
+ ```
254
+ If you're using a self-hosted GitLab instance and [subgroups or nested groups](https://docs.gitlab.com/ce/user/group/subgroups/index.html), you have to tell the update checker which parts of the URL are subgroups:
255
+ ```php
256
+ $myUpdateChecker = new Puc_v4p8_Vcs_PluginUpdateChecker(
257
+ new Puc_v4p8_Vcs_GitLabApi('https://myserver.com/group-name/subgroup-level1/subgroup-level2/subgroup-level3/repo-name/', null, 'subgroup-level1/subgroup-level2/subgroup-level3'),
258
+ __FILE__,
259
+ 'unique-plugin-or-theme-slug'
260
+ );
261
+
262
+ ```
263
+
264
+ 3. Plugins only: Add a `readme.txt` file formatted according to the [WordPress.org plugin readme standard](https://wordpress.org/plugins/readme.txt) to your repository. The contents of this file will be shown when the user clicks the "View version 1.2.3 details" link.
265
+
266
+ #### How to Release an Update
267
+
268
+ GitLab doesn't have an equivalent to GitHub's releases, so the process is slightly different. You can use any of the following approaches:
269
+
270
+ - **Tags**
271
+
272
+ To release version 1.2.3, create a new Git tag named `v1.2.3` or `1.2.3`. That's it.
273
+
274
+ PUC doesn't require strict adherence to [SemVer](http://semver.org/). These are all valid tag names: `v1.2.3`, `v1.2-foo`, `1.2.3_rc1-ABC`, `1.2.3.4.5`. However, be warned that it's not smart enough to filter out alpha/beta/RC versions. If that's a problem, you might want to use GitLab branches instead.
275
+
276
+ - **Stable branch**
277
+
278
+ Point the update checker at a stable, production-ready branch:
279
+ ```php
280
+ $updateChecker->setBranch('branch-name');
281
+ ```
282
+ PUC will periodically check the `Version` header in the main plugin file or `style.css` and display a notification if it's greater than the installed version.
283
+
284
+ Caveat: If you set the branch to `master` (the default), the update checker will look for recent releases and tags first. It'll only use the `master` branch if it doesn't find anything else suitable.
285
+
286
+ License Management
287
+ ------------------
288
+
289
+ Currently, the update checker doesn't have any built-in license management features. It only provides some hooks that you can use to, for example, append license keys to update requests (`$updateChecker->addQueryArgFilter()`). If you're looking for ways to manage and verify licenses, please post your feedback in [this issue](https://github.com/YahnisElsts/plugin-update-checker/issues/222).
290
+
291
+ Resources
292
+ ---------
293
+
294
+ - [This blog post](http://w-shadow.com/blog/2010/09/02/automatic-updates-for-any-plugin/) has more information about the update checker API. *Slightly out of date.*
295
+ - [Debug Bar](https://wordpress.org/plugins/debug-bar/) - useful for testing and debugging the update checker.
296
+ - [Update format reference](https://docs.google.com/spreadsheets/d/1eOBbW7Go2qEQXReOOCdidMTf_tDYRq4JfegcO1CBPIs/edit?usp=sharing) - describes all fields supported by the JSON-based update information format used by the update checker. Only covers plugins. Themes use a similar but more limited format.
297
+ - [Securing download links](http://w-shadow.com/blog/2013/03/19/plugin-updates-securing-download-links/) - a general overview.
298
+ - [A GUI for entering download credentials](http://open-tools.net/documentation/tutorial-automatic-updates.html#wordpress)
299
+ - [Theme Update Checker](http://w-shadow.com/blog/2011/06/02/automatic-updates-for-commercial-themes/) - an older, theme-only variant of this update checker.
lib/plugin-update-checker/composer.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "yahnis-elsts/plugin-update-checker",
3
+ "type": "library",
4
+ "description": "A custom update checker for WordPress plugins and themes. Useful if you can't host your plugin in the official WP repository but still want it to support automatic updates.",
5
+ "keywords": ["wordpress", "plugin updates", "automatic updates", "theme updates"],
6
+ "homepage": "https://github.com/YahnisElsts/plugin-update-checker/",
7
+ "license": "MIT",
8
+ "authors": [
9
+ {
10
+ "name": "Yahnis Elsts",
11
+ "email": "whiteshadow@w-shadow.com",
12
+ "homepage": "http://w-shadow.com/",
13
+ "role": "Developer"
14
+ }
15
+ ],
16
+ "require": {
17
+ "php": ">=5.2.0"
18
+ },
19
+ "autoload": {
20
+ "files": ["load-v4p8.php"]
21
+ }
22
+ }
lib/plugin-update-checker/css/puc-debug-bar.css ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .puc-debug-bar-panel-v4 pre {
2
+ margin-top: 0;
3
+ }
4
+
5
+ /* Style the debug data table to match "widefat" table style used by WordPress. */
6
+ table.puc-debug-data {
7
+ width: 100%;
8
+ clear: both;
9
+ margin: 0;
10
+
11
+ border-spacing: 0;
12
+ background-color: #f9f9f9;
13
+
14
+ border-radius: 3px;
15
+ border: 1px solid #dfdfdf;
16
+ border-collapse: separate;
17
+ }
18
+
19
+ table.puc-debug-data * {
20
+ word-wrap: break-word;
21
+ }
22
+
23
+ table.puc-debug-data th {
24
+ width: 11em;
25
+ padding: 7px 7px 8px;
26
+ text-align: left;
27
+
28
+ font-family: "Georgia", "Times New Roman", "Bitstream Charter", "Times", serif;
29
+ font-weight: 400;
30
+ font-size: 14px;
31
+ line-height: 1.3em;
32
+ text-shadow: rgba(255, 255, 255, 0.804) 0 1px 0;
33
+ }
34
+
35
+ table.puc-debug-data td, table.puc-debug-data th {
36
+ border-width: 1px 0;
37
+ border-style: solid;
38
+
39
+ border-top-color: #fff;
40
+ border-bottom-color: #dfdfdf;
41
+
42
+ text-transform: none;
43
+ }
44
+
45
+ table.puc-debug-data td {
46
+ color: #555;
47
+ font-size: 12px;
48
+ padding: 4px 7px 2px;
49
+ vertical-align: top;
50
+ }
51
+
52
+ .puc-ajax-response {
53
+ border: 1px solid #dfdfdf;
54
+ border-radius: 3px;
55
+ padding: 0.5em;
56
+ margin: 5px 0;
57
+ background-color: white;
58
+ }
59
+
60
+ .puc-ajax-nonce {
61
+ display: none;
62
+ }
63
+
64
+ .puc-ajax-response dt {
65
+ margin: 0;
66
+ }
67
+
68
+ .puc-ajax-response dd {
69
+ margin: 0 0 1em;
70
+ }
lib/plugin-update-checker/examples/plugin.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "My Example Plugin",
3
+ "version": "2.0",
4
+ "download_url": "http://example.com/updates/example-plugin.zip",
5
+
6
+ "homepage": "http://example.com/",
7
+ "requires": "4.5",
8
+ "tested": "4.8",
9
+ "last_updated": "2017-01-01 16:17:00",
10
+ "upgrade_notice": "Here's why you should upgrade...",
11
+
12
+ "author": "Janis Elsts",
13
+ "author_homepage": "http://example.com/",
14
+
15
+ "sections": {
16
+ "description": "(Required) Plugin description. Basic HTML can be used in all sections.",
17
+ "installation": "(Recommended) Installation instructions.",
18
+ "changelog": "(Recommended) Changelog. <p>This section will be displayed by default when the user clicks 'View version x.y.z details'.</p>",
19
+ "custom_section": "This is a custom section labeled 'Custom Section'."
20
+ },
21
+
22
+ "icons" : {
23
+ "1x" : "http://w-shadow.com/files/external-update-example/assets/icon-128x128.png",
24
+ "2x" : "http://w-shadow.com/files/external-update-example/assets/icon-256x256.png"
25
+ },
26
+
27
+ "banners": {
28
+ "low": "http://w-shadow.com/files/external-update-example/assets/banner-772x250.png",
29
+ "high": "http://w-shadow.com/files/external-update-example/assets/banner-1544x500.png"
30
+ },
31
+
32
+ "translations": [
33
+ {
34
+ "language": "fr_FR",
35
+ "version": "4.0",
36
+ "updated": "2016-04-22 23:22:42",
37
+ "package": "http://example.com/updates/translations/french-language-pack.zip"
38
+ },
39
+ {
40
+ "language": "de_DE",
41
+ "version": "5.0",
42
+ "updated": "2016-04-22 23:22:42",
43
+ "package": "http://example.com/updates/translations/german-language-pack.zip"
44
+ }
45
+ ],
46
+
47
+ "rating": 90,
48
+ "num_ratings": 123,
49
+
50
+ "downloaded": 1234,
51
+ "active_installs": 12345
52
+ }
lib/plugin-update-checker/examples/theme.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ {
2
+ "version": "2.0",
3
+ "details_url": "http://example.com/version-2.0-details.html",
4
+ "download_url": "http://example.com/example-theme-2.0.zip"
5
+ }
lib/plugin-update-checker/js/debug-bar.js ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(function($) {
2
+
3
+ function runAjaxAction(button, action) {
4
+ button = $(button);
5
+ var panel = button.closest('.puc-debug-bar-panel-v4');
6
+ var responseBox = button.closest('td').find('.puc-ajax-response');
7
+
8
+ responseBox.text('Processing...').show();
9
+ $.post(
10
+ ajaxurl,
11
+ {
12
+ action : action,
13
+ uid : panel.data('uid'),
14
+ _wpnonce: panel.data('nonce')
15
+ },
16
+ function(data) {
17
+ responseBox.html(data);
18
+ },
19
+ 'html'
20
+ );
21
+ }
22
+
23
+ $('.puc-debug-bar-panel-v4 input[name="puc-check-now-button"]').click(function() {
24
+ runAjaxAction(this, 'puc_v4_debug_check_now');
25
+ return false;
26
+ });
27
+
28
+ $('.puc-debug-bar-panel-v4 input[name="puc-request-info-button"]').click(function() {
29
+ runAjaxAction(this, 'puc_v4_debug_request_info');
30
+ return false;
31
+ });
32
+
33
+
34
+ // Debug Bar uses the panel class name as part of its link and container IDs. This means we can
35
+ // end up with multiple identical IDs if more than one plugin uses the update checker library.
36
+ // Fix it by replacing the class name with the plugin slug.
37
+ var panels = $('#debug-menu-targets').find('.puc-debug-bar-panel-v4');
38
+ panels.each(function() {
39
+ var panel = $(this);
40
+ var uid = panel.data('uid');
41
+ var target = panel.closest('.debug-menu-target');
42
+
43
+ //Change the panel wrapper ID.
44
+ target.attr('id', 'debug-menu-target-puc-' + uid);
45
+
46
+ //Change the menu link ID as well and point it at the new target ID.
47
+ $('#debug-bar-menu').find('.puc-debug-menu-link-' + uid)
48
+ .closest('.debug-menu-link')
49
+ .attr('id', 'debug-menu-link-puc-' + uid)
50
+ .attr('href', '#' + target.attr('id'));
51
+ });
52
+ });
lib/plugin-update-checker/languages/plugin-update-checker-ca.mo ADDED
Binary file
lib/plugin-update-checker/languages/plugin-update-checker-ca.po ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2017-11-24 17:02+0200\n"
5
+ "PO-Revision-Date: 2019-09-25 18:15+0200\n"
6
+ "Language-Team: \n"
7
+ "MIME-Version: 1.0\n"
8
+ "Content-Type: text/plain; charset=UTF-8\n"
9
+ "Content-Transfer-Encoding: 8bit\n"
10
+ "X-Generator: Poedit 2.2.3\n"
11
+ "X-Poedit-Basepath: ..\n"
12
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
13
+ "X-Poedit-SourceCharset: UTF-8\n"
14
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
15
+ "Last-Translator: \n"
16
+ "Language: ca\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: Puc/v4p3/Plugin/UpdateChecker.php:395
20
+ msgid "Check for updates"
21
+ msgstr "Comprova si hi ha actualitzacions"
22
+
23
+ #: Puc/v4p3/Plugin/UpdateChecker.php:548
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "L’extensió %s està actualitzada."
28
+
29
+ #: Puc/v4p3/Plugin/UpdateChecker.php:550
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "Una nova versió de l’extensió %s està disponible."
34
+
35
+ #: Puc/v4p3/Plugin/UpdateChecker.php:552
36
+ #, php-format
37
+ msgctxt "the plugin title"
38
+ msgid "Could not determine if updates are available for %s."
39
+ msgstr "No s’ha pogut determinar si hi ha actualitzacions per a %s."
40
+
41
+ #: Puc/v4p3/Plugin/UpdateChecker.php:558
42
+ #, php-format
43
+ msgid "Unknown update checker status \"%s\""
44
+ msgstr "Estat del comprovador d’actualitzacions desconegut \"%s\""
45
+
46
+ #: Puc/v4p3/Vcs/PluginUpdateChecker.php:95
47
+ msgid "There is no changelog available."
48
+ msgstr "No hi ha cap registre de canvis disponible."
lib/plugin-update-checker/languages/plugin-update-checker-cs_CZ.mo ADDED
Binary file
lib/plugin-update-checker/languages/plugin-update-checker-cs_CZ.po ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2017-05-20 10:53+0300\n"
6
+ "PO-Revision-Date: 2017-07-05 15:39+0000\n"
7
+ "Last-Translator: Vojtěch Sajdl <vojtech@sajdl.com>\n"
8
+ "Language-Team: Czech (Czech Republic)\n"
9
+ "Language: cs-CZ\n"
10
+ "Plural-Forms: nplurals=2; plural=(n != 1)\n"
11
+ "MIME-Version: 1.0\n"
12
+ "Content-Type: text/plain; charset=UTF-8\n"
13
+ "Content-Transfer-Encoding: 8bit\n"
14
+ "X-Loco-Source-Locale: cs_CZ\n"
15
+ "X-Generator: Loco - https://localise.biz/\n"
16
+ "X-Poedit-Basepath: ..\n"
17
+ "X-Poedit-SourceCharset: UTF-8\n"
18
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
19
+ "X-Poedit-SearchPath-0: .\n"
20
+ "X-Loco-Parser: loco_parse_po"
21
+
22
+ #: Puc/v4p1/Plugin/UpdateChecker.php:358
23
+ msgid "Check for updates"
24
+ msgstr "Zkontrolovat aktualizace"
25
+
26
+ #: Puc/v4p1/Plugin/UpdateChecker.php:405
27
+ #, php-format
28
+ msgctxt "the plugin title"
29
+ msgid "The %s plugin is up to date."
30
+ msgstr "Plugin %s je aktuální."
31
+
32
+ #: Puc/v4p1/Plugin/UpdateChecker.php:407
33
+ #, php-format
34
+ msgctxt "the plugin title"
35
+ msgid "A new version of the %s plugin is available."
36
+ msgstr "Nová verze pluginu %s je dostupná."
37
+
38
+ #: Puc/v4p1/Plugin/UpdateChecker.php:409
39
+ #, php-format
40
+ msgid "Unknown update checker status \"%s\""
41
+ msgstr "Neznámý status kontroly aktualizací \"%s\""
42
+
43
+ #: Puc/v4p1/Vcs/PluginUpdateChecker.php:83
44
+ msgid "There is no changelog available."
45
+ msgstr "Changelog není dostupný."
lib/plugin-update-checker/languages/plugin-update-checker-da_DK.mo ADDED
Binary file
lib/plugin-update-checker/languages/plugin-update-checker-da_DK.po ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2017-05-20 10:53+0300\n"
5
+ "PO-Revision-Date: 2017-10-17 11:07+0200\n"
6
+ "Last-Translator: Mikk3lRo\n"
7
+ "Language-Team: Mikk3lRo\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 2.0.4\n"
12
+ "X-Poedit-Basepath: ..\n"
13
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
14
+ "X-Poedit-SourceCharset: UTF-8\n"
15
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
16
+ "Language: da_DK\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: Puc/v4p1/Plugin/UpdateChecker.php:358
20
+ msgid "Check for updates"
21
+ msgstr "Undersøg for opdateringer"
22
+
23
+ #: Puc/v4p1/Plugin/UpdateChecker.php:405
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "Plugin'et %s er allerede opdateret."
28
+
29
+ #: Puc/v4p1/Plugin/UpdateChecker.php:407
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "En ny version af plugin'et %s er tilgængelig."
34
+
35
+ #: Puc/v4p1/Plugin/UpdateChecker.php:409
36
+ #, php-format
37
+ msgid "Unknown update checker status \"%s\""
38
+ msgstr "Ukendt opdateringsstatus: \"%s\""
39
+
40
+ #: Puc/v4p1/Vcs/PluginUpdateChecker.php:83
41
+ msgid "There is no changelog available."
42
+ msgstr "Der er ingen ændringslog tilgængelig."
lib/plugin-update-checker/languages/plugin-update-checker-de_DE.mo ADDED
Binary file
lib/plugin-update-checker/languages/plugin-update-checker-de_DE.po ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2016-06-29 20:21+0100\n"
5
+ "PO-Revision-Date: 2016-06-29 20:23+0100\n"
6
+ "Last-Translator: Igor Lückel <info@igorlueckel.de>\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.8.1\n"
12
+ "X-Poedit-Basepath: ..\n"
13
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
14
+ "X-Poedit-SourceCharset: UTF-8\n"
15
+ "X-Poedit-KeywordsList: __;_e\n"
16
+ "Language: de_DE\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: github-checker.php:137
20
+ msgid "There is no changelog available."
21
+ msgstr "Es ist keine Liste von Programmänderungen verfügbar."
22
+
23
+ #: plugin-update-checker.php:852
24
+ msgid "Check for updates"
25
+ msgstr "Nach Update suchen"
26
+
27
+ #: plugin-update-checker.php:896
28
+ msgid "This plugin is up to date."
29
+ msgstr "Das Plugin ist aktuell."
30
+
31
+ #: plugin-update-checker.php:898
32
+ msgid "A new version of this plugin is available."
33
+ msgstr "Es ist eine neue Version für das Plugin verfügbar."
34
+
35
+ #: plugin-update-checker.php:900
36
+ #, php-format
37
+ msgid "Unknown update checker status \"%s\""
38
+ msgstr "Unbekannter Update Status \"%s\""
lib/plugin-update-checker/languages/plugin-update-checker-es_ES.mo ADDED
Binary file
lib/plugin-update-checker/languages/plugin-update-checker-es_ES.po ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2017-11-24 17:02+0200\n"
5
+ "PO-Revision-Date: 2019-09-25 18:17+0200\n"
6
+ "Language-Team: \n"
7
+ "MIME-Version: 1.0\n"
8
+ "Content-Type: text/plain; charset=UTF-8\n"
9
+ "Content-Transfer-Encoding: 8bit\n"
10
+ "X-Generator: Poedit 2.2.3\n"
11
+ "X-Poedit-Basepath: ..\n"
12
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
13
+ "X-Poedit-SourceCharset: UTF-8\n"
14
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
15
+ "Last-Translator: \n"
16
+ "Language: es_ES\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: Puc/v4p3/Plugin/UpdateChecker.php:395
20
+ msgid "Check for updates"
21
+ msgstr "Comprobar si hay actualizaciones"
22
+
23
+ #: Puc/v4p3/Plugin/UpdateChecker.php:548
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "El plugin %s está actualizado."
28
+
29
+ #: Puc/v4p3/Plugin/UpdateChecker.php:550
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "Una nueva versión del %s plugin está disponible."
34
+
35
+ #: Puc/v4p3/Plugin/UpdateChecker.php:552
36
+ #, php-format
37
+ msgctxt "the plugin title"
38
+ msgid "Could not determine if updates are available for %s."
39
+ msgstr "No se pudo determinar si hay actualizaciones disponibles para %s."
40
+
41
+ #: Puc/v4p3/Plugin/UpdateChecker.php:558
42
+ #, php-format
43
+ msgid "Unknown update checker status \"%s\""
44
+ msgstr "Estado del comprobador de actualización desconocido \"%s\""
45
+
46
+ #: Puc/v4p3/Vcs/PluginUpdateChecker.php:95
47
+ msgid "There is no changelog available."
48
+ msgstr "No hay registro de cambios disponible."
lib/plugin-update-checker/languages/plugin-update-checker-fa_IR.mo ADDED
Binary file
lib/plugin-update-checker/languages/plugin-update-checker-fa_IR.po ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2016-02-17 14:21+0100\n"
5
+ "PO-Revision-Date: 2016-10-28 14:30+0330\n"
6
+ "Last-Translator: studio RVOLA <hello@rvola.com>\n"
7
+ "Language-Team: Pro Style <info@prostyle.ir>\n"
8
+ "Language: fa_IR\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.8\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "Plural-Forms: nplurals=2; plural=(n > 1);\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-KeywordsList: __;_e\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: github-checker.php:120
20
+ msgid "There is no changelog available."
21
+ msgstr "شرحی برای تغییرات یافت نشد"
22
+
23
+ #: plugin-update-checker.php:637
24
+ msgid "Check for updates"
25
+ msgstr "بررسی برای بروزرسانی "
26
+
27
+ #: plugin-update-checker.php:681
28
+ msgid "This plugin is up to date."
29
+ msgstr "شما از آخرین نسخه استفاده میکنید . به‌روز باشید"
30
+
31
+ #: plugin-update-checker.php:683
32
+ msgid "A new version of this plugin is available."
33
+ msgstr "نسخه جدیدی برای افزونه ارائه شده است ."
34
+
35
+ #: plugin-update-checker.php:685
36
+ #, php-format
37
+ msgid "Unknown update checker status \"%s\""
38
+ msgstr "وضعیت ناشناخته برای بروزرسانی \"%s\""
lib/plugin-update-checker/languages/plugin-update-checker-fr_CA.mo ADDED
Binary file
lib/plugin-update-checker/languages/plugin-update-checker-fr_CA.po ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2017-11-24 17:02+0200\n"
5
+ "PO-Revision-Date: 2018-02-12 10:32-0500\n"
6
+ "Language-Team: \n"
7
+ "MIME-Version: 1.0\n"
8
+ "Content-Type: text/plain; charset=UTF-8\n"
9
+ "Content-Transfer-Encoding: 8bit\n"
10
+ "X-Generator: Poedit 2.0.4\n"
11
+ "X-Poedit-Basepath: ..\n"
12
+ "Plural-Forms: nplurals=2; plural=(n > 1);\n"
13
+ "X-Poedit-SourceCharset: UTF-8\n"
14
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
15
+ "Last-Translator: Eric Gagnon <eric.gagnon@banq.qc.ca>\n"
16
+ "Language: fr_CA\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: Puc/v4p3/Plugin/UpdateChecker.php:395
20
+ msgid "Check for updates"
21
+ msgstr "Vérifier les mises à jour"
22
+
23
+ #: Puc/v4p3/Plugin/UpdateChecker.php:548
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "L’extension %s est à jour."
28
+
29
+ #: Puc/v4p3/Plugin/UpdateChecker.php:550
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "Une nouvelle version de l’extension %s est disponible."
34
+
35
+ #: Puc/v4p3/Plugin/UpdateChecker.php:552
36
+ #, php-format
37
+ msgctxt "the plugin title"
38
+ msgid "Could not determine if updates are available for %s."
39
+ msgstr "Impossible de déterminer si une mise à jour est disponible pour \"%s\""
40
+
41
+ #: Puc/v4p3/Plugin/UpdateChecker.php:558
42
+ #, php-format
43
+ msgid "Unknown update checker status \"%s\""
44
+ msgstr "Un problème inconnu est survenu \"%s\""
45
+
46
+ #: Puc/v4p3/Vcs/PluginUpdateChecker.php:95
47
+ msgid "There is no changelog available."
48
+ msgstr "Il n’y a aucun journal de mise à jour disponible."
lib/plugin-update-checker/languages/plugin-update-checker-fr_FR.mo ADDED
Binary file
lib/plugin-update-checker/languages/plugin-update-checker-fr_FR.po ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2017-07-07 14:53+0200\n"
5
+ "PO-Revision-Date: 2017-07-07 14:54+0200\n"
6
+ "Language-Team: studio RVOLA <http://www.rvola.com>\n"
7
+ "Language: fr_FR\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 2.0.2\n"
12
+ "X-Poedit-Basepath: ..\n"
13
+ "Plural-Forms: nplurals=2; plural=(n > 1);\n"
14
+ "X-Poedit-SourceCharset: UTF-8\n"
15
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
16
+ "Last-Translator: Nicolas GEHIN\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: Puc/v4p1/Plugin/UpdateChecker.php:358
20
+ msgid "Check for updates"
21
+ msgstr "Vérifier les mises à jour"
22
+
23
+ #: Puc/v4p1/Plugin/UpdateChecker.php:405
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "L’extension %s est à jour."
28
+
29
+ #: Puc/v4p1/Plugin/UpdateChecker.php:407
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "Une nouvelle version de l’extension %s est disponible."
34
+
35
+ #: Puc/v4p1/Plugin/UpdateChecker.php:409
36
+ #, php-format
37
+ msgid "Unknown update checker status \"%s\""
38
+ msgstr "Un problème inconnu est survenu \"%s\""
39
+
40
+ #: Puc/v4p1/Vcs/PluginUpdateChecker.php:85
41
+ msgid "There is no changelog available."
42
+ msgstr "Il n’y a aucun journal de mise à jour disponible."
lib/plugin-update-checker/languages/plugin-update-checker-hu_HU.mo ADDED
Binary file
lib/plugin-update-checker/languages/plugin-update-checker-hu_HU.po ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2016-01-11 21:23+0100\n"
5
+ "PO-Revision-Date: 2016-01-11 21:25+0100\n"
6
+ "Last-Translator: Tamás András Horváth <htomy92@gmail.com>\n"
7
+ "Language-Team: \n"
8
+ "Language: hu_HU\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.6\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-KeywordsList: __;_e\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: github-checker.php:137
20
+ msgid "There is no changelog available."
21
+ msgstr "Nem érhető el a changelog."
22
+
23
+ #: plugin-update-checker.php:852
24
+ msgid "Check for updates"
25
+ msgstr "Frissítés ellenőrzése"
26
+
27
+ #: plugin-update-checker.php:896
28
+ msgid "This plugin is up to date."
29
+ msgstr "Ez a plugin naprakész."
30
+
31
+ #: plugin-update-checker.php:898
32
+ msgid "A new version of this plugin is available."
33
+ msgstr "Új verzió érhető el a kiegészítőhöz"
34
+
35
+ #: plugin-update-checker.php:900
36
+ #, php-format
37
+ msgid "Unknown update checker status \"%s\""
38
+ msgstr "Ismeretlen a frissítés ellenőrző státusza \"%s\""
39
+
40
+ #~ msgid "Every %d hours"
41
+ #~ msgstr "Minden %d órában"
lib/plugin-update-checker/languages/plugin-update-checker-it_IT.mo ADDED
Binary file
lib/plugin-update-checker/languages/plugin-update-checker-it_IT.po ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2016-06-29 20:21+0100\n"
5
+ "PO-Revision-Date: 2017-01-15 12:24+0100\n"
6
+ "Last-Translator: Igor Lückel <info@igorlueckel.de>\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.5\n"
12
+ "X-Poedit-Basepath: ..\n"
13
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
14
+ "X-Poedit-SourceCharset: UTF-8\n"
15
+ "X-Poedit-KeywordsList: __;_e\n"
16
+ "Language: de_DE\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: github-checker.php:137
20
+ msgid "There is no changelog available."
21
+ msgstr "Non c'è alcuna sezione di aggiornamento disponibile"
22
+
23
+ #: plugin-update-checker.php:852
24
+ msgid "Check for updates"
25
+ msgstr "Verifica aggiornamenti"
26
+
27
+ #: plugin-update-checker.php:896
28
+ msgid "This plugin is up to date."
29
+ msgstr "Il plugin è aggiornato"
30
+
31
+ #: plugin-update-checker.php:898
32
+ msgid "A new version of this plugin is available."
33
+ msgstr "Una nuova versione del plugin è disponibile"
34
+
35
+ #: plugin-update-checker.php:900
36
+ #, php-format
37
+ msgid "Unknown update checker status \"%s\""
38
+ msgstr "Si è verificato un problema sconosciuto \"%s\""
lib/plugin-update-checker/languages/plugin-update-checker-ja.mo ADDED
Binary file
lib/plugin-update-checker/languages/plugin-update-checker-ja.po ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: \n"
4
+ "POT-Creation-Date: 2019-07-15 17:07+0900\n"
5
+ "PO-Revision-Date: 2019-07-15 17:12+0900\n"
6
+ "Last-Translator: tak <tak7725@gmail.com>\n"
7
+ "Language-Team: \n"
8
+ "Language: ja_JP\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 2.2.3\n"
13
+ "X-Poedit-Basepath: ../../../../../../Applications/XAMPP/xamppfiles/htdocs/"
14
+ "kisagai/wordpress/wp-content/plugins/simple-stripe-gateway/Puc\n"
15
+ "Plural-Forms: nplurals=1; plural=0;\n"
16
+ "X-Poedit-KeywordsList: __;_x:1,2c\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: v4p7/Plugin/Ui.php:54
20
+ msgid "View details"
21
+ msgstr "詳細を表示"
22
+
23
+ #: v4p7/Plugin/Ui.php:77
24
+ #, php-format
25
+ msgid "More information about %s"
26
+ msgstr "%sについての詳細"
27
+
28
+ #: v4p7/Plugin/Ui.php:128
29
+ msgid "Check for updates"
30
+ msgstr "アップデートを確認"
31
+
32
+ #: v4p7/Plugin/Ui.php:213
33
+ #, php-format
34
+ msgctxt "the plugin title"
35
+ msgid "The %s plugin is up to date."
36
+ msgstr "%s プラグインは、最新バージョンです。"
37
+
38
+ #: v4p7/Plugin/Ui.php:215
39
+ #, php-format
40
+ msgctxt "the plugin title"
41
+ msgid "A new version of the %s plugin is available."
42
+ msgstr "%s プラグインの最新バージョンがあります。"
43
+
44
+ #: v4p7/Plugin/Ui.php:217
45
+ #, php-format
46
+ msgctxt "the plugin title"
47
+ msgid "Could not determine if updates are available for %s."
48
+ msgstr "%s のアップデートがあるかどうかを判断できませんでした。"
49
+
50
+ #: v4p7/Plugin/Ui.php:223
51
+ #, php-format
52
+ msgid "Unknown update checker status \"%s\""
53
+ msgstr "バージョンアップの確認で想定外の状態になりました。ステータス:”%s”"
54
+
55
+ #: v4p7/Vcs/PluginUpdateChecker.php:98
56
+ msgid "There is no changelog available."
57
+ msgstr "更新履歴はありません。"
lib/plugin-update-checker/languages/plugin-update-checker-nl_BE.mo ADDED
Binary file
lib/plugin-update-checker/languages/plugin-update-checker-nl_BE.po ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2018-03-25 18:15+0200\n"
5
+ "PO-Revision-Date: 2018-03-25 18:32+0200\n"
6
+ "Language-Team: \n"
7
+ "MIME-Version: 1.0\n"
8
+ "Content-Type: text/plain; charset=UTF-8\n"
9
+ "Content-Transfer-Encoding: 8bit\n"
10
+ "X-Generator: Poedit 1.8.7.1\n"
11
+ "X-Poedit-Basepath: ..\n"
12
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
13
+ "X-Poedit-SourceCharset: UTF-8\n"
14
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
15
+ "Last-Translator: Frank Goossens <frank@optimizingmatters.com>\n"
16
+ "Language: nl_BE\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: Puc/v4p3/Plugin/UpdateChecker.php:395
20
+ msgid "Check for updates"
21
+ msgstr "Controleer op nieuwe versies"
22
+
23
+ #: Puc/v4p3/Plugin/UpdateChecker.php:548
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "De meest recente %s versie is geïnstalleerd."
28
+
29
+ #: Puc/v4p3/Plugin/UpdateChecker.php:550
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "Er is een nieuwe versie van %s beschikbaar."
34
+
35
+ #: Puc/v4p3/Plugin/UpdateChecker.php:552
36
+ #, php-format
37
+ msgctxt "the plugin title"
38
+ msgid "Could not determine if updates are available for %s."
39
+ msgstr "Kon niet bepalen of er nieuwe versie van %s beschikbaar is."
40
+
41
+ #: Puc/v4p3/Plugin/UpdateChecker.php:558
42
+ #, php-format
43
+ msgid "Unknown update checker status \"%s\""
44
+ msgstr "Ongekende status bij controle op nieuwe versie: \"%s\""
45
+
46
+ #: Puc/v4p3/Vcs/PluginUpdateChecker.php:95
47
+ msgid "There is no changelog available."
48
+ msgstr "Er is geen changelog beschikbaar."
lib/plugin-update-checker/languages/plugin-update-checker-nl_NL.mo ADDED
Binary file
lib/plugin-update-checker/languages/plugin-update-checker-nl_NL.po ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2018-03-25 18:15+0200\n"
5
+ "PO-Revision-Date: 2018-03-25 18:32+0200\n"
6
+ "Language-Team: \n"
7
+ "MIME-Version: 1.0\n"
8
+ "Content-Type: text/plain; charset=UTF-8\n"
9
+ "Content-Transfer-Encoding: 8bit\n"
10
+ "X-Generator: Poedit 1.8.7.1\n"
11
+ "X-Poedit-Basepath: ..\n"
12
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
13
+ "X-Poedit-SourceCharset: UTF-8\n"
14
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
15
+ "Last-Translator: Frank Goossens <frank@optimizingmatters.com>\n"
16
+ "Language: nl_NL\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: Puc/v4p3/Plugin/UpdateChecker.php:395
20
+ msgid "Check for updates"
21
+ msgstr "Controleer op nieuwe versies"
22
+
23
+ #: Puc/v4p3/Plugin/UpdateChecker.php:548
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "De meest recente %s versie is geïnstalleerd."
28
+
29
+ #: Puc/v4p3/Plugin/UpdateChecker.php:550
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "Er is een nieuwe versie van %s beschikbaar."
34
+
35
+ #: Puc/v4p3/Plugin/UpdateChecker.php:552
36
+ #, php-format
37
+ msgctxt "the plugin title"
38
+ msgid "Could not determine if updates are available for %s."
39
+ msgstr "Kon niet bepalen of er nieuwe versie van %s beschikbaar is."
40
+
41
+ #: Puc/v4p3/Plugin/UpdateChecker.php:558
42
+ #, php-format
43
+ msgid "Unknown update checker status \"%s\""
44
+ msgstr "Ongekende status bij controle op nieuwe versie: \"%s\""
45
+
46
+ #: Puc/v4p3/Vcs/PluginUpdateChecker.php:95
47
+ msgid "There is no changelog available."
48
+ msgstr "Er is geen changelog beschikbaar."
lib/plugin-update-checker/languages/plugin-update-checker-pt_BR.mo ADDED
Binary file
lib/plugin-update-checker/languages/plugin-update-checker-pt_BR.po ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2017-05-19 15:41-0300\n"
5
+ "PO-Revision-Date: 2017-05-19 15:42-0300\n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: \n"
8
+ "Language: pt_BR\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.8\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "Plural-Forms: nplurals=2; plural=(n > 1);\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-KeywordsList: __;_e;_x;_x:1,2c\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: Puc/v4p1/Plugin/UpdateChecker.php:358
20
+ msgid "Check for updates"
21
+ msgstr "Verificar Atualizações"
22
+
23
+ #: Puc/v4p1/Plugin/UpdateChecker.php:401 Puc/v4p1/Plugin/UpdateChecker.php:406
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "O plugin %s já está na sua versão mais recente."
28
+
29
+ #: Puc/v4p1/Plugin/UpdateChecker.php:408
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "Há uma nova versão para o plugin %s disponível para download."
34
+
35
+ #: Puc/v4p1/Plugin/UpdateChecker.php:410
36
+ #, php-format
37
+ msgid "Unknown update checker status \"%s\""
38
+ msgstr "Status \"%s\" desconhecido."
39
+
40
+ #: Puc/v4p1/Vcs/PluginUpdateChecker.php:83
41
+ msgid "There is no changelog available."
42
+ msgstr "Não há um changelog disponível."
43
+
44
+ #~ msgid "The %s plugin is up to date."
45
+ #~ msgstr "O plugin %s já está na sua versão mais recente."
46
+
47
+ #~ msgid "A new version of the %s plugin is available."
48
+ #~ msgstr "Há uma nova versão para o plugin %s disponível para download."
lib/plugin-update-checker/languages/plugin-update-checker-sl_SI.mo ADDED
Binary file
lib/plugin-update-checker/languages/plugin-update-checker-sl_SI.po ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2017-11-24 17:02+0200\n"
5
+ "PO-Revision-Date: 2018-10-27 20:36+0200\n"
6
+ "Language-Team: \n"
7
+ "MIME-Version: 1.0\n"
8
+ "Content-Type: text/plain; charset=UTF-8\n"
9
+ "Content-Transfer-Encoding: 8bit\n"
10
+ "X-Generator: Poedit 2.2\n"
11
+ "X-Poedit-Basepath: ..\n"
12
+ "Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100>=3 && n%100<=4 ? 2 : 3);\n"
13
+ "X-Poedit-SourceCharset: UTF-8\n"
14
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
15
+ "Last-Translator: Igor Funa\n"
16
+ "Language: sl_SI\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: Puc/v4p3/Plugin/UpdateChecker.php:395
20
+ msgid "Check for updates"
21
+ msgstr "Preveri posodobitve"
22
+
23
+ #: Puc/v4p3/Plugin/UpdateChecker.php:548
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "Vtičnik %s je že posodobljen."
28
+
29
+ #: Puc/v4p3/Plugin/UpdateChecker.php:550
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "Nova različica vtičnika %s je na razpolago."
34
+
35
+ #: Puc/v4p3/Plugin/UpdateChecker.php:552
36
+ #, php-format
37
+ msgctxt "the plugin title"
38
+ msgid "Could not determine if updates are available for %s."
39
+ msgstr "Ne morem ugotoviti če se za vtičnik %s na razpolago posodobitve."
40
+
41
+ #: Puc/v4p3/Plugin/UpdateChecker.php:558
42
+ #, php-format
43
+ msgid "Unknown update checker status \"%s\""
44
+ msgstr "Neznan status preverjanja posodobitev za \"%s\""
45
+
46
+ #: Puc/v4p3/Vcs/PluginUpdateChecker.php:95
47
+ msgid "There is no changelog available."
48
+ msgstr "Dnevnik sprememb ni na razpolago."
lib/plugin-update-checker/languages/plugin-update-checker-sv_SE.mo ADDED
Binary file
lib/plugin-update-checker/languages/plugin-update-checker-sv_SE.po ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2017-05-20 10:53+0300\n"
5
+ "PO-Revision-Date: 2017-10-16 15:02+0200\n"
6
+ "Language-Team: \n"
7
+ "MIME-Version: 1.0\n"
8
+ "Content-Type: text/plain; charset=UTF-8\n"
9
+ "Content-Transfer-Encoding: 8bit\n"
10
+ "X-Generator: Poedit 2.0.4\n"
11
+ "X-Poedit-Basepath: ..\n"
12
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
13
+ "X-Poedit-SourceCharset: UTF-8\n"
14
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
15
+ "Last-Translator: \n"
16
+ "Language: sv_SE\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: Puc/v4p1/Plugin/UpdateChecker.php:358
20
+ msgid "Check for updates"
21
+ msgstr "Sök efter uppdateringar"
22
+
23
+ #: Puc/v4p1/Plugin/UpdateChecker.php:405
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "Tillägget %s är uppdaterat."
28
+
29
+ #: Puc/v4p1/Plugin/UpdateChecker.php:407
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "Det finns en ny version av tillägget %s."
34
+
35
+ #: Puc/v4p1/Plugin/UpdateChecker.php:409
36
+ #, php-format
37
+ msgid "Unknown update checker status \"%s\""
38
+ msgstr "Okänd status för kontroll av uppdatering “%s”"
39
+
40
+ #: Puc/v4p1/Vcs/PluginUpdateChecker.php:83
41
+ msgid "There is no changelog available."
42
+ msgstr "Det finns ingen ändringslogg tillgänglig."
lib/plugin-update-checker/languages/plugin-update-checker.pot ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #, fuzzy
2
+ msgid ""
3
+ msgstr ""
4
+ "Project-Id-Version: plugin-update-checker\n"
5
+ "POT-Creation-Date: 2017-11-24 17:02+0200\n"
6
+ "PO-Revision-Date: 2016-01-10 20:59+0100\n"
7
+ "Last-Translator: Tamás András Horváth <htomy92@gmail.com>\n"
8
+ "Language-Team: \n"
9
+ "Language: en_US\n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Generator: Poedit 2.0.4\n"
14
+ "X-Poedit-Basepath: ..\n"
15
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
18
+ "X-Poedit-SearchPath-0: .\n"
19
+
20
+ #: Puc/v4p3/Plugin/UpdateChecker.php:395
21
+ msgid "Check for updates"
22
+ msgstr ""
23
+
24
+ #: Puc/v4p3/Plugin/UpdateChecker.php:548
25
+ #, php-format
26
+ msgctxt "the plugin title"
27
+ msgid "The %s plugin is up to date."
28
+ msgstr ""
29
+
30
+ #: Puc/v4p3/Plugin/UpdateChecker.php:550
31
+ #, php-format
32
+ msgctxt "the plugin title"
33
+ msgid "A new version of the %s plugin is available."
34
+ msgstr ""
35
+
36
+ #: Puc/v4p3/Plugin/UpdateChecker.php:552
37
+ #, php-format
38
+ msgctxt "the plugin title"
39
+ msgid "Could not determine if updates are available for %s."
40
+ msgstr ""
41
+
42
+ #: Puc/v4p3/Plugin/UpdateChecker.php:558
43
+ #, php-format
44
+ msgid "Unknown update checker status \"%s\""
45
+ msgstr ""
46
+
47
+ #: Puc/v4p3/Vcs/PluginUpdateChecker.php:95
48
+ msgid "There is no changelog available."
49
+ msgstr ""
lib/plugin-update-checker/license.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ Copyright (c) 2017 Jānis Elsts
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
lib/plugin-update-checker/load-v4p8.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require dirname(__FILE__) . '/Puc/v4p8/Autoloader.php';
3
+ new Puc_v4p8_Autoloader();
4
+
5
+ require dirname(__FILE__) . '/Puc/v4p8/Factory.php';
6
+ require dirname(__FILE__) . '/Puc/v4/Factory.php';
7
+
8
+ //Register classes defined in this version with the factory.
9
+ foreach (
10
+ array(
11
+ 'Plugin_UpdateChecker' => 'Puc_v4p8_Plugin_UpdateChecker',
12
+ 'Theme_UpdateChecker' => 'Puc_v4p8_Theme_UpdateChecker',
13
+
14
+ 'Vcs_PluginUpdateChecker' => 'Puc_v4p8_Vcs_PluginUpdateChecker',
15
+ 'Vcs_ThemeUpdateChecker' => 'Puc_v4p8_Vcs_ThemeUpdateChecker',
16
+
17
+ 'GitHubApi' => 'Puc_v4p8_Vcs_GitHubApi',
18
+ 'BitBucketApi' => 'Puc_v4p8_Vcs_BitBucketApi',
19
+ 'GitLabApi' => 'Puc_v4p8_Vcs_GitLabApi',
20
+ )
21
+ as $pucGeneralClass => $pucVersionedClass
22
+ ) {
23
+ Puc_v4_Factory::addVersion($pucGeneralClass, $pucVersionedClass, '4.8');
24
+ //Also add it to the minor-version factory in case the major-version factory
25
+ //was already defined by another, older version of the update checker.
26
+ Puc_v4p8_Factory::addVersion($pucGeneralClass, $pucVersionedClass, '4.8');
27
+ }
28
+
lib/plugin-update-checker/plugin-update-checker.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Update Checker Library 4.8
4
+ * http://w-shadow.com/
5
+ *
6
+ * Copyright 2019 Janis Elsts
7
+ * Released under the MIT license. See license.txt for details.
8
+ */
9
+
10
+ require dirname(__FILE__) . '/load-v4p8.php';
lib/plugin-update-checker/vendor/Parsedown.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Parsedown', false) ) {
3
+ //Load the Parsedown version that's compatible with the current PHP version.
4
+ if ( version_compare(PHP_VERSION, '5.3.0', '>=') ) {
5
+ require __DIR__ . '/ParsedownModern.php';
6
+ } else {
7
+ require __DIR__ . '/ParsedownLegacy.php';
8
+ }
9
+ }
lib/plugin-update-checker/vendor/ParsedownLegacy.php ADDED
@@ -0,0 +1,1535 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ #
4
+ #
5
+ # Parsedown
6
+ # http://parsedown.org
7
+ #
8
+ # (c) Emanuil Rusev
9
+ # http://erusev.com
10
+ #
11
+ # For the full license information, view the LICENSE file that was distributed
12
+ # with this source code.
13
+ #
14
+ #
15
+
16
+ class Parsedown
17
+ {
18
+ # ~
19
+
20
+ const version = '1.5.0';
21
+
22
+ # ~
23
+
24
+ function text($text)
25
+ {
26
+ # make sure no definitions are set
27
+ $this->DefinitionData = array();
28
+
29
+ # standardize line breaks
30
+ $text = str_replace(array("\r\n", "\r"), "\n", $text);
31
+
32
+ # remove surrounding line breaks
33
+ $text = trim($text, "\n");
34
+
35
+ # split text into lines
36
+ $lines = explode("\n", $text);
37
+
38
+ # iterate through lines to identify blocks
39
+ $markup = $this->lines($lines);
40
+
41
+ # trim line breaks
42
+ $markup = trim($markup, "\n");
43
+
44
+ return $markup;
45
+ }
46
+
47
+ #
48
+ # Setters
49
+ #
50
+
51
+ function setBreaksEnabled($breaksEnabled)
52
+ {
53
+ $this->breaksEnabled = $breaksEnabled;
54
+
55
+ return $this;
56
+ }
57
+
58
+ protected $breaksEnabled;
59
+
60
+ function setMarkupEscaped($markupEscaped)
61
+ {
62
+ $this->markupEscaped = $markupEscaped;
63
+
64
+ return $this;
65
+ }
66
+
67
+ protected $markupEscaped;
68
+
69
+ function setUrlsLinked($urlsLinked)
70
+ {
71
+ $this->urlsLinked = $urlsLinked;
72
+
73
+ return $this;
74
+ }
75
+
76
+ protected $urlsLinked = true;
77
+
78
+ #
79
+ # Lines
80
+ #
81
+
82
+ protected $BlockTypes = array(
83
+ '#' => array('Header'),
84
+ '*' => array('Rule', 'List'),
85
+ '+' => array('List'),
86
+ '-' => array('SetextHeader', 'Table', 'Rule', 'List'),
87
+ '0' => array('List'),
88
+ '1' => array('List'),
89
+ '2' => array('List'),
90
+ '3' => array('List'),
91
+ '4' => array('List'),
92
+ '5' => array('List'),
93
+ '6' => array('List'),
94
+ '7' => array('List'),
95
+ '8' => array('List'),
96
+ '9' => array('List'),
97
+ ':' => array('Table'),
98
+ '<' => array('Comment', 'Markup'),
99
+ '=' => array('SetextHeader'),
100
+ '>' => array('Quote'),
101
+ '[' => array('Reference'),
102
+ '_' => array('Rule'),
103
+ '`' => array('FencedCode'),
104
+ '|' => array('Table'),
105
+ '~' => array('FencedCode'),
106
+ );
107
+
108
+ # ~
109
+
110
+ protected $DefinitionTypes = array(
111
+ '[' => array('Reference'),
112
+ );
113
+
114
+ # ~
115
+
116
+ protected $unmarkedBlockTypes = array(
117
+ 'Code',
118
+ );
119
+
120
+ #
121
+ # Blocks
122
+ #
123
+
124
+ private function lines(array $lines)
125
+ {
126
+ $CurrentBlock = null;
127
+
128
+ foreach ($lines as $line)
129
+ {
130
+ if (chop($line) === '')
131
+ {
132
+ if (isset($CurrentBlock))
133
+ {
134
+ $CurrentBlock['interrupted'] = true;
135
+ }
136
+
137
+ continue;
138
+ }
139
+
140
+ if (strpos($line, "\t") !== false)
141
+ {
142
+ $parts = explode("\t", $line);
143
+
144
+ $line = $parts[0];
145
+
146
+ unset($parts[0]);
147
+
148
+ foreach ($parts as $part)
149
+ {
150
+ $shortage = 4 - mb_strlen($line, 'utf-8') % 4;
151
+
152
+ $line .= str_repeat(' ', $shortage);
153
+ $line .= $part;
154
+ }
155
+ }
156
+
157
+ $indent = 0;
158
+
159
+ while (isset($line[$indent]) and $line[$indent] === ' ')
160
+ {
161
+ $indent ++;
162
+ }
163
+
164
+ $text = $indent > 0 ? substr($line, $indent) : $line;
165
+
166
+ # ~
167
+
168
+ $Line = array('body' => $line, 'indent' => $indent, 'text' => $text);
169
+
170
+ # ~
171
+
172
+ if (isset($CurrentBlock['incomplete']))
173
+ {
174
+ $Block = $this->{'block'.$CurrentBlock['type'].'Continue'}($Line, $CurrentBlock);
175
+
176
+ if (isset($Block))
177
+ {
178
+ $CurrentBlock = $Block;
179
+
180
+ continue;
181
+ }
182
+ else
183
+ {
184
+ if (method_exists($this, 'block'.$CurrentBlock['type'].'Complete'))
185
+ {
186
+ $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
187
+ }
188
+
189
+ unset($CurrentBlock['incomplete']);
190
+ }
191
+ }
192
+
193
+ # ~
194
+
195
+ $marker = $text[0];
196
+
197
+ # ~
198
+
199
+ $blockTypes = $this->unmarkedBlockTypes;
200
+
201
+ if (isset($this->BlockTypes[$marker]))
202
+ {
203
+ foreach ($this->BlockTypes[$marker] as $blockType)
204
+ {
205
+ $blockTypes []= $blockType;
206
+ }
207
+ }
208
+
209
+ #
210
+ # ~
211
+
212
+ foreach ($blockTypes as $blockType)
213
+ {
214
+ $Block = $this->{'block'.$blockType}($Line, $CurrentBlock);
215
+
216
+ if (isset($Block))
217
+ {
218
+ $Block['type'] = $blockType;
219
+
220
+ if ( ! isset($Block['identified']))
221
+ {
222
+ $Blocks []= $CurrentBlock;
223
+
224
+ $Block['identified'] = true;
225
+ }
226
+
227
+ if (method_exists($this, 'block'.$blockType.'Continue'))
228
+ {
229
+ $Block['incomplete'] = true;
230
+ }
231
+
232
+ $CurrentBlock = $Block;
233
+
234
+ continue 2;
235
+ }
236
+ }
237
+
238
+ # ~
239
+
240
+ if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted']))
241
+ {
242
+ $CurrentBlock['element']['text'] .= "\n".$text;
243
+ }
244
+ else
245
+ {
246
+ $Blocks []= $CurrentBlock;
247
+
248
+ $CurrentBlock = $this->paragraph($Line);
249
+
250
+ $CurrentBlock['identified'] = true;
251
+ }
252
+ }
253
+
254
+ # ~
255
+
256
+ if (isset($CurrentBlock['incomplete']) and method_exists($this, 'block'.$CurrentBlock['type'].'Complete'))
257
+ {
258
+ $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
259
+ }
260
+
261
+ # ~
262
+
263
+ $Blocks []= $CurrentBlock;
264
+
265
+ unset($Blocks[0]);
266
+
267
+ # ~
268
+
269
+ $markup = '';
270
+
271
+ foreach ($Blocks as $Block)
272
+ {
273
+ if (isset($Block['hidden']))
274
+ {
275
+ continue;
276
+ }
277
+
278
+ $markup .= "\n";
279
+ $markup .= isset($Block['markup']) ? $Block['markup'] : $this->element($Block['element']);
280
+ }
281
+
282
+ $markup .= "\n";
283
+
284
+ # ~
285
+
286
+ return $markup;
287
+ }
288
+
289
+ #
290
+ # Code
291
+
292
+ protected function blockCode($Line, $Block = null)
293
+ {
294
+ if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted']))
295
+ {
296
+ return;
297
+ }
298
+
299
+ if ($Line['indent'] >= 4)
300
+ {
301
+ $text = substr($Line['body'], 4);
302
+
303
+ $Block = array(
304
+ 'element' => array(
305
+ 'name' => 'pre',
306
+ 'handler' => 'element',
307
+ 'text' => array(
308
+ 'name' => 'code',
309
+ 'text' => $text,
310
+ ),
311
+ ),
312
+ );
313
+
314
+ return $Block;
315
+ }
316
+ }
317
+
318
+ protected function blockCodeContinue($Line, $Block)
319
+ {
320
+ if ($Line['indent'] >= 4)
321
+ {
322
+ if (isset($Block['interrupted']))
323
+ {
324
+ $Block['element']['text']['text'] .= "\n";
325
+
326
+ unset($Block['interrupted']);
327
+ }
328
+
329
+ $Block['element']['text']['text'] .= "\n";
330
+
331
+ $text = substr($Line['body'], 4);
332
+
333
+ $Block['element']['text']['text'] .= $text;
334
+
335
+ return $Block;
336
+ }
337
+ }
338
+
339
+ protected function blockCodeComplete($Block)
340
+ {
341
+ $text = $Block['element']['text']['text'];
342
+
343
+ $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
344
+
345
+ $Block['element']['text']['text'] = $text;
346
+
347
+ return $Block;
348
+ }
349
+
350
+ #
351
+ # Comment
352
+
353
+ protected function blockComment($Line)
354
+ {
355
+ if ($this->markupEscaped)
356
+ {
357
+ return;
358
+ }
359
+
360
+ if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!')
361
+ {
362
+ $Block = array(
363
+ 'markup' => $Line['body'],
364
+ );
365
+
366
+ if (preg_match('/-->$/', $Line['text']))
367
+ {
368
+ $Block['closed'] = true;
369
+ }
370
+
371
+ return $Block;
372
+ }
373
+ }
374
+
375
+ protected function blockCommentContinue($Line, array $Block)
376
+ {
377
+ if (isset($Block['closed']))
378
+ {
379
+ return;
380
+ }
381
+
382
+ $Block['markup'] .= "\n" . $Line['body'];
383
+
384
+ if (preg_match('/-->$/', $Line['text']))
385
+ {
386
+ $Block['closed'] = true;
387
+ }
388
+
389
+ return $Block;
390
+ }
391
+
392
+ #
393
+ # Fenced Code
394
+
395
+ protected function blockFencedCode($Line)
396
+ {
397
+ if (preg_match('/^(['.$Line['text'][0].']{3,})[ ]*([\w-]+)?[ ]*$/', $Line['text'], $matches))
398
+ {
399
+ $Element = array(
400
+ 'name' => 'code',
401
+ 'text' => '',
402
+ );
403
+
404
+ if (isset($matches[2]))
405
+ {
406
+ $class = 'language-'.$matches[2];
407
+
408
+ $Element['attributes'] = array(
409
+ 'class' => $class,
410
+ );
411
+ }
412
+
413
+ $Block = array(
414
+ 'char' => $Line['text'][0],
415
+ 'element' => array(
416
+ 'name' => 'pre',
417
+ 'handler' => 'element',
418
+ 'text' => $Element,
419
+ ),
420
+ );
421
+
422
+ return $Block;
423
+ }
424
+ }
425
+
426
+ protected function blockFencedCodeContinue($Line, $Block)
427
+ {
428
+ if (isset($Block['complete']))
429
+ {
430
+ return;
431
+ }
432
+
433
+ if (isset($Block['interrupted']))
434
+ {
435
+ $Block['element']['text']['text'] .= "\n";
436
+
437
+ unset($Block['interrupted']);
438
+ }
439
+
440
+ if (preg_match('/^'.$Block['char'].'{3,}[ ]*$/', $Line['text']))
441
+ {
442
+ $Block['element']['text']['text'] = substr($Block['element']['text']['text'], 1);
443
+
444
+ $Block['complete'] = true;
445
+
446
+ return $Block;
447
+ }
448
+
449
+ $Block['element']['text']['text'] .= "\n".$Line['body'];;
450
+
451
+ return $Block;
452
+ }
453
+
454
+ protected function blockFencedCodeComplete($Block)
455
+ {
456
+ $text = $Block['element']['text']['text'];
457
+
458
+ $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
459
+
460
+ $Block['element']['text']['text'] = $text;
461
+
462
+ return $Block;
463
+ }
464
+
465
+ #
466
+ # Header
467
+
468
+ protected function blockHeader($Line)
469
+ {
470
+ if (isset($Line['text'][1]))
471
+ {
472
+ $level = 1;
473
+
474
+ while (isset($Line['text'][$level]) and $Line['text'][$level] === '#')
475
+ {
476
+ $level ++;
477
+ }
478
+
479
+ if ($level > 6)
480
+ {
481
+ return;
482
+ }
483
+
484
+ $text = trim($Line['text'], '# ');
485
+
486
+ $Block = array(
487
+ 'element' => array(
488
+ 'name' => 'h' . min(6, $level),
489
+ 'text' => $text,
490
+ 'handler' => 'line',
491
+ ),
492
+ );
493
+
494
+ return $Block;
495
+ }
496
+ }
497
+
498
+ #
499
+ # List
500
+
501
+ protected function blockList($Line)
502
+ {
503
+ list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]');
504
+
505
+ if (preg_match('/^('.$pattern.'[ ]+)(.*)/', $Line['text'], $matches))
506
+ {
507
+ $Block = array(
508
+ 'indent' => $Line['indent'],
509
+ 'pattern' => $pattern,
510
+ 'element' => array(
511
+ 'name' => $name,
512
+ 'handler' => 'elements',
513
+ ),
514
+ );
515
+
516
+ $Block['li'] = array(
517
+ 'name' => 'li',
518
+ 'handler' => 'li',
519
+ 'text' => array(
520
+ $matches[2],
521
+ ),
522
+ );
523
+
524
+ $Block['element']['text'] []= & $Block['li'];
525
+
526
+ return $Block;
527
+ }
528
+ }
529
+
530
+ protected function blockListContinue($Line, array $Block)
531
+ {
532
+ if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches))
533
+ {
534
+ if (isset($Block['interrupted']))
535
+ {
536
+ $Block['li']['text'] []= '';
537
+
538
+ unset($Block['interrupted']);
539
+ }
540
+
541
+ unset($Block['li']);
542
+
543
+ $text = isset($matches[1]) ? $matches[1] : '';
544
+
545
+ $Block['li'] = array(
546
+ 'name' => 'li',
547
+ 'handler' => 'li',
548
+ 'text' => array(
549
+ $text,
550
+ ),
551
+ );
552
+
553
+ $Block['element']['text'] []= & $Block['li'];
554
+
555
+ return $Block;
556
+ }
557
+
558
+ if ($Line['text'][0] === '[' and $this->blockReference($Line))
559
+ {
560
+ return $Block;
561
+ }
562
+
563
+ if ( ! isset($Block['interrupted']))
564
+ {
565
+ $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
566
+
567
+ $Block['li']['text'] []= $text;
568
+
569
+ return $Block;
570
+ }
571
+
572
+ if ($Line['indent'] > 0)
573
+ {
574
+ $Block['li']['text'] []= '';
575
+
576
+ $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
577
+
578
+ $Block['li']['text'] []= $text;
579
+
580
+ unset($Block['interrupted']);
581
+
582
+ return $Block;
583
+ }
584
+ }
585
+
586
+ #
587
+ # Quote
588
+
589
+ protected function blockQuote($Line)
590
+ {
591
+ if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
592
+ {
593
+ $Block = array(
594
+ 'element' => array(
595
+ 'name' => 'blockquote',
596
+ 'handler' => 'lines',
597
+ 'text' => (array) $matches[1],
598
+ ),
599
+ );
600
+
601
+ return $Block;
602
+ }
603
+ }
604
+
605
+ protected function blockQuoteContinue($Line, array $Block)
606
+ {
607
+ if ($Line['text'][0] === '>' and preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
608
+ {
609
+ if (isset($Block['interrupted']))
610
+ {
611
+ $Block['element']['text'] []= '';
612
+
613
+ unset($Block['interrupted']);
614
+ }
615
+
616
+ $Block['element']['text'] []= $matches[1];
617
+
618
+ return $Block;
619
+ }
620
+
621
+ if ( ! isset($Block['interrupted']))
622
+ {
623
+ $Block['element']['text'] []= $Line['text'];
624
+
625
+ return $Block;
626
+ }
627
+ }
628
+
629
+ #
630
+ # Rule
631
+
632
+ protected function blockRule($Line)
633
+ {
634
+ if (preg_match('/^(['.$Line['text'][0].'])([ ]*\1){2,}[ ]*$/', $Line['text']))
635
+ {
636
+ $Block = array(
637
+ 'element' => array(
638
+ 'name' => 'hr'
639
+ ),
640
+ );
641
+
642
+ return $Block;
643
+ }
644
+ }
645
+
646
+ #
647
+ # Setext
648
+
649
+ protected function blockSetextHeader($Line, array $Block = null)
650
+ {
651
+ if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
652
+ {
653
+ return;
654
+ }
655
+
656
+ if (chop($Line['text'], $Line['text'][0]) === '')
657
+ {
658
+ $Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2';
659
+
660
+ return $Block;
661
+ }
662
+ }
663
+
664
+ #
665
+ # Markup
666
+
667
+ protected function blockMarkup($Line)
668
+ {
669
+ if ($this->markupEscaped)
670
+ {
671
+ return;
672
+ }
673
+
674
+ if (preg_match('/^<(\w*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches))
675
+ {
676
+ if (in_array($matches[1], $this->textLevelElements))
677
+ {
678
+ return;
679
+ }
680
+
681
+ $Block = array(
682
+ 'name' => $matches[1],
683
+ 'depth' => 0,
684
+ 'markup' => $Line['text'],
685
+ );
686
+
687
+ $length = strlen($matches[0]);
688
+
689
+ $remainder = substr($Line['text'], $length);
690
+
691
+ if (trim($remainder) === '')
692
+ {
693
+ if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
694
+ {
695
+ $Block['closed'] = true;
696
+
697
+ $Block['void'] = true;
698
+ }
699
+ }
700
+ else
701
+ {
702
+ if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
703
+ {
704
+ return;
705
+ }
706
+
707
+ if (preg_match('/<\/'.$matches[1].'>[ ]*$/i', $remainder))
708
+ {
709
+ $Block['closed'] = true;
710
+ }
711
+ }
712
+
713
+ return $Block;
714
+ }
715
+ }
716
+
717
+ protected function blockMarkupContinue($Line, array $Block)
718
+ {
719
+ if (isset($Block['closed']))
720
+ {
721
+ return;
722
+ }
723
+
724
+ if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
725
+ {
726
+ $Block['depth'] ++;
727
+ }
728
+
729
+ if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
730
+ {
731
+ if ($Block['depth'] > 0)
732
+ {
733
+ $Block['depth'] --;
734
+ }
735
+ else
736
+ {
737
+ $Block['closed'] = true;
738
+ }
739
+
740
+ $Block['markup'] .= $matches[1];
741
+ }
742
+
743
+ if (isset($Block['interrupted']))
744
+ {
745
+ $Block['markup'] .= "\n";
746
+
747
+ unset($Block['interrupted']);
748
+ }
749
+
750
+ $Block['markup'] .= "\n".$Line['body'];
751
+
752
+ return $Block;
753
+ }
754
+
755
+ #
756
+ # Reference
757
+
758
+ protected function blockReference($Line)
759
+ {
760
+ if (preg_match('/^\[(.+?)\]:[ ]*<?(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*$/', $Line['text'], $matches))
761
+ {
762
+ $id = strtolower($matches[1]);
763
+
764
+ $Data = array(
765
+ 'url' => $matches[2],
766
+ 'title' => null,
767
+ );
768
+
769
+ if (isset($matches[3]))
770
+ {
771
+ $Data['title'] = $matches[3];
772
+ }
773
+
774
+ $this->DefinitionData['Reference'][$id] = $Data;
775
+
776
+ $Block = array(
777
+ 'hidden' => true,
778
+ );
779
+
780
+ return $Block;
781
+ }
782
+ }
783
+
784
+ #
785
+ # Table
786
+
787
+ protected function blockTable($Line, array $Block = null)
788
+ {
789
+ if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
790
+ {
791
+ return;
792
+ }
793
+
794
+ if (strpos($Block['element']['text'], '|') !== false and chop($Line['text'], ' -:|') === '')
795
+ {
796
+ $alignments = array();
797
+
798
+ $divider = $Line['text'];
799
+
800
+ $divider = trim($divider);
801
+ $divider = trim($divider, '|');
802
+
803
+ $dividerCells = explode('|', $divider);
804
+
805
+ foreach ($dividerCells as $dividerCell)
806
+ {
807
+ $dividerCell = trim($dividerCell);
808
+
809
+ if ($dividerCell === '')
810
+ {
811
+ continue;
812
+ }
813
+
814
+ $alignment = null;
815
+
816
+ if ($dividerCell[0] === ':')
817
+ {
818
+ $alignment = 'left';
819
+ }
820
+
821
+ if (substr($dividerCell, - 1) === ':')
822
+ {
823
+ $alignment = $alignment === 'left' ? 'center' : 'right';
824
+ }
825
+
826
+ $alignments []= $alignment;
827
+ }
828
+
829
+ # ~
830
+
831
+ $HeaderElements = array();
832
+
833
+ $header = $Block['element']['text'];
834
+
835
+ $header = trim($header);
836
+ $header = trim($header, '|');
837
+
838
+ $headerCells = explode('|', $header);
839
+
840
+ foreach ($headerCells as $index => $headerCell)
841
+ {
842
+ $headerCell = trim($headerCell);
843
+
844
+ $HeaderElement = array(
845
+ 'name' => 'th',
846
+ 'text' => $headerCell,
847
+ 'handler' => 'line',
848
+ );
849
+
850
+ if (isset($alignments[$index]))
851
+ {
852
+ $alignment = $alignments[$index];
853
+
854
+ $HeaderElement['attributes'] = array(
855
+ 'style' => 'text-align: '.$alignment.';',
856
+ );
857
+ }
858
+
859
+ $HeaderElements []= $HeaderElement;
860
+ }
861
+
862
+ # ~
863
+
864
+ $Block = array(
865
+ 'alignments' => $alignments,
866
+ 'identified' => true,
867
+ 'element' => array(
868
+ 'name' => 'table',
869
+ 'handler' => 'elements',
870
+ ),
871
+ );
872
+
873
+ $Block['element']['text'] []= array(
874
+ 'name' => 'thead',
875
+ 'handler' => 'elements',
876
+ );
877
+
878
+ $Block['element']['text'] []= array(
879
+ 'name' => 'tbody',
880
+ 'handler' => 'elements',
881
+ 'text' => array(),
882
+ );
883
+
884
+ $Block['element']['text'][0]['text'] []= array(
885
+ 'name' => 'tr',
886
+ 'handler' => 'elements',
887
+ 'text' => $HeaderElements,
888
+ );
889
+
890
+ return $Block;
891
+ }
892
+ }
893
+
894
+ protected function blockTableContinue($Line, array $Block)
895
+ {
896
+ if (isset($Block['interrupted']))
897
+ {
898
+ return;
899
+ }
900
+
901
+ if ($Line['text'][0] === '|' or strpos($Line['text'], '|'))
902
+ {
903
+ $Elements = array();
904
+
905
+ $row = $Line['text'];
906
+
907
+ $row = trim($row);
908
+ $row = trim($row, '|');
909
+
910
+ preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]+`|`)+/', $row, $matches);
911
+
912
+ foreach ($matches[0] as $index => $cell)
913
+ {
914
+ $cell = trim($cell);
915
+
916
+ $Element = array(
917
+ 'name' => 'td',
918
+ 'handler' => 'line',
919
+ 'text' => $cell,
920
+ );
921
+
922
+ if (isset($Block['alignments'][$index]))
923
+ {
924
+ $Element['attributes'] = array(
925
+ 'style' => 'text-align: '.$Block['alignments'][$index].';',
926
+ );
927
+ }
928
+
929
+ $Elements []= $Element;
930
+ }
931
+
932
+ $Element = array(
933
+ 'name' => 'tr',
934
+ 'handler' => 'elements',
935
+ 'text' => $Elements,
936
+ );
937
+
938
+ $Block['element']['text'][1]['text'] []= $Element;
939
+
940
+ return $Block;
941
+ }
942
+ }
943
+
944
+ #
945
+ # ~
946
+ #
947
+
948
+ protected function paragraph($Line)
949
+ {
950
+ $Block = array(
951
+ 'element' => array(
952
+ 'name' => 'p',
953
+ 'text' => $Line['text'],
954
+ 'handler' => 'line',
955
+ ),
956
+ );
957
+
958
+ return $Block;
959
+ }
960
+
961
+ #
962
+ # Inline Elements
963
+ #
964
+
965
+ protected $InlineTypes = array(
966
+ '"' => array('SpecialCharacter'),
967
+ '!' => array('Image'),
968
+ '&' => array('SpecialCharacter'),
969
+ '*' => array('Emphasis'),
970
+ ':' => array('Url'),
971
+ '<' => array('UrlTag', 'EmailTag', 'Markup', 'SpecialCharacter'),
972
+ '>' => array('SpecialCharacter'),
973
+ '[' => array('Link'),
974
+ '_' => array('Emphasis'),
975
+ '`' => array('Code'),
976
+ '~' => array('Strikethrough'),
977
+ '\\' => array('EscapeSequence'),
978
+ );
979
+
980
+ # ~
981
+
982
+ protected $inlineMarkerList = '!"*_&[:<>`~\\';
983
+
984
+ #
985
+ # ~
986
+ #
987
+
988
+ public function line($text)
989
+ {
990
+ $markup = '';
991
+
992
+ $unexaminedText = $text;
993
+
994
+ $markerPosition = 0;
995
+
996
+ while ($excerpt = strpbrk($unexaminedText, $this->inlineMarkerList))
997
+ {
998
+ $marker = $excerpt[0];
999
+
1000
+ $markerPosition += strpos($unexaminedText, $marker);
1001
+
1002
+ $Excerpt = array('text' => $excerpt, 'context' => $text);
1003
+
1004
+ foreach ($this->InlineTypes[$marker] as $inlineType)
1005
+ {
1006
+ $Inline = $this->{'inline'.$inlineType}($Excerpt);
1007
+
1008
+ if ( ! isset($Inline))
1009
+ {
1010
+ continue;
1011
+ }
1012
+
1013
+ if (isset($Inline['position']) and $Inline['position'] > $markerPosition) # position is ahead of marker
1014
+ {
1015
+ continue;
1016
+ }
1017
+
1018
+ if ( ! isset($Inline['position']))
1019
+ {
1020
+ $Inline['position'] = $markerPosition;
1021
+ }
1022
+
1023
+ $unmarkedText = substr($text, 0, $Inline['position']);
1024
+
1025
+ $markup .= $this->unmarkedText($unmarkedText);
1026
+
1027
+ $markup .= isset($Inline['markup']) ? $Inline['markup'] : $this->element($Inline['element']);
1028
+
1029
+ $text = substr($text, $Inline['position'] + $Inline['extent']);
1030
+
1031
+ $unexaminedText = $text;
1032
+
1033
+ $markerPosition = 0;
1034
+
1035
+ continue 2;
1036
+ }
1037
+
1038
+ $unexaminedText = substr($excerpt, 1);
1039
+
1040
+ $markerPosition ++;
1041
+ }
1042
+
1043
+ $markup .= $this->unmarkedText($text);
1044
+
1045
+ return $markup;
1046
+ }
1047
+
1048
+ #
1049
+ # ~
1050
+ #
1051
+
1052
+ protected function inlineCode($Excerpt)
1053
+ {
1054
+ $marker = $Excerpt['text'][0];
1055
+
1056
+ if (preg_match('/^('.$marker.'+)[ ]*(.+?)[ ]*(?<!'.$marker.')\1(?!'.$marker.')/s', $Excerpt['text'], $matches))
1057
+ {
1058
+ $text = $matches[2];
1059
+ $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
1060
+ $text = preg_replace("/[ ]*\n/", ' ', $text);
1061
+
1062
+ return array(
1063
+ 'extent' => strlen($matches[0]),
1064
+ 'element' => array(
1065
+ 'name' => 'code',
1066
+ 'text' => $text,
1067
+ ),
1068
+ );
1069
+ }
1070
+ }
1071
+
1072
+ protected function inlineEmailTag($Excerpt)
1073
+ {
1074
+ if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches))
1075
+ {
1076
+ $url = $matches[1];
1077
+
1078
+ if ( ! isset($matches[2]))
1079
+ {
1080
+ $url = 'mailto:' . $url;
1081
+ }
1082
+
1083
+ return array(
1084
+ 'extent' => strlen($matches[0]),
1085
+ 'element' => array(
1086
+ 'name' => 'a',
1087
+ 'text' => $matches[1],
1088
+ 'attributes' => array(
1089
+ 'href' => $url,
1090
+ ),
1091
+ ),
1092
+ );
1093
+ }
1094
+ }
1095
+
1096
+ protected function inlineEmphasis($Excerpt)
1097
+ {
1098
+ if ( ! isset($Excerpt['text'][1]))
1099
+ {
1100
+ return;
1101
+ }
1102
+
1103
+ $marker = $Excerpt['text'][0];
1104
+
1105
+ if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches))
1106
+ {
1107
+ $emphasis = 'strong';
1108
+ }
1109
+ elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches))
1110
+ {
1111
+ $emphasis = 'em';
1112
+ }
1113
+ else
1114
+ {
1115
+ return;
1116
+ }
1117
+
1118
+ return array(
1119
+ 'extent' => strlen($matches[0]),
1120
+ 'element' => array(
1121
+ 'name' => $emphasis,
1122
+ 'handler' => 'line',
1123
+ 'text' => $matches[1],
1124
+ ),
1125
+ );
1126
+ }
1127
+
1128
+ protected function inlineEscapeSequence($Excerpt)
1129
+ {
1130
+ if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters))
1131
+ {
1132
+ return array(
1133
+ 'markup' => $Excerpt['text'][1],
1134
+ 'extent' => 2,
1135
+ );
1136
+ }
1137
+ }
1138
+
1139
+ protected function inlineImage($Excerpt)
1140
+ {
1141
+ if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
1142
+ {
1143
+ return;
1144
+ }
1145
+
1146
+ $Excerpt['text']= substr($Excerpt['text'], 1);
1147
+
1148
+ $Link = $this->inlineLink($Excerpt);
1149
+
1150
+ if ($Link === null)
1151
+ {
1152
+ return;
1153
+ }
1154
+
1155
+ $Inline = array(
1156
+ 'extent' => $Link['extent'] + 1,
1157
+ 'element' => array(
1158
+ 'name' => 'img',
1159
+ 'attributes' => array(
1160
+ 'src' => $Link['element']['attributes']['href'],
1161
+ 'alt' => $Link['element']['text'],
1162
+ ),
1163
+ ),
1164
+ );
1165
+
1166
+ $Inline['element']['attributes'] += $Link['element']['attributes'];
1167
+
1168
+ unset($Inline['element']['attributes']['href']);
1169
+
1170
+ return $Inline;
1171
+ }
1172
+
1173
+ protected function inlineLink($Excerpt)
1174
+ {
1175
+ $Element = array(
1176
+ 'name' => 'a',
1177
+ 'handler' => 'line',
1178
+ 'text' => null,
1179
+ 'attributes' => array(
1180
+ 'href' => null,
1181
+ 'title' => null,
1182
+ ),
1183
+ );
1184
+
1185
+ $extent = 0;
1186
+
1187
+ $remainder = $Excerpt['text'];
1188
+
1189
+ if (preg_match('/\[((?:[^][]|(?R))*)\]/', $remainder, $matches))
1190
+ {
1191
+ $Element['text'] = $matches[1];
1192
+
1193
+ $extent += strlen($matches[0]);
1194
+
1195
+ $remainder = substr($remainder, $extent);
1196
+ }
1197
+ else
1198
+ {
1199
+ return;
1200
+ }
1201
+
1202
+ if (preg_match('/^[(]((?:[^ (]|[(][^ )]+[)])+)(?:[ ]+("[^"]+"|\'[^\']+\'))?[)]/', $remainder, $matches))
1203
+ {
1204
+ $Element['attributes']['href'] = $matches[1];
1205
+
1206
+ if (isset($matches[2]))
1207
+ {
1208
+ $Element['attributes']['title'] = substr($matches[2], 1, - 1);
1209
+ }
1210
+
1211
+ $extent += strlen($matches[0]);
1212
+ }
1213
+ else
1214
+ {
1215
+ if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches))
1216
+ {
1217
+ $definition = $matches[1] ? $matches[1] : $Element['text'];
1218
+ $definition = strtolower($definition);
1219
+
1220
+ $extent += strlen($matches[0]);
1221
+ }
1222
+ else
1223
+ {
1224
+ $definition = strtolower($Element['text']);
1225
+ }
1226
+
1227
+ if ( ! isset($this->DefinitionData['Reference'][$definition]))
1228
+ {
1229
+ return;
1230
+ }
1231
+
1232
+ $Definition = $this->DefinitionData['Reference'][$definition];
1233
+
1234
+ $Element['attributes']['href'] = $Definition['url'];
1235
+ $Element['attributes']['title'] = $Definition['title'];
1236
+ }
1237
+
1238
+ $Element['attributes']['href'] = str_replace(array('&', '<'), array('&amp;', '&lt;'), $Element['attributes']['href']);
1239
+
1240
+ return array(
1241
+ 'extent' => $extent,
1242
+ 'element' => $Element,
1243
+ );
1244
+ }
1245
+
1246
+ protected function inlineMarkup($Excerpt)
1247
+ {
1248
+ if ($this->markupEscaped or strpos($Excerpt['text'], '>') === false)
1249
+ {
1250
+ return;
1251
+ }
1252
+
1253
+ if ($Excerpt['text'][1] === '/' and preg_match('/^<\/\w*[ ]*>/s', $Excerpt['text'], $matches))
1254
+ {
1255
+ return array(
1256
+ 'markup' => $matches[0],
1257
+ 'extent' => strlen($matches[0]),
1258
+ );
1259
+ }
1260
+
1261
+ if ($Excerpt['text'][1] === '!' and preg_match('/^<!---?[^>-](?:-?[^-])*-->/s', $Excerpt['text'], $matches))
1262
+ {
1263
+ return array(
1264
+ 'markup' => $matches[0],
1265
+ 'extent' => strlen($matches[0]),
1266
+ );
1267
+ }
1268
+
1269
+ if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w*(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*\/?>/s', $Excerpt['text'], $matches))
1270
+ {
1271
+ return array(
1272
+ 'markup' => $matches[0],
1273
+ 'extent' => strlen($matches[0]),
1274
+ );
1275
+ }
1276
+ }
1277
+
1278
+ protected function inlineSpecialCharacter($Excerpt)
1279
+ {
1280
+ if ($Excerpt['text'][0] === '&' and ! preg_match('/^&#?\w+;/', $Excerpt['text']))
1281
+ {
1282
+ return array(
1283
+ 'markup' => '&amp;',
1284
+ 'extent' => 1,
1285
+ );
1286
+ }
1287
+
1288
+ $SpecialCharacter = array('>' => 'gt', '<' => 'lt', '"' => 'quot');
1289
+
1290
+ if (isset($SpecialCharacter[$Excerpt['text'][0]]))
1291
+ {
1292
+ return array(
1293
+ 'markup' => '&'.$SpecialCharacter[$Excerpt['text'][0]].';',
1294
+ 'extent' => 1,
1295
+ );
1296
+ }
1297
+ }
1298
+
1299
+ protected function inlineStrikethrough($Excerpt)
1300
+ {
1301
+ if ( ! isset($Excerpt['text'][1]))
1302
+ {
1303
+ return;
1304
+ }
1305
+
1306
+ if ($Excerpt['text'][1] === '~' and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches))
1307
+ {
1308
+ return array(
1309
+ 'extent' => strlen($matches[0]),
1310
+ 'element' => array(
1311
+ 'name' => 'del',
1312
+ 'text' => $matches[1],
1313
+ 'handler' => 'line',
1314
+ ),
1315
+ );
1316
+ }
1317
+ }
1318
+
1319
+ protected function inlineUrl($Excerpt)
1320
+ {
1321
+ if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/')
1322
+ {
1323
+ return;
1324
+ }
1325
+
1326
+ if (preg_match('/\bhttps?:[\/]{2}[^\s<]+\b\/*/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE))
1327
+ {
1328
+ $Inline = array(
1329
+ 'extent' => strlen($matches[0][0]),
1330
+ 'position' => $matches[0][1],
1331
+ 'element' => array(
1332
+ 'name' => 'a',
1333
+ 'text' => $matches[0][0],
1334
+ 'attributes' => array(
1335
+ 'href' => $matches[0][0],
1336
+ ),
1337
+ ),
1338
+ );
1339
+
1340
+ return $Inline;
1341
+ }
1342
+ }
1343
+
1344
+ protected function inlineUrlTag($Excerpt)
1345
+ {
1346
+ if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $Excerpt['text'], $matches))
1347
+ {
1348
+ $url = str_replace(array('&', '<'), array('&amp;', '&lt;'), $matches[1]);
1349
+
1350
+ return array(
1351
+ 'extent' => strlen($matches[0]),
1352
+ 'element' => array(
1353
+ 'name' => 'a',
1354
+ 'text' => $url,
1355
+ 'attributes' => array(
1356
+ 'href' => $url,
1357
+ ),
1358
+ ),
1359
+ );
1360
+ }
1361
+ }
1362
+
1363
+ #
1364
+ # ~
1365
+
1366
+ protected $unmarkedInlineTypes = array("\n" => 'Break', '://' => 'Url');
1367
+
1368
+ # ~
1369
+
1370
+ protected function unmarkedText($text)
1371
+ {
1372
+ if ($this->breaksEnabled)
1373
+ {
1374
+ $text = preg_replace('/[ ]*\n/', "<br />\n", $text);
1375
+ }
1376
+ else
1377
+ {
1378
+ $text = preg_replace('/(?:[ ][ ]+|[ ]*\\\\)\n/', "<br />\n", $text);
1379
+ $text = str_replace(" \n", "\n", $text);
1380
+ }
1381
+
1382
+ return $text;
1383
+ }
1384
+
1385
+ #
1386
+ # Handlers
1387
+ #
1388
+
1389
+ protected function element(array $Element)
1390
+ {
1391
+ $markup = '<'.$Element['name'];
1392
+
1393
+ if (isset($Element['attributes']))
1394
+ {
1395
+ foreach ($Element['attributes'] as $name => $value)
1396
+ {
1397
+ if ($value === null)
1398
+ {
1399
+ continue;
1400
+ }
1401
+
1402
+ $markup .= ' '.$name.'="'.$value.'"';
1403
+ }
1404
+ }
1405
+
1406
+ if (isset($Element['text']))
1407
+ {
1408
+ $markup .= '>';
1409
+
1410
+ if (isset($Element['handler']))
1411
+ {
1412
+ $markup .= $this->{$Element['handler']}($Element['text']);
1413
+ }
1414
+ else
1415
+ {
1416
+ $markup .= $Element['text'];
1417
+ }
1418
+
1419
+ $markup .= '</'.$Element['name'].'>';
1420
+ }
1421
+ else
1422
+ {
1423
+ $markup .= ' />';
1424
+ }
1425
+
1426
+ return $markup;
1427
+ }
1428
+
1429
+ protected function elements(array $Elements)
1430
+ {
1431
+ $markup = '';
1432
+
1433
+ foreach ($Elements as $Element)
1434
+ {
1435
+ $markup .= "\n" . $this->element($Element);
1436
+ }
1437
+
1438
+ $markup .= "\n";
1439
+
1440
+ return $markup;
1441
+ }
1442
+
1443
+ # ~
1444
+
1445
+ protected function li($lines)
1446
+ {
1447
+ $markup = $this->lines($lines);
1448
+
1449
+ $trimmedMarkup = trim($markup);
1450
+
1451
+ if ( ! in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '<p>')
1452
+ {
1453
+ $markup = $trimmedMarkup;
1454
+ $markup = substr($markup, 3);
1455
+
1456
+ $position = strpos($markup, "</p>");
1457
+
1458
+ $markup = substr_replace($markup, '', $position, 4);
1459
+ }
1460
+
1461
+ return $markup;
1462
+ }
1463
+
1464
+ #
1465
+ # Deprecated Methods
1466
+ #
1467
+
1468
+ function parse($text)
1469
+ {
1470
+ $markup = $this->text($text);
1471
+
1472
+ return $markup;
1473
+ }
1474
+
1475
+ #
1476
+ # Static Methods
1477
+ #
1478
+
1479
+ static function instance($name = 'default')
1480
+ {
1481
+ if (isset(self::$instances[$name]))
1482
+ {
1483
+ return self::$instances[$name];
1484
+ }
1485
+
1486
+ $instance = new self();
1487
+
1488
+ self::$instances[$name] = $instance;
1489
+
1490
+ return $instance;
1491
+ }
1492
+
1493
+ private static $instances = array();
1494
+
1495
+ #
1496
+ # Fields
1497
+ #
1498
+
1499
+ protected $DefinitionData;
1500
+
1501
+ #
1502
+ # Read-Only
1503
+
1504
+ protected $specialCharacters = array(
1505
+ '\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|',
1506
+ );
1507
+
1508
+ protected $StrongRegex = array(
1509
+ '*' => '/^[*]{2}((?:\\\\\*|[^*]|[*][^*]*[*])+?)[*]{2}(?![*])/s',
1510
+ '_' => '/^__((?:\\\\_|[^_]|_[^_]*_)+?)__(?!_)/us',
1511
+ );
1512
+
1513
+ protected $EmRegex = array(
1514
+ '*' => '/^[*]((?:\\\\\*|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s',
1515
+ '_' => '/^_((?:\\\\_|[^_]|__[^_]*__)+?)_(?!_)\b/us',
1516
+ );
1517
+
1518
+ protected $regexHtmlAttribute = '[a-zA-Z_:][\w:.-]*(?:\s*=\s*(?:[^"\'=<>`\s]+|"[^"]*"|\'[^\']*\'))?';
1519
+
1520
+ protected $voidElements = array(
1521
+ 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source',
1522
+ );
1523
+
1524
+ protected $textLevelElements = array(
1525
+ 'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont',
1526
+ 'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing',
1527
+ 'i', 'rp', 'del', 'code', 'strike', 'marquee',
1528
+ 'q', 'rt', 'ins', 'font', 'strong',
1529
+ 's', 'tt', 'sub', 'mark',
1530
+ 'u', 'xm', 'sup', 'nobr',
1531
+ 'var', 'ruby',
1532
+ 'wbr', 'span',
1533
+ 'time',
1534
+ );
1535
+ }
lib/plugin-update-checker/vendor/ParsedownModern.php ADDED
@@ -0,0 +1,1538 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ #
4
+ #
5
+ # Parsedown
6
+ # http://parsedown.org
7
+ #
8
+ # (c) Emanuil Rusev
9
+ # http://erusev.com
10
+ #
11
+ # For the full license information, view the LICENSE file that was distributed
12
+ # with this source code.
13
+ #
14
+ #
15
+
16
+ class Parsedown
17
+ {
18
+ # ~
19
+
20
+ const version = '1.6.0';
21
+
22
+ # ~
23
+
24
+ function text($text)
25
+ {
26
+ # make sure no definitions are set
27
+ $this->DefinitionData = array();
28
+
29
+ # standardize line breaks
30
+ $text = str_replace(array("\r\n", "\r"), "\n", $text);
31
+
32
+ # remove surrounding line breaks
33
+ $text = trim($text, "\n");
34
+
35
+ # split text into lines
36
+ $lines = explode("\n", $text);
37
+
38
+ # iterate through lines to identify blocks
39
+ $markup = $this->lines($lines);
40
+
41
+ # trim line breaks
42
+ $markup = trim($markup, "\n");
43
+
44
+ return $markup;
45
+ }
46
+
47
+ #
48
+ # Setters
49
+ #
50
+
51
+ function setBreaksEnabled($breaksEnabled)
52
+ {
53
+ $this->breaksEnabled = $breaksEnabled;
54
+
55
+ return $this;
56
+ }
57
+
58
+ protected $breaksEnabled;
59
+
60
+ function setMarkupEscaped($markupEscaped)
61
+ {
62
+ $this->markupEscaped = $markupEscaped;
63
+
64
+ return $this;
65
+ }
66
+
67
+ protected $markupEscaped;
68
+
69
+ function setUrlsLinked($urlsLinked)
70
+ {
71
+ $this->urlsLinked = $urlsLinked;
72
+
73
+ return $this;
74
+ }
75
+
76
+ protected $urlsLinked = true;
77
+
78
+ #
79
+ # Lines
80
+ #
81
+
82
+ protected $BlockTypes = array(
83
+ '#' => array('Header'),
84
+ '*' => array('Rule', 'List'),
85
+ '+' => array('List'),
86
+ '-' => array('SetextHeader', 'Table', 'Rule', 'List'),
87
+ '0' => array('List'),
88
+ '1' => array('List'),
89
+ '2' => array('List'),
90
+ '3' => array('List'),
91
+ '4' => array('List'),
92
+ '5' => array('List'),
93
+ '6' => array('List'),
94
+ '7' => array('List'),
95
+ '8' => array('List'),
96
+ '9' => array('List'),
97
+ ':' => array('Table'),
98
+ '<' => array('Comment', 'Markup'),
99
+ '=' => array('SetextHeader'),
100
+ '>' => array('Quote'),
101
+ '[' => array('Reference'),
102
+ '_' => array('Rule'),
103
+ '`' => array('FencedCode'),
104
+ '|' => array('Table'),
105
+ '~' => array('FencedCode'),
106
+ );
107
+
108
+ # ~
109
+
110
+ protected $unmarkedBlockTypes = array(
111
+ 'Code',
112
+ );
113
+
114
+ #
115
+ # Blocks
116
+ #
117
+
118
+ protected function lines(array $lines)
119
+ {
120
+ $CurrentBlock = null;
121
+
122
+ foreach ($lines as $line)
123
+ {
124
+ if (chop($line) === '')
125
+ {
126
+ if (isset($CurrentBlock))
127
+ {
128
+ $CurrentBlock['interrupted'] = true;
129
+ }
130
+
131
+ continue;
132
+ }
133
+
134
+ if (strpos($line, "\t") !== false)
135
+ {
136
+ $parts = explode("\t", $line);
137
+
138
+ $line = $parts[0];
139
+
140
+ unset($parts[0]);
141
+
142
+ foreach ($parts as $part)
143
+ {
144
+ $shortage = 4 - mb_strlen($line, 'utf-8') % 4;
145
+
146
+ $line .= str_repeat(' ', $shortage);
147
+ $line .= $part;
148
+ }
149
+ }
150
+
151
+ $indent = 0;
152
+
153
+ while (isset($line[$indent]) and $line[$indent] === ' ')
154
+ {
155
+ $indent ++;
156
+ }
157
+
158
+ $text = $indent > 0 ? substr($line, $indent) : $line;
159
+
160
+ # ~
161
+
162
+ $Line = array('body' => $line, 'indent' => $indent, 'text' => $text);
163
+
164
+ # ~
165
+
166
+ if (isset($CurrentBlock['continuable']))
167
+ {
168
+ $Block = $this->{'block'.$CurrentBlock['type'].'Continue'}($Line, $CurrentBlock);
169
+
170
+ if (isset($Block))
171
+ {
172
+ $CurrentBlock = $Block;
173
+
174
+ continue;
175
+ }
176
+ else
177
+ {
178
+ if ($this->isBlockCompletable($CurrentBlock['type']))
179
+ {
180
+ $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
181
+ }
182
+ }
183
+ }
184
+
185
+ # ~
186
+
187
+ $marker = $text[0];
188
+
189
+ # ~
190
+
191
+ $blockTypes = $this->unmarkedBlockTypes;
192
+
193
+ if (isset($this->BlockTypes[$marker]))
194
+ {
195
+ foreach ($this->BlockTypes[$marker] as $blockType)
196
+ {
197
+ $blockTypes []= $blockType;
198
+ }
199
+ }
200
+
201
+ #
202
+ # ~
203
+
204
+ foreach ($blockTypes as $blockType)
205
+ {
206
+ $Block = $this->{'block'.$blockType}($Line, $CurrentBlock);
207
+
208
+ if (isset($Block))
209
+ {
210
+ $Block['type'] = $blockType;
211
+
212
+ if ( ! isset($Block['identified']))
213
+ {
214
+ $Blocks []= $CurrentBlock;
215
+
216
+ $Block['identified'] = true;
217
+ }
218
+
219
+ if ($this->isBlockContinuable($blockType))
220
+ {
221
+ $Block['continuable'] = true;
222
+ }
223
+
224
+ $CurrentBlock = $Block;
225
+
226
+ continue 2;
227
+ }
228
+ }
229
+
230
+ # ~
231
+
232
+ if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted']))
233
+ {
234
+ $CurrentBlock['element']['text'] .= "\n".$text;
235
+ }
236
+ else
237
+ {
238
+ $Blocks []= $CurrentBlock;
239
+
240
+ $CurrentBlock = $this->paragraph($Line);
241
+
242
+ $CurrentBlock['identified'] = true;
243
+ }
244
+ }
245
+
246
+ # ~
247
+
248
+ if (isset($CurrentBlock['continuable']) and $this->isBlockCompletable($CurrentBlock['type']))
249
+ {
250
+ $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
251
+ }
252
+
253
+ # ~
254
+
255
+ $Blocks []= $CurrentBlock;
256
+
257
+ unset($Blocks[0]);
258
+
259
+ # ~
260
+
261
+ $markup = '';
262
+
263
+ foreach ($Blocks as $Block)
264
+ {
265
+ if (isset($Block['hidden']))
266
+ {
267
+ continue;
268
+ }
269
+
270
+ $markup .= "\n";
271
+ $markup .= isset($Block['markup']) ? $Block['markup'] : $this->element($Block['element']);
272
+ }
273
+
274
+ $markup .= "\n";
275
+
276
+ # ~
277
+
278
+ return $markup;
279
+ }
280
+
281
+ protected function isBlockContinuable($Type)
282
+ {
283
+ return method_exists($this, 'block'.$Type.'Continue');
284
+ }
285
+
286
+ protected function isBlockCompletable($Type)
287
+ {
288
+ return method_exists($this, 'block'.$Type.'Complete');
289
+ }
290
+
291
+ #
292
+ # Code
293
+
294
+ protected function blockCode($Line, $Block = null)
295
+ {
296
+ if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted']))
297
+ {
298
+ return;
299
+ }
300
+
301
+ if ($Line['indent'] >= 4)
302
+ {
303
+ $text = substr($Line['body'], 4);
304
+
305
+ $Block = array(
306
+ 'element' => array(
307
+ 'name' => 'pre',
308
+ 'handler' => 'element',
309
+ 'text' => array(
310
+ 'name' => 'code',
311
+ 'text' => $text,
312
+ ),
313
+ ),
314
+ );
315
+
316
+ return $Block;
317
+ }
318
+ }
319
+
320
+ protected function blockCodeContinue($Line, $Block)
321
+ {
322
+ if ($Line['indent'] >= 4)
323
+ {
324
+ if (isset($Block['interrupted']))
325
+ {
326
+ $Block['element']['text']['text'] .= "\n";
327
+
328
+ unset($Block['interrupted']);
329
+ }
330
+
331
+ $Block['element']['text']['text'] .= "\n";
332
+
333
+ $text = substr($Line['body'], 4);
334
+
335
+ $Block['element']['text']['text'] .= $text;
336
+
337
+ return $Block;
338
+ }
339
+ }
340
+
341
+ protected function blockCodeComplete($Block)
342
+ {
343
+ $text = $Block['element']['text']['text'];
344
+
345
+ $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
346
+
347
+ $Block['element']['text']['text'] = $text;
348
+
349
+ return $Block;
350
+ }
351
+
352
+ #
353
+ # Comment
354
+
355
+ protected function blockComment($Line)
356
+ {
357
+ if ($this->markupEscaped)
358
+ {
359
+ return;
360
+ }
361
+
362
+ if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!')
363
+ {
364
+ $Block = array(
365
+ 'markup' => $Line['body'],
366
+ );
367
+
368
+ if (preg_match('/-->$/', $Line['text']))
369
+ {
370
+ $Block['closed'] = true;
371
+ }
372
+
373
+ return $Block;
374
+ }
375
+ }
376
+
377
+ protected function blockCommentContinue($Line, array $Block)
378
+ {
379
+ if (isset($Block['closed']))
380
+ {
381
+ return;
382
+ }
383
+
384
+ $Block['markup'] .= "\n" . $Line['body'];
385
+
386
+ if (preg_match('/-->$/', $Line['text']))
387
+ {
388
+ $Block['closed'] = true;
389
+ }
390
+
391
+ return $Block;
392
+ }
393
+
394
+ #
395
+ # Fenced Code
396
+
397
+ protected function blockFencedCode($Line)
398
+ {
399
+ if (preg_match('/^['.$Line['text'][0].']{3,}[ ]*([\w-]+)?[ ]*$/', $Line['text'], $matches))
400
+ {
401
+ $Element = array(
402
+ 'name' => 'code',
403
+ 'text' => '',
404
+ );
405
+
406
+ if (isset($matches[1]))
407
+ {
408
+ $class = 'language-'.$matches[1];
409
+
410
+ $Element['attributes'] = array(
411
+ 'class' => $class,
412
+ );
413
+ }
414
+
415
+ $Block = array(
416
+ 'char' => $Line['text'][0],
417
+ 'element' => array(
418
+ 'name' => 'pre',
419
+ 'handler' => 'element',
420
+ 'text' => $Element,
421
+ ),
422
+ );
423
+
424
+ return $Block;
425
+ }
426
+ }
427
+
428
+ protected function blockFencedCodeContinue($Line, $Block)
429
+ {
430
+ if (isset($Block['complete']))
431
+ {
432
+ return;
433
+ }
434
+
435
+ if (isset($Block['interrupted']))
436
+ {
437
+ $Block['element']['text']['text'] .= "\n";
438
+
439
+ unset($Block['interrupted']);
440
+ }
441
+
442
+ if (preg_match('/^'.$Block['char'].'{3,}[ ]*$/', $Line['text']))
443
+ {
444
+ $Block['element']['text']['text'] = substr($Block['element']['text']['text'], 1);
445
+
446
+ $Block['complete'] = true;
447
+
448
+ return $Block;
449
+ }
450
+
451
+ $Block['element']['text']['text'] .= "\n".$Line['body'];;
452
+
453
+ return $Block;
454
+ }
455
+
456
+ protected function blockFencedCodeComplete($Block)
457
+ {
458
+ $text = $Block['element']['text']['text'];
459
+
460
+ $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
461
+
462
+ $Block['element']['text']['text'] = $text;
463
+
464
+ return $Block;
465
+ }
466
+
467
+ #
468
+ # Header
469
+
470
+ protected function blockHeader($Line)
471
+ {
472
+ if (isset($Line['text'][1]))
473
+ {
474
+ $level = 1;
475
+
476
+ while (isset($Line['text'][$level]) and $Line['text'][$level] === '#')
477
+ {
478
+ $level ++;
479
+ }
480
+
481
+ if ($level > 6)
482
+ {
483
+ return;
484
+ }
485
+
486
+ $text = trim($Line['text'], '# ');
487
+
488
+ $Block = array(
489
+ 'element' => array(
490
+ 'name' => 'h' . min(6, $level),
491
+ 'text' => $text,
492
+ 'handler' => 'line',
493
+ ),
494
+ );
495
+
496
+ return $Block;
497
+ }
498
+ }
499
+
500
+ #
501
+ # List
502
+
503
+ protected function blockList($Line)
504
+ {
505
+ list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]');
506
+
507
+ if (preg_match('/^('.$pattern.'[ ]+)(.*)/', $Line['text'], $matches))
508
+ {
509
+ $Block = array(
510
+ 'indent' => $Line['indent'],
511
+ 'pattern' => $pattern,
512
+ 'element' => array(
513
+ 'name' => $name,
514
+ 'handler' => 'elements',
515
+ ),
516
+ );
517
+
518
+ $Block['li'] = array(
519
+ 'name' => 'li',
520
+ 'handler' => 'li',
521
+ 'text' => array(
522
+ $matches[2],
523
+ ),
524
+ );
525
+
526
+ $Block['element']['text'] []= & $Block['li'];
527
+
528
+ return $Block;
529
+ }
530
+ }
531
+
532
+ protected function blockListContinue($Line, array $Block)
533
+ {
534
+ if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches))
535
+ {
536
+ if (isset($Block['interrupted']))
537
+ {
538
+ $Block['li']['text'] []= '';
539
+
540
+ unset($Block['interrupted']);
541
+ }
542
+
543
+ unset($Block['li']);
544
+
545
+ $text = isset($matches[1]) ? $matches[1] : '';
546
+
547
+ $Block['li'] = array(
548
+ 'name' => 'li',
549
+ 'handler' => 'li',
550
+ 'text' => array(
551
+ $text,
552
+ ),
553
+ );
554
+
555
+ $Block['element']['text'] []= & $Block['li'];
556
+
557
+ return $Block;
558
+ }
559
+
560
+ if ($Line['text'][0] === '[' and $this->blockReference($Line))
561
+ {
562
+ return $Block;
563
+ }
564
+
565
+ if ( ! isset($Block['interrupted']))
566
+ {
567
+ $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
568
+
569
+ $Block['li']['text'] []= $text;
570
+
571
+ return $Block;
572
+ }
573
+
574
+ if ($Line['indent'] > 0)
575
+ {
576
+ $Block['li']['text'] []= '';
577
+
578
+ $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
579
+
580
+ $Block['li']['text'] []= $text;
581
+
582
+ unset($Block['interrupted']);
583
+
584
+ return $Block;
585
+ }
586
+ }
587
+
588
+ #
589
+ # Quote
590
+
591
+ protected function blockQuote($Line)
592
+ {
593
+ if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
594
+ {
595
+ $Block = array(
596
+ 'element' => array(
597
+ 'name' => 'blockquote',
598
+ 'handler' => 'lines',
599
+ 'text' => (array) $matches[1],
600
+ ),
601
+ );
602
+
603
+ return $Block;
604
+ }
605
+ }
606
+
607
+ protected function blockQuoteContinue($Line, array $Block)
608
+ {
609
+ if ($Line['text'][0] === '>' and preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
610
+ {
611
+ if (isset($Block['interrupted']))
612
+ {
613
+ $Block['element']['text'] []= '';
614
+
615
+ unset($Block['interrupted']);
616
+ }
617
+
618
+ $Block['element']['text'] []= $matches[1];
619
+
620
+ return $Block;
621
+ }
622
+
623
+ if ( ! isset($Block['interrupted']))
624
+ {
625
+ $Block['element']['text'] []= $Line['text'];
626
+
627
+ return $Block;
628
+ }
629
+ }
630
+
631
+ #
632
+ # Rule
633
+
634
+ protected function blockRule($Line)
635
+ {
636
+ if (preg_match('/^(['.$Line['text'][0].'])([ ]*\1){2,}[ ]*$/', $Line['text']))
637
+ {
638
+ $Block = array(
639
+ 'element' => array(
640
+ 'name' => 'hr'
641
+ ),
642
+ );
643
+
644
+ return $Block;
645
+ }
646
+ }
647
+
648
+ #
649
+ # Setext
650
+
651
+ protected function blockSetextHeader($Line, array $Block = null)
652
+ {
653
+ if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
654
+ {
655
+ return;
656
+ }
657
+
658
+ if (chop($Line['text'], $Line['text'][0]) === '')
659
+ {
660
+ $Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2';
661
+
662
+ return $Block;
663
+ }
664
+ }
665
+
666
+ #
667
+ # Markup
668
+
669
+ protected function blockMarkup($Line)
670
+ {
671
+ if ($this->markupEscaped)
672
+ {
673
+ return;
674
+ }
675
+
676
+ if (preg_match('/^<(\w*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches))
677
+ {
678
+ $element = strtolower($matches[1]);
679
+
680
+ if (in_array($element, $this->textLevelElements))
681
+ {
682
+ return;
683
+ }
684
+
685
+ $Block = array(
686
+ 'name' => $matches[1],
687
+ 'depth' => 0,
688
+ 'markup' => $Line['text'],
689
+ );
690
+
691
+ $length = strlen($matches[0]);
692
+
693
+ $remainder = substr($Line['text'], $length);
694
+
695
+ if (trim($remainder) === '')
696
+ {
697
+ if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
698
+ {
699
+ $Block['closed'] = true;
700
+
701
+ $Block['void'] = true;
702
+ }
703
+ }
704
+ else
705
+ {
706
+ if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
707
+ {
708
+ return;
709
+ }
710
+
711
+ if (preg_match('/<\/'.$matches[1].'>[ ]*$/i', $remainder))
712
+ {
713
+ $Block['closed'] = true;
714
+ }
715
+ }
716
+
717
+ return $Block;
718
+ }
719
+ }
720
+
721
+ protected function blockMarkupContinue($Line, array $Block)
722
+ {
723
+ if (isset($Block['closed']))
724
+ {
725
+ return;
726
+ }
727
+
728
+ if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
729
+ {
730
+ $Block['depth'] ++;
731
+ }
732
+
733
+ if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
734
+ {
735
+ if ($Block['depth'] > 0)
736
+ {
737
+ $Block['depth'] --;
738
+ }
739
+ else
740
+ {
741
+ $Block['closed'] = true;
742
+ }
743
+ }
744
+
745
+ if (isset($Block['interrupted']))
746
+ {
747
+ $Block['markup'] .= "\n";
748
+
749
+ unset($Block['interrupted']);
750
+ }
751
+
752
+ $Block['markup'] .= "\n".$Line['body'];
753
+
754
+ return $Block;
755
+ }
756
+
757
+ #
758
+ # Reference
759
+
760
+ protected function blockReference($Line)
761
+ {
762
+ if (preg_match('/^\[(.+?)\]:[ ]*<?(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*$/', $Line['text'], $matches))
763
+ {
764
+ $id = strtolower($matches[1]);
765
+
766
+ $Data = array(
767
+ 'url' => $matches[2],
768
+ 'title' => null,
769
+ );
770
+
771
+ if (isset($matches[3]))
772
+ {
773
+ $Data['title'] = $matches[3];
774
+ }
775
+
776
+ $this->DefinitionData['Reference'][$id] = $Data;
777
+
778
+ $Block = array(
779
+ 'hidden' => true,
780
+ );
781
+
782
+ return $Block;
783
+ }
784
+ }
785
+
786
+ #
787
+ # Table
788
+
789
+ protected function blockTable($Line, array $Block = null)
790
+ {
791
+ if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
792
+ {
793
+ return;
794
+ }
795
+
796
+ if (strpos($Block['element']['text'], '|') !== false and chop($Line['text'], ' -:|') === '')
797
+ {
798
+ $alignments = array();
799
+
800
+ $divider = $Line['text'];
801
+
802
+ $divider = trim($divider);
803
+ $divider = trim($divider, '|');
804
+
805
+ $dividerCells = explode('|', $divider);
806
+
807
+ foreach ($dividerCells as $dividerCell)
808
+ {
809
+ $dividerCell = trim($dividerCell);
810
+
811
+ if ($dividerCell === '')
812
+ {
813
+ continue;
814
+ }
815
+
816
+ $alignment = null;
817
+
818
+ if ($dividerCell[0] === ':')
819
+ {
820
+ $alignment = 'left';
821
+ }
822
+
823
+ if (substr($dividerCell, - 1) === ':')
824
+ {
825
+ $alignment = $alignment === 'left' ? 'center' : 'right';
826
+ }
827
+
828
+ $alignments []= $alignment;
829
+ }
830
+
831
+ # ~
832
+
833
+ $HeaderElements = array();
834
+
835
+ $header = $Block['element']['text'];
836
+
837
+ $header = trim($header);
838
+ $header = trim($header, '|');
839
+
840
+ $headerCells = explode('|', $header);
841
+
842
+ foreach ($headerCells as $index => $headerCell)
843
+ {
844
+ $headerCell = trim($headerCell);
845
+
846
+ $HeaderElement = array(
847
+ 'name' => 'th',
848
+ 'text' => $headerCell,
849
+ 'handler' => 'line',
850
+ );
851
+
852
+ if (isset($alignments[$index]))
853
+ {
854
+ $alignment = $alignments[$index];
855
+
856
+ $HeaderElement['attributes'] = array(
857
+ 'style' => 'text-align: '.$alignment.';',
858
+ );
859
+ }
860
+
861
+ $HeaderElements []= $HeaderElement;
862
+ }
863
+
864
+ # ~
865
+
866
+ $Block = array(
867
+ 'alignments' => $alignments,
868
+ 'identified' => true,
869
+ 'element' => array(
870
+ 'name' => 'table',
871
+ 'handler' => 'elements',
872
+ ),
873
+ );
874
+
875
+ $Block['element']['text'] []= array(
876
+ 'name' => 'thead',
877
+ 'handler' => 'elements',
878
+ );
879
+
880
+ $Block['element']['text'] []= array(
881
+ 'name' => 'tbody',
882
+ 'handler' => 'elements',
883
+ 'text' => array(),
884
+ );
885
+
886
+ $Block['element']['text'][0]['text'] []= array(
887
+ 'name' => 'tr',
888
+ 'handler' => 'elements',
889
+ 'text' => $HeaderElements,
890
+ );
891
+
892
+ return $Block;
893
+ }
894
+ }
895
+
896
+ protected function blockTableContinue($Line, array $Block)
897
+ {
898
+ if (isset($Block['interrupted']))
899
+ {
900
+ return;
901
+ }
902
+
903
+ if ($Line['text'][0] === '|' or strpos($Line['text'], '|'))
904
+ {
905
+ $Elements = array();
906
+
907
+ $row = $Line['text'];
908
+
909
+ $row = trim($row);
910
+ $row = trim($row, '|');
911
+
912
+ preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]+`|`)+/', $row, $matches);
913
+
914
+ foreach ($matches[0] as $index => $cell)
915
+ {
916
+ $cell = trim($cell);
917
+
918
+ $Element = array(
919
+ 'name' => 'td',
920
+ 'handler' => 'line',
921
+ 'text' => $cell,
922
+ );
923
+
924
+ if (isset($Block['alignments'][$index]))
925
+ {
926
+ $Element['attributes'] = array(
927
+ 'style' => 'text-align: '.$Block['alignments'][$index].';',
928
+ );
929
+ }
930
+
931
+ $Elements []= $Element;
932
+ }
933
+
934
+ $Element = array(
935
+ 'name' => 'tr',
936
+ 'handler' => 'elements',
937
+ 'text' => $Elements,
938
+ );
939
+
940
+ $Block['element']['text'][1]['text'] []= $Element;
941
+
942
+ return $Block;
943
+ }
944
+ }
945
+
946
+ #
947
+ # ~
948
+ #
949
+
950
+ protected function paragraph($Line)
951
+ {
952
+ $Block = array(
953
+ 'element' => array(
954
+ 'name' => 'p',
955
+ 'text' => $Line['text'],
956
+ 'handler' => 'line',
957
+ ),
958
+ );
959
+
960
+ return $Block;
961
+ }
962
+
963
+ #
964
+ # Inline Elements
965
+ #
966
+
967
+ protected $InlineTypes = array(
968
+ '"' => array('SpecialCharacter'),
969
+ '!' => array('Image'),
970
+ '&' => array('SpecialCharacter'),
971
+ '*' => array('Emphasis'),
972
+ ':' => array('Url'),
973
+ '<' => array('UrlTag', 'EmailTag', 'Markup', 'SpecialCharacter'),
974
+ '>' => array('SpecialCharacter'),
975
+ '[' => array('Link'),
976
+ '_' => array('Emphasis'),
977
+ '`' => array('Code'),
978
+ '~' => array('Strikethrough'),
979
+ '\\' => array('EscapeSequence'),
980
+ );
981
+
982
+ # ~
983
+
984
+ protected $inlineMarkerList = '!"*_&[:<>`~\\';
985
+
986
+ #
987
+ # ~
988
+ #
989
+
990
+ public function line($text)
991
+ {
992
+ $markup = '';
993
+
994
+ # $excerpt is based on the first occurrence of a marker
995
+
996
+ while ($excerpt = strpbrk($text, $this->inlineMarkerList))
997
+ {
998
+ $marker = $excerpt[0];
999
+
1000
+ $markerPosition = strpos($text, $marker);
1001
+
1002
+ $Excerpt = array('text' => $excerpt, 'context' => $text);
1003
+
1004
+ foreach ($this->InlineTypes[$marker] as $inlineType)
1005
+ {
1006
+ $Inline = $this->{'inline'.$inlineType}($Excerpt);
1007
+
1008
+ if ( ! isset($Inline))
1009
+ {
1010
+ continue;
1011
+ }
1012
+
1013
+ # makes sure that the inline belongs to "our" marker
1014
+
1015
+ if (isset($Inline['position']) and $Inline['position'] > $markerPosition)
1016
+ {
1017
+ continue;
1018
+ }
1019
+
1020
+ # sets a default inline position
1021
+
1022
+ if ( ! isset($Inline['position']))
1023
+ {
1024
+ $Inline['position'] = $markerPosition;
1025
+ }
1026
+
1027
+ # the text that comes before the inline
1028
+ $unmarkedText = substr($text, 0, $Inline['position']);
1029
+
1030
+ # compile the unmarked text
1031
+ $markup .= $this->unmarkedText($unmarkedText);
1032
+
1033
+ # compile the inline
1034
+ $markup .= isset($Inline['markup']) ? $Inline['markup'] : $this->element($Inline['element']);
1035
+
1036
+ # remove the examined text
1037
+ $text = substr($text, $Inline['position'] + $Inline['extent']);
1038
+
1039
+ continue 2;
1040
+ }
1041
+
1042
+ # the marker does not belong to an inline
1043
+
1044
+ $unmarkedText = substr($text, 0, $markerPosition + 1);
1045
+
1046
+ $markup .= $this->unmarkedText($unmarkedText);
1047
+
1048
+ $text = substr($text, $markerPosition + 1);
1049
+ }
1050
+
1051
+ $markup .= $this->unmarkedText($text);
1052
+
1053
+ return $markup;
1054
+ }
1055
+
1056
+ #
1057
+ # ~
1058
+ #
1059
+
1060
+ protected function inlineCode($Excerpt)
1061
+ {
1062
+ $marker = $Excerpt['text'][0];
1063
+
1064
+ if (preg_match('/^('.$marker.'+)[ ]*(.+?)[ ]*(?<!'.$marker.')\1(?!'.$marker.')/s', $Excerpt['text'], $matches))
1065
+ {
1066
+ $text = $matches[2];
1067
+ $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
1068
+ $text = preg_replace("/[ ]*\n/", ' ', $text);
1069
+
1070
+ return array(
1071
+ 'extent' => strlen($matches[0]),
1072
+ 'element' => array(
1073
+ 'name' => 'code',
1074
+ 'text' => $text,
1075
+ ),
1076
+ );
1077
+ }
1078
+ }
1079
+
1080
+ protected function inlineEmailTag($Excerpt)
1081
+ {
1082
+ if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches))
1083
+ {
1084
+ $url = $matches[1];
1085
+
1086
+ if ( ! isset($matches[2]))
1087
+ {
1088
+ $url = 'mailto:' . $url;
1089
+ }
1090
+
1091
+ return array(
1092
+ 'extent' => strlen($matches[0]),
1093
+ 'element' => array(
1094
+ 'name' => 'a',
1095
+ 'text' => $matches[1],
1096
+ 'attributes' => array(
1097
+ 'href' => $url,
1098
+ ),
1099
+ ),
1100
+ );
1101
+ }
1102
+ }
1103
+
1104
+ protected function inlineEmphasis($Excerpt)
1105
+ {
1106
+ if ( ! isset($Excerpt['text'][1]))
1107
+ {
1108
+ return;
1109
+ }
1110
+
1111
+ $marker = $Excerpt['text'][0];
1112
+
1113
+ if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches))
1114
+ {
1115
+ $emphasis = 'strong';
1116
+ }
1117
+ elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches))
1118
+ {
1119
+ $emphasis = 'em';
1120
+ }
1121
+ else
1122
+ {
1123
+ return;
1124
+ }
1125
+
1126
+ return array(
1127
+ 'extent' => strlen($matches[0]),
1128
+ 'element' => array(
1129
+ 'name' => $emphasis,
1130
+ 'handler' => 'line',
1131
+ 'text' => $matches[1],
1132
+ ),
1133
+ );
1134
+ }
1135
+
1136
+ protected function inlineEscapeSequence($Excerpt)
1137
+ {
1138
+ if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters))
1139
+ {
1140
+ return array(
1141
+ 'markup' => $Excerpt['text'][1],
1142
+ 'extent' => 2,
1143
+ );
1144
+ }
1145
+ }
1146
+
1147
+ protected function inlineImage($Excerpt)
1148
+ {
1149
+ if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
1150
+ {
1151
+ return;
1152
+ }
1153
+
1154
+ $Excerpt['text']= substr($Excerpt['text'], 1);
1155
+
1156
+ $Link = $this->inlineLink($Excerpt);
1157
+
1158
+ if ($Link === null)
1159
+ {
1160
+ return;
1161
+ }
1162
+
1163
+ $Inline = array(
1164
+ 'extent' => $Link['extent'] + 1,
1165
+ 'element' => array(
1166
+ 'name' => 'img',
1167
+ 'attributes' => array(
1168
+ 'src' => $Link['element']['attributes']['href'],
1169
+ 'alt' => $Link['element']['text'],
1170
+ ),
1171
+ ),
1172
+ );
1173
+
1174
+ $Inline['element']['attributes'] += $Link['element']['attributes'];
1175
+
1176
+ unset($Inline['element']['attributes']['href']);
1177
+
1178
+ return $Inline;
1179
+ }
1180
+
1181
+ protected function inlineLink($Excerpt)
1182
+ {
1183
+ $Element = array(
1184
+ 'name' => 'a',
1185
+ 'handler' => 'line',
1186
+ 'text' => null,
1187
+ 'attributes' => array(
1188
+ 'href' => null,
1189
+ 'title' => null,
1190
+ ),
1191
+ );
1192
+
1193
+ $extent = 0;
1194
+
1195
+ $remainder = $Excerpt['text'];
1196
+
1197
+ if (preg_match('/\[((?:[^][]|(?R))*)\]/', $remainder, $matches))
1198
+ {
1199
+ $Element['text'] = $matches[1];
1200
+
1201
+ $extent += strlen($matches[0]);
1202
+
1203
+ $remainder = substr($remainder, $extent);
1204
+ }
1205
+ else
1206
+ {
1207
+ return;
1208
+ }
1209
+
1210
+ if (preg_match('/^[(]((?:[^ ()]|[(][^ )]+[)])+)(?:[ ]+("[^"]*"|\'[^\']*\'))?[)]/', $remainder, $matches))
1211
+ {
1212
+ $Element['attributes']['href'] = $matches[1];
1213
+
1214
+ if (isset($matches[2]))
1215
+ {
1216
+ $Element['attributes']['title'] = substr($matches[2], 1, - 1);
1217
+ }
1218
+
1219
+ $extent += strlen($matches[0]);
1220
+ }
1221
+ else
1222
+ {
1223
+ if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches))
1224
+ {
1225
+ $definition = strlen($matches[1]) ? $matches[1] : $Element['text'];
1226
+ $definition = strtolower($definition);
1227
+
1228
+ $extent += strlen($matches[0]);
1229
+ }
1230
+ else
1231
+ {
1232
+ $definition = strtolower($Element['text']);
1233
+ }
1234
+
1235
+ if ( ! isset($this->DefinitionData['Reference'][$definition]))
1236
+ {
1237
+ return;
1238
+ }
1239
+
1240
+ $Definition = $this->DefinitionData['Reference'][$definition];
1241
+
1242
+ $Element['attributes']['href'] = $Definition['url'];
1243
+ $Element['attributes']['title'] = $Definition['title'];
1244
+ }
1245
+
1246
+ $Element['attributes']['href'] = str_replace(array('&', '<'), array('&amp;', '&lt;'), $Element['attributes']['href']);
1247
+
1248
+ return array(
1249
+ 'extent' => $extent,
1250
+ 'element' => $Element,
1251
+ );
1252
+ }
1253
+
1254
+ protected function inlineMarkup($Excerpt)
1255
+ {
1256
+ if ($this->markupEscaped or strpos($Excerpt['text'], '>') === false)
1257
+ {
1258
+ return;
1259
+ }
1260
+
1261
+ if ($Excerpt['text'][1] === '/' and preg_match('/^<\/\w*[ ]*>/s', $Excerpt['text'], $matches))
1262
+ {
1263
+ return array(
1264
+ 'markup' => $matches[0],
1265
+ 'extent' => strlen($matches[0]),
1266
+ );
1267
+ }
1268
+
1269
+ if ($Excerpt['text'][1] === '!' and preg_match('/^<!---?[^>-](?:-?[^-])*-->/s', $Excerpt['text'], $matches))
1270
+ {
1271
+ return array(
1272
+ 'markup' => $matches[0],
1273
+ 'extent' => strlen($matches[0]),
1274
+ );
1275
+ }
1276
+
1277
+ if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w*(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*\/?>/s', $Excerpt['text'], $matches))
1278
+ {
1279
+ return array(
1280
+ 'markup' => $matches[0],
1281
+ 'extent' => strlen($matches[0]),
1282
+ );
1283
+ }
1284
+ }
1285
+
1286
+ protected function inlineSpecialCharacter($Excerpt)
1287
+ {
1288
+ if ($Excerpt['text'][0] === '&' and ! preg_match('/^&#?\w+;/', $Excerpt['text']))
1289
+ {
1290
+ return array(
1291
+ 'markup' => '&amp;',
1292
+ 'extent' => 1,
1293
+ );
1294
+ }
1295
+
1296
+ $SpecialCharacter = array('>' => 'gt', '<' => 'lt', '"' => 'quot');
1297
+
1298
+ if (isset($SpecialCharacter[$Excerpt['text'][0]]))
1299
+ {
1300
+ return array(
1301
+ 'markup' => '&'.$SpecialCharacter[$Excerpt['text'][0]].';',
1302
+ 'extent' => 1,
1303
+ );
1304
+ }
1305
+ }
1306
+
1307
+ protected function inlineStrikethrough($Excerpt)
1308
+ {
1309
+ if ( ! isset($Excerpt['text'][1]))
1310
+ {
1311
+ return;
1312
+ }
1313
+
1314
+ if ($Excerpt['text'][1] === '~' and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches))
1315
+ {
1316
+ return array(
1317
+ 'extent' => strlen($matches[0]),
1318
+ 'element' => array(
1319
+ 'name' => 'del',
1320
+ 'text' => $matches[1],
1321
+ 'handler' => 'line',
1322
+ ),
1323
+ );
1324
+ }
1325
+ }
1326
+
1327
+ protected function inlineUrl($Excerpt)
1328
+ {
1329
+ if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/')
1330
+ {
1331
+ return;
1332
+ }
1333
+
1334
+ if (preg_match('/\bhttps?:[\/]{2}[^\s<]+\b\/*/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE))
1335
+ {
1336
+ $Inline = array(
1337
+ 'extent' => strlen($matches[0][0]),
1338
+ 'position' => $matches[0][1],
1339
+ 'element' => array(
1340
+ 'name' => 'a',
1341
+ 'text' => $matches[0][0],
1342
+ 'attributes' => array(
1343
+ 'href' => $matches[0][0],
1344
+ ),
1345
+ ),
1346
+ );
1347
+
1348
+ return $Inline;
1349
+ }
1350
+ }
1351
+
1352
+ protected function inlineUrlTag($Excerpt)
1353
+ {
1354
+ if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $Excerpt['text'], $matches))
1355
+ {
1356
+ $url = str_replace(array('&', '<'), array('&amp;', '&lt;'), $matches[1]);
1357
+
1358
+ return array(
1359
+ 'extent' => strlen($matches[0]),
1360
+ 'element' => array(
1361
+ 'name' => 'a',
1362
+ 'text' => $url,
1363
+ 'attributes' => array(
1364
+ 'href' => $url,
1365
+ ),
1366
+ ),
1367
+ );
1368
+ }
1369
+ }
1370
+
1371
+ # ~
1372
+
1373
+ protected function unmarkedText($text)
1374
+ {
1375
+ if ($this->breaksEnabled)
1376
+ {
1377
+ $text = preg_replace('/[ ]*\n/', "<br />\n", $text);
1378
+ }
1379
+ else
1380
+ {
1381
+ $text = preg_replace('/(?:[ ][ ]+|[ ]*\\\\)\n/', "<br />\n", $text);
1382
+ $text = str_replace(" \n", "\n", $text);
1383
+ }
1384
+
1385
+ return $text;
1386
+ }
1387
+
1388
+ #
1389
+ # Handlers
1390
+ #
1391
+
1392
+ protected function element(array $Element)
1393
+ {
1394
+ $markup = '<'.$Element['name'];
1395
+
1396
+ if (isset($Element['attributes']))
1397
+ {
1398
+ foreach ($Element['attributes'] as $name => $value)
1399
+ {
1400
+ if ($value === null)
1401
+ {
1402
+ continue;
1403
+ }
1404
+
1405
+ $markup .= ' '.$name.'="'.$value.'"';
1406
+ }
1407
+ }
1408
+
1409
+ if (isset($Element['text']))
1410
+ {
1411
+ $markup .= '>';
1412
+
1413
+ if (isset($Element['handler']))
1414
+ {
1415
+ $markup .= $this->{$Element['handler']}($Element['text']);
1416
+ }
1417
+ else
1418
+ {
1419
+ $markup .= $Element['text'];
1420
+ }
1421
+
1422
+ $markup .= '</'.$Element['name'].'>';
1423
+ }
1424
+ else
1425
+ {
1426
+ $markup .= ' />';
1427
+ }
1428
+
1429
+ return $markup;
1430
+ }
1431
+
1432
+ protected function elements(array $Elements)
1433
+ {
1434
+ $markup = '';
1435
+
1436
+ foreach ($Elements as $Element)
1437
+ {
1438
+ $markup .= "\n" . $this->element($Element);
1439
+ }
1440
+
1441
+ $markup .= "\n";
1442
+
1443
+ return $markup;
1444
+ }
1445
+
1446
+ # ~
1447
+
1448
+ protected function li($lines)
1449
+ {
1450
+ $markup = $this->lines($lines);
1451
+
1452
+ $trimmedMarkup = trim($markup);
1453
+
1454
+ if ( ! in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '<p>')
1455
+ {
1456
+ $markup = $trimmedMarkup;
1457
+ $markup = substr($markup, 3);
1458
+
1459
+ $position = strpos($markup, "</p>");
1460
+
1461
+ $markup = substr_replace($markup, '', $position, 4);
1462
+ }
1463
+
1464
+ return $markup;
1465
+ }
1466
+
1467
+ #
1468
+ # Deprecated Methods
1469
+ #
1470
+
1471
+ function parse($text)
1472
+ {
1473
+ $markup = $this->text($text);
1474
+
1475
+ return $markup;
1476
+ }
1477
+
1478
+ #
1479
+ # Static Methods
1480
+ #
1481
+
1482
+ static function instance($name = 'default')
1483
+ {
1484
+ if (isset(self::$instances[$name]))
1485
+ {
1486
+ return self::$instances[$name];
1487
+ }
1488
+
1489
+ $instance = new static();
1490
+
1491
+ self::$instances[$name] = $instance;
1492
+
1493
+ return $instance;
1494
+ }
1495
+
1496
+ private static $instances = array();
1497
+
1498
+ #
1499
+ # Fields
1500
+ #
1501
+
1502
+ protected $DefinitionData;
1503
+
1504
+ #
1505
+ # Read-Only
1506
+
1507
+ protected $specialCharacters = array(
1508
+ '\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|',
1509
+ );
1510
+
1511
+ protected $StrongRegex = array(
1512
+ '*' => '/^[*]{2}((?:\\\\\*|[^*]|[*][^*]*[*])+?)[*]{2}(?![*])/s',
1513
+ '_' => '/^__((?:\\\\_|[^_]|_[^_]*_)+?)__(?!_)/us',
1514
+ );
1515
+
1516
+ protected $EmRegex = array(
1517
+ '*' => '/^[*]((?:\\\\\*|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s',
1518
+ '_' => '/^_((?:\\\\_|[^_]|__[^_]*__)+?)_(?!_)\b/us',
1519
+ );
1520
+
1521
+ protected $regexHtmlAttribute = '[a-zA-Z_:][\w:.-]*(?:\s*=\s*(?:[^"\'=<>`\s]+|"[^"]*"|\'[^\']*\'))?';
1522
+
1523
+ protected $voidElements = array(
1524
+ 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source',
1525
+ );
1526
+
1527
+ protected $textLevelElements = array(
1528
+ 'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont',
1529
+ 'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing',
1530
+ 'i', 'rp', 'del', 'code', 'strike', 'marquee',
1531
+ 'q', 'rt', 'ins', 'font', 'strong',
1532
+ 's', 'tt', 'sub', 'mark',
1533
+ 'u', 'xm', 'sup', 'nobr',
1534
+ 'var', 'ruby',
1535
+ 'wbr', 'span',
1536
+ 'time',
1537
+ );
1538
+ }
lib/plugin-update-checker/vendor/PucReadmeParser.php ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('PucReadmeParser', false) ):
4
+
5
+ /**
6
+ * This is a slightly modified version of github.com/markjaquith/WordPress-Plugin-Readme-Parser
7
+ * It uses Parsedown instead of the "Markdown Extra" parser.
8
+ */
9
+
10
+ class PucReadmeParser {
11
+
12
+ function __construct() {
13
+ // This space intentionally blank
14
+ }
15
+
16
+ function parse_readme( $file ) {
17
+ $file_contents = @implode('', @file($file));
18
+ return $this->parse_readme_contents( $file_contents );
19
+ }
20
+
21
+ function parse_readme_contents( $file_contents ) {
22
+ $file_contents = str_replace(array("\r\n", "\r"), "\n", $file_contents);
23
+ $file_contents = trim($file_contents);
24
+ if ( 0 === strpos( $file_contents, "\xEF\xBB\xBF" ) )
25
+ $file_contents = substr( $file_contents, 3 );
26
+
27
+ // Markdown transformations
28
+ $file_contents = preg_replace( "|^###([^#]+)#*?\s*?\n|im", '=$1='."\n", $file_contents );
29
+ $file_contents = preg_replace( "|^##([^#]+)#*?\s*?\n|im", '==$1=='."\n", $file_contents );
30
+ $file_contents = preg_replace( "|^#([^#]+)#*?\s*?\n|im", '===$1==='."\n", $file_contents );
31
+
32
+ // === Plugin Name ===
33
+ // Must be the very first thing.
34
+ if ( !preg_match('|^===(.*)===|', $file_contents, $_name) )
35
+ return array(); // require a name
36
+ $name = trim($_name[1], '=');
37
+ $name = $this->sanitize_text( $name );
38
+
39
+ $file_contents = $this->chop_string( $file_contents, $_name[0] );
40
+
41
+
42
+ // Requires at least: 1.5
43
+ if ( preg_match('|Requires at least:(.*)|i', $file_contents, $_requires_at_least) )
44
+ $requires_at_least = $this->sanitize_text($_requires_at_least[1]);
45
+ else
46
+ $requires_at_least = NULL;
47
+
48
+
49
+ // Tested up to: 2.1
50
+ if ( preg_match('|Tested up to:(.*)|i', $file_contents, $_tested_up_to) )
51
+ $tested_up_to = $this->sanitize_text( $_tested_up_to[1] );
52
+ else
53
+ $tested_up_to = NULL;
54
+
55
+
56
+ // Stable tag: 10.4-ride-the-fire-eagle-danger-day
57
+ if ( preg_match('|Stable tag:(.*)|i', $file_contents, $_stable_tag) )
58
+ $stable_tag = $this->sanitize_text( $_stable_tag[1] );
59
+ else
60
+ $stable_tag = NULL; // we assume trunk, but don't set it here to tell the difference between specified trunk and default trunk
61
+
62
+
63
+ // Tags: some tag, another tag, we like tags
64
+ if ( preg_match('|Tags:(.*)|i', $file_contents, $_tags) ) {
65
+ $tags = preg_split('|,[\s]*?|', trim($_tags[1]));
66
+ foreach ( array_keys($tags) as $t )
67
+ $tags[$t] = $this->sanitize_text( $tags[$t] );
68
+ } else {
69
+ $tags = array();
70
+ }
71
+
72
+
73
+ // Contributors: markjaquith, mdawaffe, zefrank
74
+ $contributors = array();
75
+ if ( preg_match('|Contributors:(.*)|i', $file_contents, $_contributors) ) {
76
+ $temp_contributors = preg_split('|,[\s]*|', trim($_contributors[1]));
77
+ foreach ( array_keys($temp_contributors) as $c ) {
78
+ $tmp_sanitized = $this->user_sanitize( $temp_contributors[$c] );
79
+ if ( strlen(trim($tmp_sanitized)) > 0 )
80
+ $contributors[$c] = $tmp_sanitized;
81
+ unset($tmp_sanitized);
82
+ }
83
+ }
84
+
85
+
86
+ // Donate Link: URL
87
+ if ( preg_match('|Donate link:(.*)|i', $file_contents, $_donate_link) )
88
+ $donate_link = esc_url( $_donate_link[1] );
89
+ else
90
+ $donate_link = NULL;
91
+
92
+
93
+ // togs, conts, etc are optional and order shouldn't matter. So we chop them only after we've grabbed their values.
94
+ foreach ( array('tags', 'contributors', 'requires_at_least', 'tested_up_to', 'stable_tag', 'donate_link') as $chop ) {
95
+ if ( $$chop ) {
96
+ $_chop = '_' . $chop;
97
+ $file_contents = $this->chop_string( $file_contents, ${$_chop}[0] );
98
+ }
99
+ }
100
+
101
+ $file_contents = trim($file_contents);
102
+
103
+
104
+ // short-description fu
105
+ if ( !preg_match('/(^(.*?))^[\s]*=+?[\s]*.+?[\s]*=+?/ms', $file_contents, $_short_description) )
106
+ $_short_description = array( 1 => &$file_contents, 2 => &$file_contents );
107
+ $short_desc_filtered = $this->sanitize_text( $_short_description[2] );
108
+ $short_desc_length = strlen($short_desc_filtered);
109
+ $short_description = substr($short_desc_filtered, 0, 150);
110
+ if ( $short_desc_length > strlen($short_description) )
111
+ $truncated = true;
112
+ else
113
+ $truncated = false;
114
+ if ( $_short_description[1] )
115
+ $file_contents = $this->chop_string( $file_contents, $_short_description[1] ); // yes, the [1] is intentional
116
+
117
+ // == Section ==
118
+ // Break into sections
119
+ // $_sections[0] will be the title of the first section, $_sections[1] will be the content of the first section
120
+ // the array alternates from there: title2, content2, title3, content3... and so forth
121
+ $_sections = preg_split('/^[\s]*==[\s]*(.+?)[\s]*==/m', $file_contents, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
122
+
123
+ $sections = array();
124
+ for ( $i=0; $i < count($_sections); $i +=2 ) {
125
+ $title = $this->sanitize_text( $_sections[$i] );
126
+ if ( isset($_sections[$i+1]) ) {
127
+ $content = preg_replace('/(^[\s]*)=[\s]+(.+?)[\s]+=/m', '$1<h4>$2</h4>', $_sections[$i+1]);
128
+ $content = $this->filter_text( $content, true );
129
+ } else {
130
+ $content = '';
131
+ }
132
+ $sections[str_replace(' ', '_', strtolower($title))] = array('title' => $title, 'content' => $content);
133
+ }
134
+
135
+
136
+ // Special sections
137
+ // This is where we nab our special sections, so we can enforce their order and treat them differently, if needed
138
+ // upgrade_notice is not a section, but parse it like it is for now
139
+ $final_sections = array();
140
+ foreach ( array('description', 'installation', 'frequently_asked_questions', 'screenshots', 'changelog', 'change_log', 'upgrade_notice') as $special_section ) {
141
+ if ( isset($sections[$special_section]) ) {
142
+ $final_sections[$special_section] = $sections[$special_section]['content'];
143
+ unset($sections[$special_section]);
144
+ }
145
+ }
146
+ if ( isset($final_sections['change_log']) && empty($final_sections['changelog']) )
147
+ $final_sections['changelog'] = $final_sections['change_log'];
148
+
149
+
150
+ $final_screenshots = array();
151
+ if ( isset($final_sections['screenshots']) ) {
152
+ preg_match_all('|<li>(.*?)</li>|s', $final_sections['screenshots'], $screenshots, PREG_SET_ORDER);
153
+ if ( $screenshots ) {
154
+ foreach ( (array) $screenshots as $ss )
155
+ $final_screenshots[] = $ss[1];
156
+ }
157
+ }
158
+
159
+ // Parse the upgrade_notice section specially:
160
+ // 1.0 => blah, 1.1 => fnord
161
+ $upgrade_notice = array();
162
+ if ( isset($final_sections['upgrade_notice']) ) {
163
+ $split = preg_split( '#<h4>(.*?)</h4>#', $final_sections['upgrade_notice'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
164
+ if ( count($split) >= 2 ) {
165
+ for ( $i = 0; $i < count( $split ); $i += 2 ) {
166
+ $upgrade_notice[$this->sanitize_text( $split[$i] )] = substr( $this->sanitize_text( $split[$i + 1] ), 0, 300 );
167
+ }
168
+ }
169
+ unset( $final_sections['upgrade_notice'] );
170
+ }
171
+
172
+ // No description?
173
+ // No problem... we'll just fall back to the old style of description
174
+ // We'll even let you use markup this time!
175
+ $excerpt = false;
176
+ if ( !isset($final_sections['description']) ) {
177
+ $final_sections = array_merge(array('description' => $this->filter_text( $_short_description[2], true )), $final_sections);
178
+ $excerpt = true;
179
+ }
180
+
181
+
182
+ // dump the non-special sections into $remaining_content
183
+ // their order will be determined by their original order in the readme.txt
184
+ $remaining_content = '';
185
+ foreach ( $sections as $s_name => $s_data ) {
186
+ $remaining_content .= "\n<h3>{$s_data['title']}</h3>\n{$s_data['content']}";
187
+ }
188
+ $remaining_content = trim($remaining_content);
189
+
190
+
191
+ // All done!
192
+ // $r['tags'] and $r['contributors'] are simple arrays
193
+ // $r['sections'] is an array with named elements
194
+ $r = array(
195
+ 'name' => $name,
196
+ 'tags' => $tags,
197
+ 'requires_at_least' => $requires_at_least,
198
+ 'tested_up_to' => $tested_up_to,
199
+ 'stable_tag' => $stable_tag,
200
+ 'contributors' => $contributors,
201
+ 'donate_link' => $donate_link,
202
+ 'short_description' => $short_description,
203
+ 'screenshots' => $final_screenshots,
204
+ 'is_excerpt' => $excerpt,
205
+ 'is_truncated' => $truncated,
206
+ 'sections' => $final_sections,
207
+ 'remaining_content' => $remaining_content,
208
+ 'upgrade_notice' => $upgrade_notice
209
+ );
210
+
211
+ return $r;
212
+ }
213
+
214
+ function chop_string( $string, $chop ) { // chop a "prefix" from a string: Agressive! uses strstr not 0 === strpos
215
+ if ( $_string = strstr($string, $chop) ) {
216
+ $_string = substr($_string, strlen($chop));
217
+ return trim($_string);
218
+ } else {
219
+ return trim($string);
220
+ }
221
+ }
222
+
223
+ function user_sanitize( $text, $strict = false ) { // whitelisted chars
224
+ if ( function_exists('user_sanitize') ) // bbPress native
225
+ return user_sanitize( $text, $strict );
226
+
227
+ if ( $strict ) {
228
+ $text = preg_replace('/[^a-z0-9-]/i', '', $text);
229
+ $text = preg_replace('|-+|', '-', $text);
230
+ } else {
231
+ $text = preg_replace('/[^a-z0-9_-]/i', '', $text);
232
+ }
233
+ return $text;
234
+ }
235
+
236
+ function sanitize_text( $text ) { // not fancy
237
+ $text = strip_tags($text);
238
+ $text = esc_html($text);
239
+ $text = trim($text);
240
+ return $text;
241
+ }
242
+
243
+ function filter_text( $text, $markdown = false ) { // fancy, Markdown
244
+ $text = trim($text);
245
+
246
+ $text = call_user_func( array( __CLASS__, 'code_trick' ), $text, $markdown ); // A better parser than Markdown's for: backticks -> CODE
247
+
248
+ if ( $markdown ) { // Parse markdown.
249
+ if ( !class_exists('Parsedown', false) ) {
250
+ /** @noinspection PhpIncludeInspection */
251
+ require_once(dirname(__FILE__) . '/Parsedown' . (version_compare(PHP_VERSION, '5.3.0', '>=') ? '' : 'Legacy') . '.php');
252
+ }
253
+ $instance = Parsedown::instance();
254
+ $text = $instance->text($text);
255
+ }
256
+
257
+ $allowed = array(
258
+ 'a' => array(
259
+ 'href' => array(),
260
+ 'title' => array(),
261
+ 'rel' => array()),
262
+ 'blockquote' => array('cite' => array()),
263
+ 'br' => array(),
264
+ 'p' => array(),
265
+ 'code' => array(),
266
+ 'pre' => array(),
267
+ 'em' => array(),
268
+ 'strong' => array(),
269
+ 'ul' => array(),
270
+ 'ol' => array(),
271
+ 'li' => array(),
272
+ 'h3' => array(),
273
+ 'h4' => array()
274
+ );
275
+
276
+ $text = balanceTags($text);
277
+
278
+ $text = wp_kses( $text, $allowed );
279
+ $text = trim($text);
280
+ return $text;
281
+ }
282
+
283
+ function code_trick( $text, $markdown ) { // Don't use bbPress native function - it's incompatible with Markdown
284
+ // If doing markdown, first take any user formatted code blocks and turn them into backticks so that
285
+ // markdown will preserve things like underscores in code blocks
286
+ if ( $markdown )
287
+ $text = preg_replace_callback("!(<pre><code>|<code>)(.*?)(</code></pre>|</code>)!s", array( __CLASS__,'decodeit'), $text);
288
+
289
+ $text = str_replace(array("\r\n", "\r"), "\n", $text);
290
+ if ( !$markdown ) {
291
+ // This gets the "inline" code blocks, but can't be used with Markdown.
292
+ $text = preg_replace_callback("|(`)(.*?)`|", array( __CLASS__, 'encodeit'), $text);
293
+ // This gets the "block level" code blocks and converts them to PRE CODE
294
+ $text = preg_replace_callback("!(^|\n)`(.*?)`!s", array( __CLASS__, 'encodeit'), $text);
295
+ } else {
296
+ // Markdown can do inline code, we convert bbPress style block level code to Markdown style
297
+ $text = preg_replace_callback("!(^|\n)([ \t]*?)`(.*?)`!s", array( __CLASS__, 'indent'), $text);
298
+ }
299
+ return $text;
300
+ }
301
+
302
+ function indent( $matches ) {
303
+ $text = $matches[3];
304
+ $text = preg_replace('|^|m', $matches[2] . ' ', $text);
305
+ return $matches[1] . $text;
306
+ }
307
+
308
+ function encodeit( $matches ) {
309
+ if ( function_exists('encodeit') ) // bbPress native
310
+ return encodeit( $matches );
311
+
312
+ $text = trim($matches[2]);
313
+ $text = htmlspecialchars($text, ENT_QUOTES);
314
+ $text = str_replace(array("\r\n", "\r"), "\n", $text);
315
+ $text = preg_replace("|\n\n\n+|", "\n\n", $text);
316
+ $text = str_replace('&amp;lt;', '&lt;', $text);
317
+ $text = str_replace('&amp;gt;', '&gt;', $text);
318
+ $text = "<code>$text</code>";
319
+ if ( "`" != $matches[1] )
320
+ $text = "<pre>$text</pre>";
321
+ return $text;
322
+ }
323
+
324
+ function decodeit( $matches ) {
325
+ if ( function_exists('decodeit') ) // bbPress native
326
+ return decodeit( $matches );
327
+
328
+ $text = $matches[2];
329
+ $trans_table = array_flip(get_html_translation_table(HTML_ENTITIES));
330
+ $text = strtr($text, $trans_table);
331
+ $text = str_replace('<br />', '', $text);
332
+ $text = str_replace('&#38;', '&', $text);
333
+ $text = str_replace('&#39;', "'", $text);
334
+ if ( '<pre><code>' == $matches[1] )
335
+ $text = "\n$text\n";
336
+ return "`$text`";
337
+ }
338
+
339
+ } // end class
340
+
341
+ endif;
main.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Simple Download Monitor
4
  * Plugin URI: https://simple-download-monitor.com/
5
  * Description: Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
6
- * Version: 3.8.2
7
  * Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
8
  * Author URI: https://www.tipsandtricks-hq.com/development-center
9
  * License: GPL2
@@ -14,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
15
  }
16
 
17
- define( 'WP_SIMPLE_DL_MONITOR_VERSION', '3.8.2' );
18
  define( 'WP_SIMPLE_DL_MONITOR_DIR_NAME', dirname( plugin_basename( __FILE__ ) ) );
19
  define( 'WP_SIMPLE_DL_MONITOR_URL', plugins_url( '', __FILE__ ) );
20
  define( 'WP_SIMPLE_DL_MONITOR_PATH', plugin_dir_path( __FILE__ ) );
@@ -38,6 +38,11 @@ include_once('sdm-post-type-and-taxonomy.php');
38
  include_once('sdm-shortcodes.php');
39
  include_once('sdm-post-type-content-handler.php');
40
 
 
 
 
 
 
41
  //Activation hook handler
42
  register_activation_hook( __FILE__, 'sdm_install_db_table' );
43
 
@@ -94,7 +99,7 @@ function sdm_init_time_tasks() {
94
  //Handle download request if any
95
  handle_sdm_download_via_direct_post();
96
 
97
- //Check if the redirect option is being used
98
  sdm_check_redirect_query_and_settings();
99
 
100
  if ( is_admin() ) {
@@ -375,7 +380,7 @@ class simpleDownloadManager {
375
  wp_nonce_field( 'sdm_dispatch_box_nonce', 'sdm_dispatch_box_nonce_check' );
376
  }
377
 
378
- // Open Download in new window
379
  public function display_sdm_misc_properties_meta_box( $post ) {
380
 
381
  //Check the open in new window value
@@ -396,7 +401,7 @@ class simpleDownloadManager {
396
  echo '<p> <input id="sdm_item_new_window" type="checkbox" name="sdm_item_new_window" value="yes"' . checked( true, $new_window, false ) . ' />';
397
  echo '<label for="sdm_item_new_window">' . __( 'Open download in a new window.', 'simple-download-monitor' ) . '</label> </p>';
398
 
399
- //the new window will have no download button
400
  echo '<p> <input id="sdm_item_hide_dl_button_single_download_page" type="checkbox" name="sdm_item_hide_dl_button_single_download_page" value="yes"' . checked( true, $sdm_item_hide_dl_button_single_download_page, false ) . ' />';
401
  echo '<label for="sdm_item_hide_dl_button_single_download_page">';
402
 
@@ -771,7 +776,7 @@ class simpleDownloadManager {
771
  }
772
 
773
  public function termscond_options_cb() {
774
-
775
  }
776
 
777
  public function adsense_options_cb() {
3
  * Plugin Name: Simple Download Monitor
4
  * Plugin URI: https://simple-download-monitor.com/
5
  * Description: Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
6
+ * Version: 3.8.3
7
  * Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
8
  * Author URI: https://www.tipsandtricks-hq.com/development-center
9
  * License: GPL2
14
  exit;
15
  }
16
 
17
+ define( 'WP_SIMPLE_DL_MONITOR_VERSION', '3.8.3' );
18
  define( 'WP_SIMPLE_DL_MONITOR_DIR_NAME', dirname( plugin_basename( __FILE__ ) ) );
19
  define( 'WP_SIMPLE_DL_MONITOR_URL', plugins_url( '', __FILE__ ) );
20
  define( 'WP_SIMPLE_DL_MONITOR_PATH', plugin_dir_path( __FILE__ ) );
38
  include_once('sdm-shortcodes.php');
39
  include_once('sdm-post-type-content-handler.php');
40
 
41
+ if ( is_admin() ) {
42
+ //load addons update checker class
43
+ include_once WP_SIMPLE_DL_MONITOR_PATH . 'includes/class-sdm-addons-updater.php';
44
+ }
45
+
46
  //Activation hook handler
47
  register_activation_hook( __FILE__, 'sdm_install_db_table' );
48
 
99
  //Handle download request if any
100
  handle_sdm_download_via_direct_post();
101
 
102
+ //Check if the redirect option is being used
103
  sdm_check_redirect_query_and_settings();
104
 
105
  if ( is_admin() ) {
380
  wp_nonce_field( 'sdm_dispatch_box_nonce', 'sdm_dispatch_box_nonce_check' );
381
  }
382
 
383
+ // Open Download in new window
384
  public function display_sdm_misc_properties_meta_box( $post ) {
385
 
386
  //Check the open in new window value
401
  echo '<p> <input id="sdm_item_new_window" type="checkbox" name="sdm_item_new_window" value="yes"' . checked( true, $new_window, false ) . ' />';
402
  echo '<label for="sdm_item_new_window">' . __( 'Open download in a new window.', 'simple-download-monitor' ) . '</label> </p>';
403
 
404
+ //the new window will have no download button
405
  echo '<p> <input id="sdm_item_hide_dl_button_single_download_page" type="checkbox" name="sdm_item_hide_dl_button_single_download_page" value="yes"' . checked( true, $sdm_item_hide_dl_button_single_download_page, false ) . ' />';
406
  echo '<label for="sdm_item_hide_dl_button_single_download_page">';
407
 
776
  }
777
 
778
  public function termscond_options_cb() {
779
+
780
  }
781
 
782
  public function adsense_options_cb() {
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Tips and Tricks HQ, Ruhul Amin, josh401, mbrsolution, alexanderfox
3
  Donate link: https://www.tipsandtricks-hq.com
4
  Tags: download, downloads, count, counter, tracker, tracking, hits, logging, monitor, manager, files, media, digital, download monitor, download manager, downloadmanager, file manager, protect downloads, password, download category, file tree, ajax, download template, grid, documents, ip address
5
  Requires at least: 4.1.0
6
- Tested up to: 5.3
7
- Stable tag: 3.8.2
8
  License: GPLv2 or later
9
 
10
  Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
@@ -186,6 +186,11 @@ For screenshots please visit the [download monitor plugin page](https://www.tips
186
 
187
  == Changelog ==
188
 
 
 
 
 
 
189
  = 3.8.2 =
190
  - Added action hooks for password protected downloads (when a download request is submitted without a password or incorrect password).
191
  - Added the Norwegian language translation files. Thanks to Tore Østerlie.
3
  Donate link: https://www.tipsandtricks-hq.com
4
  Tags: download, downloads, count, counter, tracker, tracking, hits, logging, monitor, manager, files, media, digital, download monitor, download manager, downloadmanager, file manager, protect downloads, password, download category, file tree, ajax, download template, grid, documents, ip address
5
  Requires at least: 4.1.0
6
+ Tested up to: 5.4
7
+ Stable tag: 3.8.3
8
  License: GPLv2 or later
9
 
10
  Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
186
 
187
  == Changelog ==
188
 
189
+ = 3.8.3 =
190
+ - Spanish translation file updated.
191
+ - Better handling of the stats admin menu interface in mobile devices.
192
+ - Addon updates are now handled by the main plugin.
193
+
194
  = 3.8.2 =
195
  - Added action hooks for password protected downloads (when a download request is submitted without a password or incorrect password).
196
  - Added the Norwegian language translation files. Thanks to Tore Østerlie.