WP Retina 2x - Version 5.2.9

Version Description

None.

Download this release

Release Info

Developer TigrouMeow
Plugin Icon 128x128 WP Retina 2x
Version 5.2.9
Comparing to
See all releases

Code changes from version 5.2.8 to 5.2.9

ajax.php CHANGED
@@ -227,9 +227,12 @@ class Meow_WR2X_Ajax {
227
  $this->core->delete_attachment( $attachmentId, false );
228
 
229
  // Regenerate the Thumbnails
230
- //$file = get_attached_file( $attachmentId );
231
- //$meta = wp_generate_attachment_metadata( $attachmentId, $file );
232
- //wp_update_attachment_metadata( $attachmentId, $meta );
 
 
 
233
 
234
  // Regenerate Retina
235
  $meta = wp_get_attachment_metadata( $attachmentId );
227
  $this->core->delete_attachment( $attachmentId, false );
228
 
229
  // Regenerate the Thumbnails
230
+ $regenerate = get_option( 'wr2x_regenerate_thumbnails', false );
231
+ if ( $regenerate ) {
232
+ $file = get_attached_file( $attachmentId );
233
+ $meta = wp_generate_attachment_metadata( $attachmentId, $file );
234
+ wp_update_attachment_metadata( $attachmentId, $meta );
235
+ }
236
 
237
  // Regenerate Retina
238
  $meta = wp_get_attachment_metadata( $attachmentId );
common/admin.css CHANGED
@@ -1,4 +1,64 @@
1
- /* MEOW BOX (SETTINGS BOX) */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  .meow-box {
4
  box-sizing: border-box;
1
+ /* MEOW-TABS */
2
+
3
+ .meow-tabs {
4
+ display: flex;
5
+ flex-wrap: wrap;
6
+ box-sizing: border-box;
7
+ }
8
+
9
+ .meow-tabs * {
10
+ box-sizing: border-box;
11
+ }
12
+
13
+ .meow-tabs .meow-tabs-input {
14
+ position: absolute;
15
+ opacity: 0;
16
+ }
17
+
18
+ .meow-tabs .meow-tabs-label {
19
+ width: auto;
20
+ padding: 4px 12px;
21
+ background: #3c3c3c;
22
+ cursor: pointer;
23
+ font-weight: bold;
24
+ font-size: 13px;
25
+ text-transform: uppercase;
26
+ color: white;
27
+ transition: background 0.1s, color 0.1s;
28
+ }
29
+
30
+ .meow-tabs .inside {
31
+ display: none;
32
+ width: 100%;
33
+ }
34
+
35
+ .meow-tabs .meow-tabs-label:hover {
36
+ background: #36495f;
37
+ }
38
+
39
+ .meow-tabs .meow-tabs-label:active {
40
+ background: #3C82C7;
41
+ }
42
+
43
+ .meow-tabs .meow-tabs-input:focus + .meow-tabs-label {
44
+ box-shadow: inset 0px 0px 0px 3px #2aa1c0;
45
+ z-index: 1;
46
+ }
47
+
48
+ .meow-tabs .meow-tabs-input:checked + .meow-tabs-label {
49
+ background: #3C82C7 !important;
50
+ }
51
+
52
+ .meow-tabs-input:checked + .meow-tabs-label + .inside {
53
+ display: block;
54
+ order: 99;
55
+ }
56
+
57
+ .meow-tabs .inside {
58
+ background: #fff;
59
+ }
60
+
61
+ /* MEOW-BOX */
62
 
63
  .meow-box {
64
  box-sizing: border-box;
dashboard.php CHANGED
@@ -7,12 +7,6 @@ class Meow_WR2X_Dashboard {
7
  public function __construct( $core ) {
8
  $this->core = $core;
9
  add_action( 'admin_menu', array( $this, 'admin_menu_dashboard' ) );
10
- add_filter( 'updraftplus_com_link', array( $this, 'updraftplus_com_link' ) );
11
- }
12
-
13
- function updraftplus_com_link( $url ) {
14
- $url = $url . "?afref=460";
15
- return $url;
16
  }
17
 
18
  function admin_menu_dashboard () {
@@ -214,6 +208,19 @@ class Meow_WR2X_Dashboard {
214
  ?>
215
  </p>
216
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  <?php
218
  if ( !$this->core->admin->is_registered() && !get_option( "wr2x_hide_pro", false ) ) {
219
  echo '<div class="updated"><p>';
7
  public function __construct( $core ) {
8
  $this->core = $core;
9
  add_action( 'admin_menu', array( $this, 'admin_menu_dashboard' ) );
 
 
 
 
 
 
10
  }
11
 
12
  function admin_menu_dashboard () {
208
  ?>
209
  </p>
210
 
211
+ <?php
212
+ $method = get_option( 'wr2x_method' );
213
+ $cdn = get_option( 'wr2x_cdn_domain' );
214
+ $disable_responsive = get_option( 'wr2x_disable_responsive', false );
215
+ $keep_src = get_option( 'wr2x_picturefill_keep_src', false );
216
+
217
+ if ( $method == 'HTML Rewrite' || $method == 'Retina-Images' || !empty( $cdn ) || $disable_responsive || $keep_src ) {
218
+ echo '<div class="error"><p>';
219
+ echo __( '<b>WARNING</b>. You are using an option that will be removed in a future release. The plan is to remove two methods (HTML Rewrite and Retina-Images), Disable Responsive, Custom CDN Domain, and Keep IMG SRC. Those options are not necessary, and it is better to keep the plugin clean and focus. This warning message will go away if you avoid using those options (and will disappear in a future release). If you are using one of those options and really would like to keep it, please come here to talk about it: <a target= "_blank" href="https://wordpress.org/support/topic/simplifying-wp-retina-2x-by-removing-options/">Discussions about removing options from WP Retina 2x</a>. Thanks :)', 'wp-retina-2x' );
220
+ echo '</p></div>';
221
+ }
222
+ ?>
223
+
224
  <?php
225
  if ( !$this->core->admin->is_registered() && !get_option( "wr2x_hide_pro", false ) ) {
226
  echo '<div class="updated"><p>';
trunk/ajax.php ADDED
@@ -0,0 +1,391 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Meow_WR2X_Ajax {
4
+
5
+ public $core = null;
6
+
7
+ public function __construct( $core) {
8
+ $this->core = $core;
9
+ add_action( 'wp_ajax_wr2x_generate', array( $this, 'wp_ajax_wr2x_generate' ) );
10
+ add_action( 'wp_ajax_wr2x_delete', array( $this, 'wp_ajax_wr2x_delete' ) );
11
+ add_action( 'wp_ajax_wr2x_delete_full', array( $this, 'wp_ajax_wr2x_delete_full' ) );
12
+ add_action( 'wp_ajax_wr2x_list_all', array( $this, 'wp_ajax_wr2x_list_all' ) );
13
+ add_action( 'wp_ajax_wr2x_replace', array( $this, 'wp_ajax_wr2x_replace' ) );
14
+ add_action( 'wp_ajax_wr2x_upload', array( $this, 'wp_ajax_wr2x_upload' ) );
15
+ add_action( 'wp_ajax_wr2x_retina_details', array( $this, 'wp_ajax_wr2x_retina_details' ) );
16
+ }
17
+
18
+ /**
19
+ * Checks nonce for the specified action
20
+ * @param string $action
21
+ */
22
+ function check_nonce( $action ) {
23
+ if ( !wp_verify_nonce( $_POST['nonce'], $action ) ) {
24
+ echo json_encode(
25
+ array (
26
+ 'success' => false,
27
+ 'message' => __( "Invalid API request.", 'wp-retina-2x' )
28
+ )
29
+ );
30
+ die();
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Checks if the current user has sufficient permissions to perform the Ajax actions
36
+ */
37
+ function check_capability() {
38
+ $cap = 'upload_files';
39
+ if ( !current_user_can( $cap ) ) {
40
+ echo json_encode(
41
+ array (
42
+ 'success' => false,
43
+ 'message' => __( "You do not have permission to upload files.", 'wp-retina-2x' )
44
+ )
45
+ );
46
+ die();
47
+ }
48
+ }
49
+
50
+ /**
51
+ *
52
+ * AJAX SERVER-SIDE
53
+ *
54
+ */
55
+
56
+ // Using issuesOnly, only the IDs with a PENDING status will be processed
57
+ function wp_ajax_wr2x_list_all( $issuesOnly ) {
58
+ $this->check_nonce( 'wr2x_list_all' );
59
+ $this->check_capability();
60
+
61
+ $issuesOnly = intval( $_POST['issuesOnly'] );
62
+ if ( $issuesOnly == 1 ) {
63
+ $ids = $this->core->get_issues();
64
+ echo json_encode(
65
+ array(
66
+ 'success' => true,
67
+ 'message' => "List of issues only.",
68
+ 'ids' => $ids,
69
+ 'total' => count( $ids )
70
+ ) );
71
+ die;
72
+ }
73
+ $reply = array();
74
+ try {
75
+ $ids = array();
76
+ $total = 0;
77
+ global $wpdb;
78
+ $postids = $wpdb->get_col( "
79
+ SELECT p.ID
80
+ FROM $wpdb->posts p
81
+ WHERE post_status = 'inherit'
82
+ AND post_type = 'attachment'
83
+ AND ( post_mime_type = 'image/jpeg' OR
84
+ post_mime_type = 'image/png' OR
85
+ post_mime_type = 'image/gif' )
86
+ " );
87
+ foreach ($postids as $id) {
88
+ if ( $this->core->is_ignore( $id ) )
89
+ continue;
90
+ array_push( $ids, $id );
91
+ $total++;
92
+ }
93
+ echo json_encode(
94
+ array(
95
+ 'success' => true,
96
+ 'message' => "List of everything.",
97
+ 'ids' => $ids,
98
+ 'total' => $total
99
+ ) );
100
+ die;
101
+ }
102
+ catch (Exception $e) {
103
+ echo json_encode(
104
+ array(
105
+ 'success' => false,
106
+ 'message' => $e->getMessage()
107
+ ) );
108
+ die;
109
+ }
110
+ }
111
+
112
+ function wp_ajax_wr2x_delete_full( $pleaseReturn = false ) {
113
+ if ( !$pleaseReturn ) $this->check_nonce( 'wr2x_delete_full' );
114
+ $this->check_capability();
115
+
116
+ if ( !isset( $_POST['attachmentId'] ) ) {
117
+ echo json_encode(
118
+ array(
119
+ 'success' => false,
120
+ 'message' => __( "The attachment ID is missing.", 'wp-retina-2x' )
121
+ )
122
+ );
123
+ die();
124
+ }
125
+ $attachmentId = intval( $_POST['attachmentId'] );
126
+ $originalfile = get_attached_file( $attachmentId );
127
+ $pathinfo = pathinfo( $originalfile );
128
+ $retina_file = trailingslashit( $pathinfo['dirname'] ) . $pathinfo['filename'] . $this->core->retina_extension() . $pathinfo['extension'];
129
+ if ( $retina_file && file_exists( $retina_file ) )
130
+ unlink( $retina_file );
131
+
132
+ // RESULTS FOR RETINA DASHBOARD
133
+ $info = $this->core->html_get_basic_retina_info_full( $attachmentId, $this->core->retina_info( $attachmentId ) );
134
+ $results[$attachmentId] = $info;
135
+
136
+ // Return if that's not the final step.
137
+ if ( $pleaseReturn )
138
+ return $info;
139
+
140
+ echo json_encode(
141
+ array(
142
+ 'results' => $results,
143
+ 'success' => true,
144
+ 'message' => __( "Full retina file deleted.", 'wp-retina-2x' )
145
+ )
146
+ );
147
+ die();
148
+ }
149
+
150
+ function wp_ajax_wr2x_delete() {
151
+ $this->check_nonce( 'wr2x_delete' );
152
+ $this->check_capability();
153
+
154
+ if ( !isset( $_POST['attachmentId'] ) ) {
155
+ echo json_encode(
156
+ array(
157
+ 'success' => false,
158
+ 'message' => __( "The attachment ID is missing.", 'wp-retina-2x' )
159
+ )
160
+ );
161
+ die();
162
+ }
163
+
164
+ // Information for the retina version of the full-size
165
+ $attachmentId = intval( $_POST['attachmentId'] );
166
+ $results_full[$attachmentId] = $this->wp_ajax_wr2x_delete_full( true );
167
+
168
+ $this->core->delete_attachment( $attachmentId, true );
169
+ $meta = wp_get_attachment_metadata( $attachmentId );
170
+
171
+ // RESULTS FOR RETINA DASHBOARD
172
+ $this->core->update_issue_status( $attachmentId );
173
+ $info = $this->core->html_get_basic_retina_info( $attachmentId, $this->core->retina_info( $attachmentId ) );
174
+ $results[$attachmentId] = $info;
175
+ echo json_encode(
176
+ array(
177
+ 'results' => $results,
178
+ 'results_full' => $results_full,
179
+ 'success' => true,
180
+ 'message' => __( "Retina files deleted.", 'wp-retina-2x' )
181
+ )
182
+ );
183
+ die();
184
+ }
185
+
186
+ function wp_ajax_wr2x_retina_details() {
187
+ $this->check_nonce( 'wr2x_retina_details' );
188
+ $this->check_capability();
189
+
190
+ if ( !isset( $_POST['attachmentId'] ) ) {
191
+ echo json_encode(
192
+ array(
193
+ 'success' => false,
194
+ 'message' => __( "The attachment ID is missing.", 'wp-retina-2x' )
195
+ )
196
+ );
197
+ die();
198
+ }
199
+
200
+ $attachmentId = intval( $_POST['attachmentId'] );
201
+ $info = $this->core->html_get_details_retina_info( $attachmentId, $this->core->retina_info( $attachmentId ) );
202
+ echo json_encode(
203
+ array(
204
+ 'result' => $info,
205
+ 'success' => true,
206
+ 'message' => __( "Details retrieved.", 'wp-retina-2x' )
207
+ )
208
+ );
209
+ die();
210
+ }
211
+
212
+ function wp_ajax_wr2x_generate() {
213
+ $this->check_nonce( 'wr2x_generate' );
214
+ $this->check_capability();
215
+
216
+ if ( !isset( $_POST['attachmentId'] ) ) {
217
+ echo json_encode(
218
+ array(
219
+ 'success' => false,
220
+ 'message' => __( "The attachment ID is missing.", 'wp-retina-2x' )
221
+ )
222
+ );
223
+ die();
224
+ }
225
+
226
+ $attachmentId = intval( $_POST['attachmentId'] );
227
+ $this->core->delete_attachment( $attachmentId, false );
228
+
229
+ // Regenerate the Thumbnails
230
+ $regenerate = get_option( 'wr2x_regenerate_thumbnails', false );
231
+ if ( $regenerate ) {
232
+ $file = get_attached_file( $attachmentId );
233
+ $meta = wp_generate_attachment_metadata( $attachmentId, $file );
234
+ wp_update_attachment_metadata( $attachmentId, $meta );
235
+ }
236
+
237
+ // Regenerate Retina
238
+ $meta = wp_get_attachment_metadata( $attachmentId );
239
+ $this->core->generate_images( $meta );
240
+
241
+ // RESULTS FOR RETINA DASHBOARD
242
+ $info = $this->core->html_get_basic_retina_info( $attachmentId, $this->core->retina_info( $attachmentId ) );
243
+ $results[$attachmentId] = $info;
244
+ echo json_encode(
245
+ array(
246
+ 'results' => $results,
247
+ 'success' => true,
248
+ 'message' => __( "Retina files generated.", 'wp-retina-2x' )
249
+ )
250
+ );
251
+ die();
252
+ }
253
+
254
+ function check_get_ajax_uploaded_file() {
255
+ $this->check_capability();
256
+
257
+ $tmpfname = $_FILES['file']['tmp_name'];
258
+
259
+ // Check if it is an image
260
+ $file_info = getimagesize( $tmpfname );
261
+ if ( empty( $file_info ) ) {
262
+ $this->core->log( "The file is not an image or the upload went wrong." );
263
+ unlink( $tmpfname );
264
+ echo json_encode( array(
265
+ 'success' => false,
266
+ 'message' => __( "The file is not an image or the upload went wrong.", 'wp-retina-2x' )
267
+ ));
268
+ die();
269
+ }
270
+
271
+ $filedata = wp_check_filetype_and_ext( $tmpfname, $_POST['filename'] );
272
+ if ( $filedata["ext"] == "" ) {
273
+ $this->core->log( "You cannot use this file (wrong extension? wrong type?)." );
274
+ unlink( $current_file );
275
+ echo json_encode( array(
276
+ 'success' => false,
277
+ 'message' => __( "You cannot use this file (wrong extension? wrong type?).", 'wp-retina-2x' )
278
+ ));
279
+ die();
280
+ }
281
+
282
+ $this->core->log( "The temporary file was written successfully." );
283
+ return $tmpfname;
284
+ }
285
+
286
+ function wp_ajax_wr2x_upload() {
287
+ $this->check_nonce( 'wr2x_upload' );
288
+
289
+ try {
290
+ $tmpfname = $this->check_get_ajax_uploaded_file();
291
+ $attachmentId = (int) $_POST['attachmentId'];
292
+ $meta = wp_get_attachment_metadata( $attachmentId );
293
+ $current_file = get_attached_file( $attachmentId );
294
+ $pathinfo = pathinfo( $current_file );
295
+ $basepath = $pathinfo['dirname'];
296
+ $retinafile = trailingslashit( $pathinfo['dirname'] ) . $pathinfo['filename'] . $this->core->retina_extension() . $pathinfo['extension'];
297
+
298
+ if ( file_exists( $retinafile ) )
299
+ unlink( $retinafile );
300
+
301
+ // Insert the new file and delete the temporary one
302
+ list( $width, $height ) = getimagesize( $tmpfname );
303
+
304
+ if ( !$this->core->are_dimensions_ok( $width, $height, $meta['width'] * 2, $meta['height'] * 2 ) ) {
305
+ echo json_encode( array(
306
+ 'success' => false,
307
+ 'message' => "This image has a resolution of ${width}×${height} but your Full Size image requires a retina image of at least " . ( $meta['width'] * 2 ) . "x" . ( $meta['height'] * 2 ) . "."
308
+ ));
309
+ die();
310
+ }
311
+ $this->core->resize( $tmpfname, $meta['width'] * 2, $meta['height'] * 2, null, $retinafile );
312
+ chmod( $retinafile, 0644 );
313
+ unlink( $tmpfname );
314
+
315
+ // Get the results
316
+ $info = $this->core->retina_info( $attachmentId );
317
+ $this->core->update_issue_status( $attachmentId );
318
+ $results[$attachmentId] = $this->core->html_get_basic_retina_info_full( $attachmentId, $info );
319
+ }
320
+ catch (Exception $e) {
321
+ echo json_encode( array(
322
+ 'success' => false,
323
+ 'results' => null,
324
+ 'message' => __( "Error: " . $e->getMessage(), 'wp-retina-2x' )
325
+ ));
326
+ die();
327
+ }
328
+ echo json_encode( array(
329
+ 'success' => true,
330
+ 'results' => $results,
331
+ 'message' => __( "Uploaded successfully.", 'wp-retina-2x' )
332
+ ));
333
+ die();
334
+ }
335
+
336
+ function wp_ajax_wr2x_replace() {
337
+ $this->check_nonce( 'wr2x_replace' );
338
+
339
+ $tmpfname = $this->check_get_ajax_uploaded_file();
340
+ $attachmentId = (int) $_POST['attachmentId'];
341
+ $meta = wp_get_attachment_metadata( $attachmentId );
342
+ $current_file = get_attached_file( $attachmentId );
343
+ $this->core->delete_attachment( $attachmentId, false );
344
+ $pathinfo = pathinfo( $current_file );
345
+ $basepath = $pathinfo['dirname'];
346
+
347
+ // Let's clean everything first
348
+ if ( wp_attachment_is_image( $attachmentId ) ) {
349
+ $sizes = $this->core->get_image_sizes();
350
+ foreach ($sizes as $name => $attr) {
351
+ if ( isset( $meta['sizes'][$name] ) && isset( $meta['sizes'][$name]['file'] ) && file_exists( trailingslashit( $basepath ) . $meta['sizes'][$name]['file'] ) ) {
352
+ $normal_file = trailingslashit( $basepath ) . $meta['sizes'][$name]['file'];
353
+ $pathinfo = pathinfo( $normal_file );
354
+ $retina_file = trailingslashit( $pathinfo['dirname'] ) . $pathinfo['filename'] . $this->core->retina_extension() . $pathinfo['extension'];
355
+
356
+ // Test if the file exists and if it is actually a file (and not a dir)
357
+ // Some old WordPress Media Library are sometimes broken and link to directories
358
+ if ( file_exists( $normal_file ) && is_file( $normal_file ) )
359
+ unlink( $normal_file );
360
+ if ( file_exists( $retina_file ) && is_file( $retina_file ) )
361
+ unlink( $retina_file );
362
+ }
363
+ }
364
+ }
365
+ if ( file_exists( $current_file ) )
366
+ unlink( $current_file );
367
+
368
+ // Insert the new file and delete the temporary one
369
+ rename( $tmpfname, $current_file );
370
+ chmod( $current_file, 0644 );
371
+
372
+ // Generate the images
373
+ wp_update_attachment_metadata( $attachmentId, wp_generate_attachment_metadata( $attachmentId, $current_file ) );
374
+ $meta = wp_get_attachment_metadata( $attachmentId );
375
+ $this->core->generate_images( $meta );
376
+
377
+ // Get the results
378
+ $info = $this->core->retina_info( $attachmentId );
379
+ $results[$attachmentId] = $this->core->html_get_basic_retina_info( $attachmentId, $info );
380
+
381
+ echo json_encode( array(
382
+ 'success' => true,
383
+ 'results' => $results,
384
+ 'message' => __( "Replaced successfully.", 'wp-retina-2x' )
385
+ ));
386
+ die();
387
+ }
388
+
389
+ }
390
+
391
+ ?>
trunk/api.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * FUNCTIONS THAT CAN BE USED BY THEMES/PLUGINS DEVELOPERS
6
+ * FOR ADDITIONAL RETINA SUPPORT
7
+ *
8
+ */
9
+
10
+ // Rewrite the HTML to add Retina support (not recommended, that is
11
+ // done automatically by the plugin through the Method)
12
+ function wr2x_picture_rewrite( $buffer ) {
13
+ global $wr2x_core;
14
+ return $wr2x_core->picture_rewrite( $buffer );
15
+ }
16
+
17
+ // Return Retina URL from the Image URL
18
+ function wr2x_get_retina_from_url( $url ) {
19
+ global $wr2x_core;
20
+ return $wr2x_core->get_retina_from_url( $url );
21
+ }
22
+
23
+ // Return the retina file if my found for this normal file
24
+ function wr2x_get_retina( $file ) {
25
+ global $wr2x_core;
26
+ return $wr2x_core->get_retina( $file );
27
+ }
28
+
29
+ // Generate the retina images for the given meta of a media
30
+ function wr2x_generate_images( $meta ) {
31
+ global $wr2x_core;
32
+ return $wr2x_core->generate_images( $meta );
33
+ }
34
+
35
+ // Delete the Retina files for this attachment
36
+ function wr2x_delete_attachment( $attach_id, $deleteFullSize = true ) {
37
+ global $wr2x_core;
38
+ return $wr2x_core->delete_attachment( $attach_id, $deleteFullSize );
39
+ }
40
+
41
+ function wr2x_get_pathinfo_from_image_src( $image_src ) {
42
+ global $wr2x_core;
43
+ return $wr2x_core->get_pathinfo_from_image_src( $image_src );
44
+ }
45
+
46
+ function wr2x_retina_extension() {
47
+ global $wr2x_core;
48
+ return $wr2x_core->retina_extension();
49
+ }
50
+
51
+ ?>
trunk/common/admin.css ADDED
@@ -0,0 +1,382 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* MEOW-TABS */
2
+
3
+ .meow-tabs {
4
+ display: flex;
5
+ flex-wrap: wrap;
6
+ box-sizing: border-box;
7
+ }
8
+
9
+ .meow-tabs * {
10
+ box-sizing: border-box;
11
+ }
12
+
13
+ .meow-tabs .meow-tabs-input {
14
+ position: absolute;
15
+ opacity: 0;
16
+ }
17
+
18
+ .meow-tabs .meow-tabs-label {
19
+ width: auto;
20
+ padding: 4px 12px;
21
+ background: #3c3c3c;
22
+ cursor: pointer;
23
+ font-weight: bold;
24
+ font-size: 13px;
25
+ text-transform: uppercase;
26
+ color: white;
27
+ transition: background 0.1s, color 0.1s;
28
+ }
29
+
30
+ .meow-tabs .inside {
31
+ display: none;
32
+ width: 100%;
33
+ }
34
+
35
+ .meow-tabs .meow-tabs-label:hover {
36
+ background: #36495f;
37
+ }
38
+
39
+ .meow-tabs .meow-tabs-label:active {
40
+ background: #3C82C7;
41
+ }
42
+
43
+ .meow-tabs .meow-tabs-input:focus + .meow-tabs-label {
44
+ box-shadow: inset 0px 0px 0px 3px #2aa1c0;
45
+ z-index: 1;
46
+ }
47
+
48
+ .meow-tabs .meow-tabs-input:checked + .meow-tabs-label {
49
+ background: #3C82C7 !important;
50
+ }
51
+
52
+ .meow-tabs-input:checked + .meow-tabs-label + .inside {
53
+ display: block;
54
+ order: 99;
55
+ }
56
+
57
+ .meow-tabs .inside {
58
+ background: #fff;
59
+ }
60
+
61
+ /* MEOW-BOX */
62
+
63
+ .meow-box {
64
+ box-sizing: border-box;
65
+ border: 1px solid #e5e5e5;
66
+ box-shadow: 2px 2px 1px rgba(0,0,0,.02);
67
+ background: #fff;
68
+ color: #444;
69
+ margin-bottom: 15px;
70
+ font-size: 13px !important;
71
+ border-top-right-radius: 8px;
72
+ }
73
+
74
+ .meow-box input, .meow-box th, .meow-box label, .meow-box select {
75
+ font-size: 13px !important;
76
+ }
77
+
78
+ .meow-box small {
79
+ font-size: 12px !important;
80
+ }
81
+
82
+ .meow-box h3 {
83
+ font-size: 13px;
84
+ padding: 4px 12px;
85
+ margin: 0;
86
+ background: #3c3c3c;
87
+ color: #ffffff;
88
+ text-transform: uppercase;
89
+ border-top-right-radius: 8px;
90
+ /*border-bottom: 1px solid #eee;*/
91
+ }
92
+
93
+ .meow-box h3 .dashicons {
94
+ position: relative;
95
+ top: 0px;
96
+ margin-right: 5px;
97
+ }
98
+
99
+ .meow-box .pro_info {
100
+ padding: 5px;
101
+ margin: 10px -10px 5px -10px;
102
+ font-size: 11px;
103
+ line-height: 13px;
104
+ }
105
+
106
+ .meow-box .pro_info.enabled {
107
+ background: #4482d2;
108
+ border-left: 5px solid #4482d2;
109
+ color: white;
110
+ }
111
+
112
+ .meow-box .pro_info.disabled {
113
+ background: #96555b;
114
+ border-left: 5px solid #632329;
115
+ color: white;
116
+ }
117
+
118
+ .meow-box .pro_info.disabled a {
119
+ background: #96555b;
120
+ color: red;
121
+ text-decoration: none;
122
+ }
123
+
124
+ .meow-box .inside {
125
+ margin: 10px;
126
+ }
127
+
128
+ .meow-box th {
129
+ padding: 10px 10px 10px 0px;
130
+ width: 22%;
131
+ }
132
+
133
+ .meow-box td {
134
+ padding: 10px 10px;
135
+ }
136
+
137
+ .meow-box p.submit {
138
+ text-align: right;
139
+ margin: 10px -10px -10px -10px;
140
+ padding: 7px 10px 10px 0px !important;
141
+ border-top: 1px solid #eee !important;
142
+ max-width: inherit;
143
+ background: rgba(125, 125, 125, 0.04);
144
+ border-radius: 0px;
145
+ }
146
+
147
+ .meow-box [type="text"], .meow-box select {
148
+ width: 100%;
149
+ }
150
+
151
+ /* CONTROLS INSIDE A COLUMN (LABEL ON THE LEFT, VALUE ON THE RIGHT) */
152
+ .meow-box td [type="text"], .meow-box td [type="checkbox"], .meow-box td select {
153
+ margin-top: -3px;
154
+ }
155
+
156
+ .meow-header-ad {
157
+ float: right;
158
+ }
159
+
160
+ /* BUTTONS */
161
+
162
+ .meow-button-xs {
163
+ font-size: 10px !important;
164
+ height: 20px !important;
165
+ line-height: 18px !important;
166
+ position: relative !important;
167
+ top: 1px !important;
168
+ text-align: center !important
169
+ }
170
+
171
+ /* MODAL */
172
+
173
+ #meow-modal-info-backdrop {
174
+ background: rgba(0, 0, 0, 0.75);
175
+ position: fixed;
176
+ top: 0px;
177
+ bottom: 0px;
178
+ right: 0px;
179
+ left: 0px;
180
+ z-index: 10000;
181
+ }
182
+
183
+ #meow-modal-info {
184
+ background: white;
185
+ box-shadow: 0px 0px 5px black;
186
+ padding: 15px;
187
+ overflow-y: scroll;
188
+ position: fixed;
189
+ z-index: 10000;
190
+ left: 100px;
191
+ right: 100px;
192
+ top: 50px;
193
+ bottom: 50px;
194
+ }
195
+
196
+ #meow-modal-info h3 {
197
+ height: 25px;
198
+ border-bottom: 2px solid #808080;
199
+ }
200
+
201
+ #meow-modal-info td {
202
+ text-align: center;
203
+ font-size: 11px;
204
+ border: 1px solid #D3DCFF;
205
+ padding: 10px 15px;
206
+ background: #EFF8FF;
207
+ }
208
+
209
+ #meow-modal-info .close {
210
+ float: right;
211
+ font-size: 18px;
212
+ font-weight: bold;
213
+ font-family: Verdana;
214
+ cursor: pointer;
215
+ }
216
+
217
+ #meow-modal-info .loading {
218
+ background-color: #F2F2F2;
219
+ text-align: center;
220
+ padding-top: 10px;
221
+ background-size: 32px 32px;
222
+ }
223
+
224
+ #meow-modal-info .meow-sized-image {
225
+ width: 19px;
226
+ height: 19px;
227
+ margin-right: 10px;
228
+ }
229
+
230
+ /* IMAGE SIZES RELATED INFO */
231
+
232
+ .meow-sized-images {
233
+ margin-top: 0px;
234
+ cursor: pointer;
235
+ }
236
+
237
+ .meow-sized-images li, #meow-modal-info .meow-sized-image {
238
+ display: block;
239
+ color: white;
240
+ padding: 5px 0px;
241
+ font-size: 10px;
242
+ text-align: center;
243
+ width: 18px;
244
+ height: 18px;
245
+ line-height: 8px;
246
+ background: black;
247
+ float: left;
248
+ margin-right: 1px;
249
+ box-sizing: border-box;
250
+ margin-bottom: 2px;
251
+ }
252
+
253
+ .meow-sized-images:after {
254
+ clear: both;
255
+ content:""; display:table;
256
+ }
257
+
258
+ .meow-sized-images + span {
259
+ position: relative;
260
+ top: -12px;
261
+ }
262
+
263
+ /* MEOW COLORS */
264
+
265
+ .meow-bk-blue {
266
+ background: #3C82C7 !important;
267
+ color: white;
268
+ }
269
+
270
+ .meow-bk-orange {
271
+ background: #f1900e !important;
272
+ color: white;
273
+ }
274
+
275
+ .meow-bk-red {
276
+ background: #c53a47 !important;
277
+ color: white;
278
+ }
279
+
280
+ .meow-bk-gray {
281
+ background: gray !important;
282
+ color: white;
283
+ }
284
+
285
+ .meow-bk-green {
286
+ background: #2b9463 !important;
287
+ color: white;
288
+ }
289
+
290
+ .meow-bk-black {
291
+ background: #3c3c3c !important;
292
+ color: white;
293
+ }
294
+
295
+ .meow-bk-purple {
296
+ background: #984c96 !important;
297
+ color: white;
298
+ }
299
+
300
+ /* DASHBOARD */
301
+
302
+ .meow-dashboard .meow-box li {
303
+ border-bottom: 1px solid #eee;
304
+ padding: 0px 10px 10px 10px;
305
+ }
306
+
307
+ .meow-dashboard .meow-box li:last-child {
308
+ border: none;
309
+ padding-bottom: 0px;
310
+ }
311
+
312
+ .meow-button-xs .dashicons {
313
+ font-size: 18px !important;
314
+ }
315
+
316
+ .meow-button-xs.updating-message:before {
317
+ margin-top: 0px !important;
318
+ }
319
+
320
+ .meow-button-xs.updating-message * {
321
+ display: none;
322
+ }
323
+
324
+ #phpinfo {
325
+ font-size: 11px;
326
+ }
327
+
328
+ #phpinfo .e {
329
+ padding: 5px;
330
+ background: lightgray;
331
+ }
332
+
333
+ #phpinfo .h th {
334
+ padding: 5px;
335
+ color: white;
336
+ background: gray;
337
+ text-align: left;
338
+ font-size: 14px !important;
339
+ }
340
+
341
+ #phpinfo h1 {
342
+ padding: 10px 0px;
343
+ font-weight: bold;
344
+ }
345
+
346
+ #phpinfo h2 {
347
+ padding: 10px 0px;
348
+ font-weight: bold;
349
+ font-size: 20px;
350
+ }
351
+
352
+ #error_log {
353
+ font-size: 12px;
354
+ }
355
+
356
+ /* ROWS AND COLUMNS */
357
+ .meow-col { display: block; float:left; margin: 1% 0 1% 1.6%; }
358
+ .meow-col:first-child { margin-left: 0; }
359
+
360
+ /* GROUPING */
361
+ .meow-row { clear: both; padding: 0px; margin: 0px; }
362
+ .meow-row:before,
363
+ .meow-row:after { content:""; display:table; }
364
+ .meow-row:after { clear:both; }
365
+ .meow-row { zoom:1; /* For IE 6/7 */ }
366
+
367
+ /* GRID OF THREE */
368
+ .meow-span_3_of_3 { width: 100%; }
369
+ .meow-span_2_of_3 { width: 66.1%; }
370
+ .meow-span_1_of_3 { width: 32.2%; }
371
+
372
+ /* GRID OF TWO */
373
+ .meow-span_2_of_2 { width: 100%; }
374
+ .meow-span_1_of_2 { width: 49.2%; }
375
+
376
+ @media only screen and (max-width: 480px) {
377
+ .meow-col { margin: 0 0 0px 0;}
378
+ .meow-span_3_of_3, .meow-span_2_of_3, .meow-span_1_of_3 { width: 100%; }
379
+ .meow-span_2_of_2, .meow-span_1_of_2 { width: 100%; }
380
+ .meow-header-ad { display: none !important; }
381
+ .meow-box [type="text"] { width: 100% !important; }
382
+ }
trunk/common/admin.php ADDED
@@ -0,0 +1,431 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists( 'MeowApps_Admin' ) ) {
4
+
5
+ class MeowApps_Admin {
6
+
7
+ public static $loaded = false;
8
+ public static $admin_version = "1.4";
9
+
10
+ public $prefix; // prefix used for actions, filters (mfrh)
11
+ public $mainfile; // plugin main file (media-file-renamer.php)
12
+ public $domain; // domain used for translation (media-file-renamer)
13
+
14
+ public function __construct( $prefix, $mainfile, $domain, $disableReview = false ) {
15
+
16
+ // Core Admin (used by all Meow Apps plugins)
17
+ if ( !MeowApps_Admin::$loaded ) {
18
+ if ( is_admin() ) {
19
+ add_action( 'admin_menu', array( $this, 'admin_menu_start' ) );
20
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
21
+ add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
22
+ add_filter( 'updraftplus_com_link', array( $this, 'updraftplus_com_link' ) );
23
+ }
24
+ MeowApps_Admin::$loaded = true;
25
+ }
26
+
27
+ // Variables for this plugin
28
+ $this->prefix = $prefix;
29
+ $this->mainfile = $mainfile;
30
+ $this->domain = $domain;
31
+
32
+ register_activation_hook( $mainfile, array( $this, 'show_meowapps_create_rating_date' ) );
33
+
34
+ if ( is_admin() ) {
35
+ $license = get_option( $this->prefix . '_license', "" );
36
+ if ( ( !empty( $license ) ) && !file_exists( plugin_dir_path( $this->mainfile ) . 'common/meowapps/admin.php' ) ) {
37
+ add_action( 'admin_notices', array( $this, 'admin_notices_licensed_free' ) );
38
+ }
39
+ if ( !$disableReview ) {
40
+ $rating_date = $this->create_rating_date();
41
+ if ( time() > $rating_date ) {
42
+ add_action( 'admin_notices', array( $this, 'admin_notices_rating' ) );
43
+ }
44
+ }
45
+ }
46
+ }
47
+
48
+ function updraftplus_com_link( $url ) {
49
+ $url = $url . "?afref=460";
50
+ return $url;
51
+ }
52
+
53
+ function show_meowapps_create_rating_date() {
54
+ delete_option( 'meowapps_hide_meowapps' );
55
+ $this->create_rating_date();
56
+ }
57
+
58
+ function create_rating_date() {
59
+ $rating_date = get_option( $this->prefix . '_rating_date' );
60
+ if ( empty( $rating_date ) ) {
61
+ $two_months = strtotime( '+2 months' );
62
+ $six_months = strtotime( '+4 months' );
63
+ $rating_date = mt_rand( $two_months, $six_months );
64
+ update_option( $this->prefix . '_rating_date', $rating_date, false );
65
+ }
66
+ return $rating_date;
67
+ }
68
+
69
+ function admin_notices_rating() {
70
+ if ( isset( $_POST[$this->prefix . '_remind_me'] ) ) {
71
+ $two_weeks = strtotime( '+2 weeks' );
72
+ $six_weeks = strtotime( '+6 weeks' );
73
+ $future_date = mt_rand( $two_weeks, $six_weeks );
74
+ update_option( $this->prefix . '_rating_date', $future_date, false );
75
+ return;
76
+ }
77
+ else if ( isset( $_POST[$this->prefix . '_never_remind_me'] ) ) {
78
+ $twenty_years = strtotime( '+5 years' );
79
+ update_option( $this->prefix . '_rating_date', $twenty_years, false );
80
+ return;
81
+ }
82
+ else if ( isset( $_POST[$this->prefix . '_did_it'] ) ) {
83
+ $twenty_years = strtotime( '+10 years' );
84
+ update_option( $this->prefix . '_rating_date', $twenty_years, false );
85
+ return;
86
+ }
87
+ $rating_date = get_option( $this->prefix . '_rating_date' );
88
+ echo '<div class="notice notice-success" data-rating-date="' . date( 'Y-m-d', $rating_date ) . '">';
89
+ echo '<p style="font-size: 100%;">You have been using <b>' . $this->nice_name_from_file( $this->mainfile ) . '</b> for some time now. Thank you! Could you kindly share your opinion with me, along with, maybe, features you would like to see implemented? Then, please <a style="font-weight: bold; color: #b926ff;" target="_blank" href="https://wordpress.org/support/plugin/' . $this->nice_short_url_from_file( $this->mainfile ) . '/reviews/?rate=5#new-post">write a little review</a>. That will also bring me joy and motivation, and I will get back to you :) <u>In the case you already have written a review</u>, please check again. Many reviews got removed from WordPress recently.';
90
+ echo '<p>
91
+ <form method="post" action="" style="float: right;">
92
+ <input type="hidden" name="' . $this->prefix . '_never_remind_me" value="true">
93
+ <input type="submit" name="submit" id="submit" class="button button-red" value="Never remind me!">
94
+ </form>
95
+ <form method="post" action="" style="float: right; margin-right: 10px;">
96
+ <input type="hidden" name="' . $this->prefix . '_remind_me" value="true">
97
+ <input type="submit" name="submit" id="submit" class="button button-primary" value="Remind me in a few weeks...">
98
+ </form>
99
+ <form method="post" action="" style="float: right; margin-right: 10px;">
100
+ <input type="hidden" name="' . $this->prefix . '_did_it" value="true">
101
+ <input type="submit" name="submit" id="submit" class="button button-primary" value="Yes, I did it!">
102
+ </form>
103
+ <div style="clear: both;"></div>
104
+ </p>
105
+ ';
106
+ echo '</div>';
107
+ }
108
+
109
+ function nice_short_url_from_file( $file ) {
110
+ $info = pathinfo( $file );
111
+ if ( !empty( $info ) ) {
112
+ $info['filename'] = str_replace( '-pro', '', $info['filename'] );
113
+ return $info['filename'];
114
+ }
115
+ return "";
116
+ }
117
+
118
+ function nice_name_from_file( $file ) {
119
+ $info = pathinfo( $file );
120
+ if ( !empty( $info ) ) {
121
+ if ( $info['filename'] == 'wplr-sync' ) {
122
+ return "WP/LR Sync";
123
+ }
124
+ $info['filename'] = str_replace( '-', ' ', $info['filename'] );
125
+ $file = ucwords( $info['filename'] );
126
+ }
127
+ return $file;
128
+ }
129
+
130
+ function admin_notices_licensed_free() {
131
+ if ( isset( $_POST[$this->prefix . '_reset_sub'] ) ) {
132
+ delete_option( $this->prefix . '_pro_serial' );
133
+ delete_option( $this->prefix . '_license' );
134
+ return;
135
+ }
136
+ echo '<div class="error">';
137
+ echo '<p>It looks like you are using the free version of the plugin (<b>' . $this->nice_name_from_file( $this->mainfile ) . '</b>) but a license for the Pro version was also found. The Pro version might have been replaced by the Free version during an update (might be caused by a temporarily issue). If it is the case, <b>please download it again</b> from the <a target="_blank" href="https://store.meowapps.com">Meow Store</a>. If you wish to continue using the free version and clear this message, click on this button.';
138
+ echo '<p>
139
+ <form method="post" action="">
140
+ <input type="hidden" name="' . $this->prefix . '_reset_sub" value="true">
141
+ <input type="submit" name="submit" id="submit" class="button" value="Remove the license">
142
+ </form>
143
+ </p>
144
+ ';
145
+ echo '</div>';
146
+ }
147
+
148
+ function display_ads() {
149
+ return !get_option( 'meowapps_hide_ads', false );
150
+ }
151
+
152
+ function display_title( $title = "Meow Apps",
153
+ $author = "By <a style='text-decoration: none;' href='https://meowapps.com' target='_blank'>Jordy Meow</a>" ) {
154
+ if ( !empty( $this->prefix ) )
155
+ $title = apply_filters( $this->prefix . '_plugin_title', $title );
156
+ if ( $this->display_ads() ) {
157
+ echo '<a class="meow-header-ad" target="_blank" href="http://www.shareasale.com/r.cfm?b=906810&u=767054&m=41388&urllink=&afftrack="">
158
+ <img src="' . $this->common_url( 'img/wpengine.png' ) . '" height="60" border="0" /></a>';
159
+ }
160
+ ?>
161
+ <h1 style="line-height: 16px;">
162
+ <img width="36" style="margin-right: 10px; float: left; position: relative; top: -5px;"
163
+ src="<?php echo $this->meowapps_logo_url(); ?>"><?php echo $title; ?><br />
164
+ <span style="font-size: 12px"><?php echo $author; ?></span>
165
+ </h1>
166
+ <div style="clear: both;"></div>
167
+ <?php
168
+ }
169
+
170
+ function admin_enqueue_scripts() {
171
+ wp_register_style( 'meowapps-core-css', $this->common_url( 'admin.css' ) );
172
+ wp_enqueue_style( 'meowapps-core-css' );
173
+ }
174
+
175
+ function admin_menu_start() {
176
+ if ( get_option( 'meowapps_hide_meowapps', false ) ) {
177
+ register_setting( 'general', 'meowapps_hide_meowapps' );
178
+ add_settings_field( 'meowapps_hide_ads', 'Meow Apps Menu', array( $this, 'meowapps_hide_dashboard_callback' ), 'general' );
179
+ return;
180
+ }
181
+
182
+ // Creates standard menu if it does NOT exist
183
+ global $submenu;
184
+ if ( !isset( $submenu[ 'meowapps-main-menu' ] ) ) {
185
+ add_menu_page( 'Meow Apps', 'Meow Apps', 'manage_options', 'meowapps-main-menu',
186
+ array( $this, 'admin_meow_apps' ), 'dashicons-camera', 82 );
187
+ add_submenu_page( 'meowapps-main-menu', __( 'Dashboard', 'meowapps' ),
188
+ __( 'Dashboard', 'meowapps' ), 'manage_options',
189
+ 'meowapps-main-menu', array( $this, 'admin_meow_apps' ) );
190
+ }
191
+
192
+ add_settings_section( 'meowapps_common_settings', null, null, 'meowapps_common_settings-menu' );
193
+ add_settings_field( 'meowapps_hide_meowapps', "Main Menu",
194
+ array( $this, 'meowapps_hide_dashboard_callback' ),
195
+ 'meowapps_common_settings-menu', 'meowapps_common_settings' );
196
+ add_settings_field( 'meowapps_force_sslverify', "SSL Verify",
197
+ array( $this, 'meowapps_force_sslverify_callback' ),
198
+ 'meowapps_common_settings-menu', 'meowapps_common_settings' );
199
+ add_settings_field( 'meowapps_hide_ads', "Ads",
200
+ array( $this, 'meowapps_hide_ads_callback' ),
201
+ 'meowapps_common_settings-menu', 'meowapps_common_settings' );
202
+ register_setting( 'meowapps_common_settings', 'force_sslverify' );
203
+ register_setting( 'meowapps_common_settings', 'meowapps_hide_meowapps' );
204
+ register_setting( 'meowapps_common_settings', 'meowapps_hide_ads' );
205
+ }
206
+
207
+ function meowapps_hide_ads_callback() {
208
+ $value = get_option( 'meowapps_hide_ads', null );
209
+ $html = '<input type="checkbox" id="meowapps_hide_ads" name="meowapps_hide_ads" value="1" ' .
210
+ checked( 1, get_option( 'meowapps_hide_ads' ), false ) . '/>';
211
+ $html .= __( '<label>Hide</label><br /><small>Doesn\'t display the ads.</small>', 'meowapps' );
212
+ echo $html;
213
+ }
214
+
215
+ function meowapps_hide_dashboard_callback() {
216
+ $value = get_option( 'meowapps_hide_meowapps', null );
217
+ $html = '<input type="checkbox" id="meowapps_hide_meowapps" name="meowapps_hide_meowapps" value="1" ' .
218
+ checked( 1, get_option( 'meowapps_hide_meowapps' ), false ) . '/>';
219
+ $html .= __( '<label>Hide <b>Meow Apps</b> Menu</label><br /><small>Hide Meow Apps menu and all its components, for a cleaner admin. This option will be reset if a new Meow Apps plugin is installed. <b>Once activated, an option will be added in your General settings to display it again.</b></small>', 'meowapps' );
220
+ echo $html;
221
+ }
222
+
223
+ function meowapps_force_sslverify_callback() {
224
+ $value = get_option( 'force_sslverify', null );
225
+ $html = '<input type="checkbox" id="force_sslverify" name="force_sslverify" value="1" ' .
226
+ checked( 1, get_option( 'force_sslverify' ), false ) . '/>';
227
+ $html .= __( '<label>Force</label><br /><small>Updates and licenses checks are usually made without checking SSL certificates and it is actually fine this way. But if you are intransigent when it comes to SSL matters, this option will force it.</small>', 'meowapps' );
228
+ echo $html;
229
+ }
230
+
231
+ function display_serialkey_box( $url = "https://meowapps.com/" ) {
232
+ $html = '<div class="meow-box">';
233
+ $html .= '<h3 class="' . ( $this->is_registered( $this->prefix ) ? 'meow-bk-blue' : 'meow-bk-red' ) . '">Pro Version ' .
234
+ ( $this->is_registered( $this->prefix ) ? '(enabled)' : '(disabled)' ) . '</h3>';
235
+ $html .= '<div class="inside">';
236
+ echo $html;
237
+ $html = apply_filters( $this->prefix . '_meowapps_license_input', ( 'More information about the Pro version here:
238
+ <a target="_blank" href="' . $url . '">' . $url . '</a>. If you actually bought the Pro version already, please remove the current plugin and download the Pro version from your account at the <a target="_blank" href="https://store.meowapps.com/account/downloads/">Meow Apps Store</a>.' ), $url );
239
+ $html .= '</div>';
240
+ $html .= '</div>';
241
+ echo $html;
242
+ }
243
+
244
+ function is_registered() {
245
+ return apply_filters( $this->prefix . '_meowapps_is_registered', false, $this->prefix );
246
+ }
247
+
248
+ function check_install( $plugin ) {
249
+ $pro = false;
250
+
251
+ $pluginpath = trailingslashit( plugin_dir_path( __FILE__ ) ) . '../../' . $plugin . '-pro';
252
+ if ( !file_exists( $pluginpath ) ) {
253
+ $pluginpath = trailingslashit( plugin_dir_path( __FILE__ ) ) . '../../' . $plugin;
254
+ if ( !file_exists( $pluginpath ) ) {
255
+ $url = wp_nonce_url( "update.php?action=install-plugin&plugin=$plugin", "install-plugin_$plugin" );
256
+ return "<a href='$url'><small><span class='' style='float: right;'>install</span></small></a>";
257
+ }
258
+ }
259
+ else {
260
+ $pro = true;
261
+ $plugin = $plugin . "-pro";
262
+ }
263
+
264
+ $plugin_file = $plugin . '/' . $plugin . '.php';
265
+ if ( is_plugin_active( $plugin_file ) ) {
266
+ if ( $plugin == 'wplr-sync' )
267
+ $pro = true;
268
+ if ( $pro )
269
+ return "<small><span style='float: right;'><span class='dashicons dashicons-heart' style='color: rgba(255, 63, 0, 1); font-size: 30px !important; margin-right: 10px;'></span></span></small>";
270
+ else
271
+ return "<small><span style='float: right;'><span class='dashicons dashicons-yes' style='color: #00b4ff; font-size: 30px !important; margin-right: 10px;'></span></span></small>";
272
+ }
273
+ else {
274
+ $url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=' . $plugin_file ),
275
+ 'activate-plugin_' . $plugin_file );
276
+ return '<small><span style="color: black; float: right;">off
277
+ (<a style="color: rgba(30,140,190,1); text-decoration: none;" href="' .
278
+ $url . '">enable</a>)</span></small>';
279
+ }
280
+ }
281
+
282
+ function common_url( $file ) {
283
+ die( "Meow Apps: The function common_url( \$file ) needs to be overriden." );
284
+ // Normally, this should be used:
285
+ // return plugin_dir_url( __FILE__ ) . ( '\/common\/' . $file );
286
+ }
287
+
288
+ function meowapps_logo_url() {
289
+ return $this->common_url( 'img/meowapps.png' );
290
+ }
291
+
292
+ function plugins_loaded() {
293
+ if ( isset( $_GET[ 'tool' ] ) && $_GET[ 'tool' ] == 'error_log' ) {
294
+ $sec = "5";
295
+ header("Refresh: $sec;");
296
+ }
297
+ }
298
+
299
+ function admin_meow_apps() {
300
+
301
+ echo '<div class="wrap meow-dashboard">';
302
+ if ( isset( $_GET['tool'] ) && $_GET['tool'] == 'phpinfo' ) {
303
+ echo "<a href=\"javascript:history.go(-1)\">< Go back</a><br /><br />";
304
+ echo '<div id="phpinfo">';
305
+ ob_start();
306
+ phpinfo();
307
+ $pinfo = ob_get_contents();
308
+ ob_end_clean();
309
+ $pinfo = preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', $pinfo );
310
+ echo $pinfo;
311
+ echo "</div>";
312
+ }
313
+ else if ( isset( $_GET['tool'] ) && $_GET['tool'] == 'error_log' ) {
314
+ $errorpath = ini_get( 'error_log' );
315
+ echo "<a href=\"javascript:history.go(-1)\">< Go back</a><br /><br />";
316
+ echo '<div id="error_log">';
317
+ if ( file_exists( $errorpath ) ) {
318
+ echo "Now (auto-reload every 5 seconds):<br />[" . date( "d-M-Y H:i:s", time() ) . " UTC]<br /<br /><br />Errors (order by latest):";
319
+ $errors = file_get_contents( $errorpath );
320
+ $errors = explode( "\n", $errors );
321
+ $errors = array_reverse( $errors );
322
+ $errors = implode( "<br />", $errors );
323
+ echo $errors;
324
+ }
325
+ else {
326
+ echo "The PHP Error Logs cannot be found. Please ask your hosting service for it.";
327
+ }
328
+ echo "</div>";
329
+
330
+ }
331
+ else {
332
+
333
+ ?>
334
+ <?php $this->display_title(); ?>
335
+ <p>
336
+ <?php _e( 'Meow Apps is run by Jordy Meow, a photographer and software developer living in Japan (and taking <a target="_blank" href="http://offbeatjapan.org">a lot of photos</a>). Meow Apps is a suite of plugins focusing on photography, imaging, optimization and it teams up with the best players in the community (other themes and plugins developers). For more information, please check <a href="http://meowapps.com" target="_blank">Meow Apps</a>.', 'meowapps' )
337
+ ?>
338
+ </p>
339
+ <div class="meow-row">
340
+ <div class="meow-box meow-col meow-span_1_of_2 ">
341
+ <h3 class=""><span class="dashicons dashicons-camera"></span> UI Plugins </h3>
342
+ <ul class="">
343
+ <li><b>WP/LR Sync</b> <?php echo $this->check_install( 'wplr-sync' ) ?><br />
344
+ Synchronize photos (folders, collections, keywords) from Lightroom to WordPress.</li>
345
+ <li><b>Meow Lightbox</b> <?php echo $this->check_install( 'meow-lightbox' ) ?><br />
346
+ Light but powerful lightbox that can also display photo information (EXIF).</li>
347
+ <li><b>Meow Gallery</b> <?php echo $this->check_install( 'meow-gallery' ) ?><br />
348
+ Gallery (using the built-in WP gallery) that makes your website look better.</li>
349
+ <!-- <li><b>Audio Story for Images</b> <?php echo $this->check_install( 'audio-story-images' ) ?><br />
350
+ Add audio (music, explanation, ambiance) to your images.</li> -->
351
+ </ul>
352
+ </div>
353
+ <div class="meow-box meow-col meow-span_1_of_2">
354
+ <h3 class=""><span class="dashicons dashicons-admin-tools"></span> System Plugins</h3>
355
+ <ul class="">
356
+ <li><b>Media File Renamer</b> <?php echo $this->check_install( 'media-file-renamer' ) ?><br />
357
+ For nicer filenames and better SEO.</li>
358
+ <li><b>Media Cleaner</b> <?php echo $this->check_install( 'media-cleaner' ) ?><br />
359
+ Detect the files which are not in use.</li>
360
+ <li><b>WP Retina 2x</b> <?php echo $this->check_install( 'wp-retina-2x' ) ?><br />
361
+ The famous plugin that adds Retina support.</li>
362
+ </ul>
363
+ </div>
364
+ </div>
365
+
366
+ <div class="meow-row">
367
+ <div class="meow-box meow-col meow-span_2_of_3">
368
+ <h3><span class="dashicons dashicons-admin-tools"></span> Common</h3>
369
+ <div class="inside">
370
+ <form method="post" action="options.php">
371
+ <?php settings_fields( 'meowapps_common_settings' ); ?>
372
+ <?php do_settings_sections( 'meowapps_common_settings-menu' ); ?>
373
+ <?php submit_button(); ?>
374
+ </form>
375
+ </div>
376
+ </div>
377
+
378
+ <div class="meow-box meow-col meow-span_1_of_3">
379
+ <h3><span class="dashicons dashicons-admin-tools"></span> Debug</h3>
380
+ <div class="inside">
381
+ <ul>
382
+ <li><a href="?page=meowapps-main-menu&amp;tool=error_log">Display Error Log</a></li>
383
+ <li><a href="?page=meowapps-main-menu&amp;tool=phpinfo">Display PHP Info</a></li>
384
+ </ul>
385
+ </div>
386
+ </div>
387
+
388
+ <div class="meow-box meow-col meow-span_1_of_3">
389
+ <h3><span class="dashicons dashicons-admin-tools"></span> Post Types (used by this install)</h3>
390
+ <div class="inside">
391
+ <?php
392
+ global $wpdb;
393
+ // Maybe we could avoid to check more post_types.
394
+ // SELECT post_type, COUNT(*) FROM `wp_posts` GROUP BY post_type
395
+ $types = $wpdb->get_results( "SELECT post_type as 'type', COUNT(*) as 'count' FROM $wpdb->posts GROUP BY post_type" );
396
+ $result = array();
397
+ foreach( $types as $type )
398
+ array_push( $result, "{$type->type} ({$type->count})" );
399
+ echo implode( $result, ', ' );
400
+ ?>
401
+ </div>
402
+ </div>
403
+ </div>
404
+
405
+
406
+ <?php
407
+
408
+ }
409
+
410
+ echo "<br /><small style='color: lightgray;'>Meow Admin " . MeowApps_Admin::$admin_version . "</small></div>";
411
+ }
412
+
413
+ // HELPERS
414
+
415
+ static function size_shortname( $name ) {
416
+ $name = preg_split( '[_-]', $name );
417
+ $short = strtoupper( substr( $name[0], 0, 1 ) );
418
+ if ( count( $name ) > 1 )
419
+ $short .= strtoupper( substr( $name[1], 0, 1 ) );
420
+ return $short;
421
+ }
422
+
423
+ }
424
+
425
+ }
426
+
427
+ if ( file_exists( plugin_dir_path( __FILE__ ) . '/meowapps/admin.php' ) ) {
428
+ require( 'meowapps/admin.php' );
429
+ }
430
+
431
+ ?>
trunk/common/img/meowapps.png ADDED
Binary file
trunk/common/img/wpengine.png ADDED
Binary file
trunk/core.php ADDED
@@ -0,0 +1,1210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Meow_WR2X_Core {
4
+
5
+ public $admin = null;
6
+
7
+ public function __construct( $admin ) {
8
+ $this->admin = $admin;
9
+ add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
10
+ add_action( 'admin_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
11
+ add_filter( 'wp_generate_attachment_metadata', array( $this, 'wp_generate_attachment_metadata' ) );
12
+ add_action( 'delete_attachment', array( $this, 'delete_attachment' ) );
13
+ add_filter( 'generate_rewrite_rules', array( 'Meow_WR2X_Admin', 'generate_rewrite_rules' ) );
14
+ add_filter( 'retina_validate_src', array( $this, 'validate_src' ) );
15
+ add_filter( 'wp_calculate_image_srcset', array( $this, 'calculate_image_srcset' ), 1000, 3 );
16
+ add_action( 'init', array( $this, 'init' ) );
17
+ include( __DIR__ . '/api.php' );
18
+
19
+ if ( is_admin() ) {
20
+ include( __DIR__ . '/ajax.php' );
21
+ new Meow_WR2X_Ajax( $this );
22
+ if ( !get_option( "wr2x_hide_retina_dashboard" ) ) {
23
+ include( __DIR__ . '/dashboard.php' );
24
+ new Meow_WR2X_Dashboard( $this );
25
+ }
26
+ if ( !get_option( "wr2x_hide_retina_column" ) ) {
27
+ include( __DIR__ . '/media-library.php' );
28
+ new Meow_WR2X_MediaLibrary( $this );
29
+ }
30
+ //if ( !get_option( "wr2x_hide_retina_column" ) )
31
+ //include( 'wr2x_retina_uploader.php' );
32
+ }
33
+ }
34
+
35
+ function init() {
36
+ //load_plugin_textdomain( 'wp-retina-2x', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
37
+
38
+ if ( get_option( 'wr2x_disable_medium_large' ) ) {
39
+ remove_image_size( 'medium_large' );
40
+ add_filter( 'image_size_names_choose', array( $this, 'unset_medium_large' ) );
41
+ add_filter( 'intermediate_image_sizes_advanced', array( $this, 'unset_medium_large' ) );
42
+ }
43
+
44
+ if ( is_admin() ) {
45
+ wp_register_style( 'wr2x-admin-css', plugins_url( '/wr2x_admin.css', __FILE__ ) );
46
+ wp_enqueue_style( 'wr2x-admin-css' );
47
+ if ( !get_option( "wr2x_retina_admin" ) )
48
+ return;
49
+ }
50
+
51
+ $method = get_option( "wr2x_method" );
52
+ if ( $method == "Picturefill" ) {
53
+ add_action( 'wp_head', array( $this, 'picture_buffer_start' ) );
54
+ add_action( 'wp_footer', array( $this, 'picture_buffer_end' ) );
55
+ }
56
+ else if ( $method == 'HTML Rewrite' ) {
57
+ $is_retina = false;
58
+ if ( isset( $_COOKIE['devicePixelRatio'] ) ) {
59
+ $is_retina = ceil( floatval( $_COOKIE['devicePixelRatio'] ) ) > 1;
60
+ }
61
+ if ( $is_retina || $this->is_debug() ) {
62
+ add_action( 'wp_head', array( $this, 'buffer_start' ) );
63
+ add_action( 'wp_footer', array( $this, 'buffer_end' ) );
64
+ }
65
+ }
66
+
67
+ }
68
+
69
+ function unset_medium_large( $sizes ) {
70
+ unset( $sizes['medium_large'] );
71
+ return $sizes;
72
+ }
73
+
74
+ /**
75
+ *
76
+ * PICTURE METHOD
77
+ *
78
+ */
79
+
80
+ function is_supported_image( $url ) {
81
+ $wr2x_supported_image = array( 'jpg', 'jpeg', 'png', 'gif' );
82
+ $ext = strtolower( pathinfo( $url, PATHINFO_EXTENSION ) );
83
+ if ( !in_array( $ext, $wr2x_supported_image ) ) {
84
+ $this->log( "Extension (" . $ext . ") is not " . implode( ', ', $wr2x_supported_image ) . "." );
85
+ return false;
86
+ }
87
+ return true;
88
+ }
89
+
90
+ function picture_buffer_start() {
91
+ ob_start( array( $this, "picture_rewrite" ) );
92
+ $this->log( "* HTML REWRITE FOR PICTUREFILL" );
93
+ }
94
+
95
+ function picture_buffer_end() {
96
+ @ob_end_flush();
97
+ }
98
+
99
+ // Replace the IMG tags by PICTURE tags with SRCSET
100
+ function picture_rewrite( $buffer ) {
101
+ if ( !isset( $buffer ) || trim( $buffer ) === '' )
102
+ return $buffer;
103
+ if ( !function_exists( "str_get_html" ) )
104
+ include( __DIR__ . '/inc/simple_html_dom.php' );
105
+
106
+ $lazysize = get_option( "wr2x_picturefill_lazysizes" ) && $this->admin->is_registered();
107
+ $killsrc = !get_option( "wr2x_picturefill_keep_src" );
108
+ $nodes_count = 0;
109
+ $nodes_replaced = 0;
110
+ $html = str_get_html( $buffer );
111
+ if ( !$html ) {
112
+ $this->log( "The HTML buffer is null, another plugin might block the process." );
113
+ return $buffer;
114
+ }
115
+
116
+ // IMG TAGS
117
+ foreach( $html->find( 'img' ) as $element ) {
118
+ $nodes_count++;
119
+ $parent = $element->parent();
120
+ if ( $parent->tag == "picture" ) {
121
+ $this->log("The img tag is inside a picture tag. Tag ignored.");
122
+ continue;
123
+ }
124
+ else {
125
+ $valid = apply_filters( "wr2x_validate_src", $element->src );
126
+ if ( empty( $valid ) ) {
127
+ $nodes_count--;
128
+ continue;
129
+ }
130
+
131
+ // Original HTML
132
+ $from = substr( $element, 0 );
133
+
134
+ // SRC-SET already exists, let's check if LazySize is used
135
+ if ( !empty( $element->srcset ) ) {
136
+ if ( $lazysize ) {
137
+ $this->log( "The src-set has already been created but it will be modifid to data-srcset for lazyload." );
138
+ $element->class = $element->class . ' lazyload';
139
+ $element->{'data-srcset'} = $element->srcset;
140
+ $element->srcset = null;
141
+ if ( $killsrc )
142
+ $element->src = null;
143
+ $to = $element;
144
+ $buffer = str_replace( trim( $from, "</> "), trim( $to, "</> " ), $buffer );
145
+ $this->log( "The img tag '$from' was rewritten to '$to'" );
146
+ $nodes_replaced++;
147
+ }
148
+ else {
149
+ $this->log( "The src-set has already been created. Tag ignored." );
150
+ }
151
+ continue;
152
+ }
153
+
154
+ // Process of SRC-SET creation
155
+ if ( !$this->is_supported_image( $element->src ) ) {
156
+ $nodes_count--;
157
+ continue;
158
+ }
159
+ $retina_url = $this->get_retina_from_url( $element->src );
160
+ $retina_url = apply_filters( 'wr2x_img_retina_url', $retina_url );
161
+ if ( $retina_url != null ) {
162
+ $retina_url = $this->cdn_this( $retina_url );
163
+ $img_url = $this->cdn_this( $element->src );
164
+ $img_url = apply_filters( 'wr2x_img_url', $img_url );
165
+ if ( $lazysize ) {
166
+ $element->class = $element->class . ' lazyload';
167
+ $element->{'data-srcset'} = "$img_url, $retina_url 2x";
168
+ }
169
+ else
170
+ $element->srcset = "$img_url, $retina_url 2x";
171
+ if ( $killsrc )
172
+ $element->src = null;
173
+ else {
174
+ $img_src = apply_filters( 'wr2x_img_src', $element->src );
175
+ $element->src = $this->cdn_this( $img_src );
176
+ }
177
+ $to = $element;
178
+ $buffer = str_replace( trim( $from, "</> "), trim( $to, "</> " ), $buffer );
179
+ $this->log( "The img tag '$from' was rewritten to '$to'" );
180
+ $nodes_replaced++;
181
+ }
182
+ else {
183
+ $this->log( "The img tag was not rewritten. No retina for '" . $element->src . "'." );
184
+ }
185
+ }
186
+ }
187
+ $this->log( "$nodes_replaced/$nodes_count img tags were replaced." );
188
+
189
+ // INLINE CSS BACKGROUND
190
+ if ( get_option( 'wr2x_picturefill_css_background', false ) && $this->admin->is_registered() ) {
191
+ preg_match_all( "/url(?:\(['\"]?)(.*?)(?:['\"]?\))/", $buffer, $matches );
192
+ $match_css = $matches[0];
193
+ $match_url = $matches[1];
194
+ if ( count( $matches ) != 2 )
195
+ return $buffer;
196
+ $nodes_count = 0;
197
+ $nodes_replaced = 0;
198
+ for ( $c = 0; $c < count( $matches[0] ); $c++ ) {
199
+ $css = $match_css[$c];
200
+ $url = $match_url[$c];
201
+ if ( !$this->is_supported_image( $url ) )
202
+ continue;
203
+ $nodes_count++;
204
+ $retina_url = $this->get_retina_from_url( $url );
205
+ $retina_url = apply_filters( 'wr2x_img_retina_url', $retina_url );
206
+ if ( $retina_url != null ) {
207
+ $retina_url = $this->cdn_this( $retina_url );
208
+ $minibuffer = str_replace( $url, $retina_url, $css );
209
+ $buffer = str_replace( $css, $minibuffer, $buffer );
210
+ $this->log( "The background src '$css' was rewritten to '$minibuffer'" );
211
+ $nodes_replaced++;
212
+ }
213
+ else {
214
+ $this->log( "The background src was not rewritten. No retina for '" . $url . "'." );
215
+ }
216
+ }
217
+ $this->log( "$nodes_replaced/$nodes_count background src were replaced." );
218
+ }
219
+
220
+ return $buffer;
221
+ }
222
+
223
+ /**
224
+ *
225
+ * HTML REWRITE METHOD
226
+ *
227
+ */
228
+
229
+ function buffer_start () {
230
+ ob_start( array( $this, "html_rewrite" ) );
231
+ $this->log( "* HTML REWRITE" );
232
+ }
233
+
234
+ function buffer_end () {
235
+ @ob_end_flush();
236
+ }
237
+
238
+ // Replace the images by retina images (if available)
239
+ function html_rewrite( $buffer ) {
240
+ if ( !isset( $buffer ) || trim( $buffer ) === '' )
241
+ return $buffer;
242
+ $nodes_count = 0;
243
+ $nodes_replaced = 0;
244
+ $doc = new DOMDocument();
245
+ @$doc->loadHTML( $buffer ); // = ($doc->strictErrorChecking = false;)
246
+ $imageTags = $doc->getElementsByTagName('img');
247
+ foreach ( $imageTags as $tag ) {
248
+ $nodes_count++;
249
+ $img_pathinfo = $this->get_pathinfo_from_image_src( $tag->getAttribute('src') );
250
+ $filepath = trailingslashit( $this->get_upload_root() ) . $img_pathinfo;
251
+ $system_retina = $this->get_retina( $filepath );
252
+ if ( $system_retina != null ) {
253
+ $retina_pathinfo = $this->cdn_this( ltrim( str_replace( $this->get_upload_root(), "", $system_retina ), '/' ) );
254
+ $buffer = str_replace( $img_pathinfo, $retina_pathinfo, $buffer );
255
+ $this->log( "The img src '$img_pathinfo' was replaced by '$retina_pathinfo'" );
256
+ $nodes_replaced++;
257
+ }
258
+ else {
259
+ $this->log( "The file '$system_retina' was not found. Tag not modified." );
260
+ }
261
+ }
262
+ $this->log( "$nodes_replaced/$nodes_count were replaced." );
263
+ return $buffer;
264
+ }
265
+
266
+
267
+ // Converts PHP INI size type (e.g. 24M) to int
268
+ function parse_ini_size( $size ) {
269
+ $unit = preg_replace('/[^bkmgtpezy]/i', '', $size);
270
+ $size = preg_replace('/[^0-9\.]/', '', $size);
271
+ if ( $unit )
272
+ return round( $size * pow( 1024, stripos( 'bkmgtpezy', $unit[0] ) ) );
273
+ else
274
+ round( $size );
275
+ }
276
+
277
+ function get_max_filesize() {
278
+ if ( defined ('HHVM_VERSION' ) ) {
279
+ $post_max_size = ini_get( 'post_max_size' ) ? (int)$this->parse_ini_size( ini_get( 'post_max_size' ) ) : (int)ini_get( 'hhvm.server.max_post_size' );
280
+ $upload_max_filesize = ini_get( 'upload_max_filesize' ) ? (int)$this->parse_ini_size( ini_get( 'upload_max_filesize' ) ) :
281
+ (int)ini_get( 'hhvm.server.upload.upload_max_file_size' );
282
+ }
283
+ else {
284
+ $post_max_size = (int)$this->parse_ini_size( ini_get( 'post_max_size' ) );
285
+ $upload_max_filesize = (int)$this->parse_ini_size( ini_get( 'upload_max_filesize' ) );
286
+ }
287
+ $max = min( $post_max_size, $upload_max_filesize );
288
+ return $max > 0 ? $max : 66600000;
289
+ }
290
+
291
+ /**
292
+ *
293
+ * RESPONSIVE IMAGES METHOD
294
+ *
295
+ */
296
+
297
+ function calculate_image_srcset( $srcset, $size ) {
298
+ if ( get_option( "wr2x_disable_responsive" ) )
299
+ return null;
300
+ $method = get_option( "wr2x_method" );
301
+ if ( $method == "none" )
302
+ return $srcset;
303
+ $count = 0;
304
+ $total = 0;
305
+ $retinized_srcset = $srcset;
306
+ if ( empty( $srcset ) )
307
+ return $srcset;
308
+ foreach ( $srcset as $s => $cfg ) {
309
+ $total++;
310
+ $retina = $this->cdn_this( $this->get_retina_from_url( $cfg['url'] ) );
311
+ if ( !empty( $retina ) ) {
312
+ $count++;
313
+ $retinized_srcset[(int)$s * 2] = array(
314
+ 'url' => $retina,
315
+ 'descriptor' => 'w',
316
+ 'value' => (int)$s * 2 );
317
+ }
318
+ }
319
+ $this->log( "WP's srcset: " . $count . " retina files added out of " . $total . " image sizes" );
320
+ return $retinized_srcset;
321
+ }
322
+
323
+ /**
324
+ *
325
+ * ISSUES CALCULATION AND FUNCTIONS
326
+ *
327
+ */
328
+
329
+ // Compares two images dimensions (resolutions) against each while accepting an margin error
330
+ function are_dimensions_ok( $width, $height, $retina_width, $retina_height ) {
331
+ $w_margin = $width - $retina_width;
332
+ $h_margin = $height - $retina_height;
333
+ return ( $w_margin >= -2 && $h_margin >= -2 );
334
+ }
335
+
336
+ // UPDATE THE ISSUE STATUS OF THIS ATTACHMENT
337
+ function update_issue_status( $attachmentId, $issues = null, $info = null ) {
338
+ if ( $this->is_ignore( $attachmentId ) )
339
+ return;
340
+ if ( $issues == null )
341
+ $issues = $this->get_issues();
342
+ if ( $info == null )
343
+ $info = $this->retina_info( $attachmentId );
344
+ $consideredIssue = in_array( $attachmentId, $issues );
345
+ $realIssue = $this->info_has_issues( $info );
346
+ if ( $consideredIssue && !$realIssue )
347
+ $this->remove_issue( $attachmentId );
348
+ else if ( !$consideredIssue && $realIssue )
349
+ $this->add_issue( $attachmentId );
350
+ return $realIssue;
351
+ }
352
+
353
+ function get_issues() {
354
+ $issues = get_transient( 'wr2x_issues' );
355
+ if ( !$issues || !is_array( $issues ) ) {
356
+ $issues = array();
357
+ set_transient( 'wr2x_issues', $issues );
358
+ }
359
+ return $issues;
360
+ }
361
+
362
+ // CHECK IF THE 'INFO' OBJECT CONTAINS ISSUE (RETURN TRUE OR FALSE)
363
+ function info_has_issues( $info ) {
364
+ foreach ( $info as $aindex => $aval ) {
365
+ if ( is_array( $aval ) || $aval == 'PENDING' )
366
+ return true;
367
+ }
368
+ return false;
369
+ }
370
+
371
+ function calculate_issues() {
372
+ global $wpdb;
373
+ $postids = $wpdb->get_col( "
374
+ SELECT p.ID FROM $wpdb->posts p
375
+ WHERE post_status = 'inherit'
376
+ AND post_type = 'attachment'" . $this->create_sql_if_wpml_original() . "
377
+ AND ( post_mime_type = 'image/jpeg' OR
378
+ post_mime_type = 'image/jpg' OR
379
+ post_mime_type = 'image/png' OR
380
+ post_mime_type = 'image/gif' )
381
+ " );
382
+ $issues = array();
383
+ foreach ( $postids as $id ) {
384
+ $info = $this->retina_info( $id );
385
+ if ( $this->info_has_issues( $info ) )
386
+ array_push( $issues, $id );
387
+
388
+ }
389
+ set_transient( 'wr2x_ignores', array() );
390
+ set_transient( 'wr2x_issues', $issues );
391
+ }
392
+
393
+ function add_issue( $attachmentId ) {
394
+ if ( $this->is_ignore( $attachmentId ) )
395
+ return;
396
+ $issues = $this->get_issues();
397
+ if ( !in_array( $attachmentId, $issues ) ) {
398
+ array_push( $issues, $attachmentId );
399
+ set_transient( 'wr2x_issues', $issues );
400
+ }
401
+ return $issues;
402
+ }
403
+
404
+ function remove_issue( $attachmentId, $onlyIgnore = false ) {
405
+ $issues = array_diff( $this->get_issues(), array( $attachmentId ) );
406
+ set_transient( 'wr2x_issues', $issues );
407
+ if ( !$onlyIgnore )
408
+ $this->remove_ignore( $attachmentId );
409
+ return $issues;
410
+ }
411
+
412
+ // IGNORE
413
+
414
+ function get_ignores( $force = false ) {
415
+ $ignores = get_transient( 'wr2x_ignores' );
416
+ if ( !$ignores || !is_array( $ignores ) ) {
417
+ $ignores = array();
418
+ set_transient( 'wr2x_ignores', $ignores );
419
+ }
420
+ return $ignores;
421
+ }
422
+
423
+ function is_ignore( $attachmentId ) {
424
+ $ignores = $this->get_ignores();
425
+ return in_array( $attachmentId, $this->get_ignores() );
426
+ }
427
+
428
+ function remove_ignore( $attachmentId ) {
429
+ $ignores = $this->get_ignores();
430
+ $ignores = array_diff( $ignores, array( $attachmentId ) );
431
+ set_transient( 'wr2x_ignores', $ignores );
432
+ return $ignores;
433
+ }
434
+
435
+ function add_ignore( $attachmentId ) {
436
+ $ignores = $this->get_ignores();
437
+ if ( !in_array( $attachmentId, $ignores ) ) {
438
+ array_push( $ignores, $attachmentId );
439
+ set_transient( 'wr2x_ignores', $ignores );
440
+ }
441
+ $this->remove_issue( $attachmentId, true );
442
+ return $ignores;
443
+ }
444
+
445
+ /**
446
+ *
447
+ * INFORMATION ABOUT THE RETINA IMAGE IN HTML
448
+ *
449
+ */
450
+
451
+ function html_get_basic_retina_info_full( $attachmentId, $retina_info ) {
452
+ $status = ( isset( $retina_info ) && isset( $retina_info['full-size'] ) ) ? $retina_info['full-size'] : 'IGNORED';
453
+ if ( $status == 'EXISTS' ) {
454
+ return '<ul class="meow-sized-images"><li class="meow-bk-blue" title="full-size"></li></ul>';
455
+ }
456
+ else if ( is_array( $status ) ) {
457
+ return '<ul class="meow-sized-images"><li class="meow-bk-orange" title="full-size"></li></ul>';
458
+ }
459
+ else if ( $status == 'IGNORED' ) {
460
+ return __( "N/A", "wp-retina-2x" );
461
+ }
462
+ return $status;
463
+ }
464
+
465
+ function format_title( $i, $size ) {
466
+ return $i . ' (' . ( $size['width'] * 2 ) . 'x' . ( $size['height'] * 2 ) . ')';
467
+ }
468
+
469
+ // Information for the 'Media Sizes Retina-ized' Column in the Retina Dashboard
470
+ function html_get_basic_retina_info( $attachmentId, $retina_info ) {
471
+ $sizes = $this->get_active_image_sizes();
472
+ $result = '<ul class="meow-sized-images" postid="' . ( is_integer( $attachmentId ) ? $attachmentId : $attachmentId->ID ) . '">';
473
+ foreach ( $sizes as $i => $size ) {
474
+ $status = ( isset( $retina_info ) && isset( $retina_info[$i] ) ) ? $retina_info[$i] : null;
475
+ if ( is_array( $status ) )
476
+ $result .= '<li class="meow-bk-red" title="' . $this->format_title( $i, $size ) . '">'
477
+ . MeowApps_Admin::size_shortname( $i ) . '</li>';
478
+ else if ( $status == 'EXISTS' )
479
+ $result .= '<li class="meow-bk-blue" title="' . $this->format_title( $i, $size ) . '">'
480
+ . MeowApps_Admin::size_shortname( $i ) . '</li>';
481
+ else if ( $status == 'PENDING' )
482
+ $result .= '<li class="meow-bk-orange" title="' . $this->format_title( $i, $size ) . '">'
483
+ . MeowApps_Admin::size_shortname( $i ) . '</li>';
484
+ else if ( $status == 'MISSING' )
485
+ $result .= '<li class="meow-bk-red" title="' . $this->format_title( $i, $size ) . '">'
486
+ . MeowApps_Admin::size_shortname( $i ) . '</li>';
487
+ else if ( $status == 'IGNORED' )
488
+ $result .= '<li class="meow-bk-gray" title="' . $this->format_title( $i, $size ) . '">'
489
+ . MeowApps_Admin::size_shortname( $i ) . '</li>';
490
+ else {
491
+ error_log( "Retina: This status is not recognized: " . $status );
492
+ }
493
+ }
494
+ $result .= '</ul>';
495
+ return $result;
496
+ }
497
+
498
+ // Information for Details in the Retina Dashboard
499
+ function html_get_details_retina_info( $post, $retina_info ) {
500
+ if ( !$this->admin->is_registered() ) {
501
+ return __( "PRO VERSION ONLY", 'wp-retina-2x' );
502
+ }
503
+
504
+ $sizes = $this->get_image_sizes();
505
+ $total = 0; $possible = 0; $issue = 0; $ignored = 0; $retina = 0;
506
+
507
+ $postinfo = get_post( $post, OBJECT );
508
+ $meta = wp_get_attachment_metadata( $post );
509
+ $fullsize_file = get_attached_file( $post );
510
+ $pathinfo_system = pathinfo( $fullsize_file );
511
+ $pathinfo = pathinfo( $meta['file'] );
512
+ $uploads = wp_upload_dir();
513
+ $basepath_url = trailingslashit( $uploads['baseurl'] ) . $pathinfo['dirname'];
514
+ if ( get_option( "wr2x_full_size" ) ) {
515
+ $sizes['full-size']['file'] = $pathinfo['basename'];
516
+ $sizes['full-size']['width'] = $meta['width'];
517
+ $sizes['full-size']['height'] = $meta['height'];
518
+ $meta['sizes']['full-size']['file'] = $pathinfo['basename'];
519
+ $meta['sizes']['full-size']['width'] = $meta['width'];
520
+ $meta['sizes']['full-size']['height'] = $meta['height'];
521
+ }
522
+ $result = "<p>This screen displays all the image sizes set-up by your WordPress configuration with the Retina details.</p>";
523
+ $result .= "<br /><a target='_blank' href='" . trailingslashit( $uploads['baseurl'] ) . $meta['file'] . "'><img src='" . trailingslashit( $uploads['baseurl'] ) . $meta['file'] . "' height='100px' style='float: left; margin-right: 10px;' /></a><div class='base-info'>";
524
+ $result .= "Title: <b>" . ( $postinfo->post_title ? $postinfo->post_title : '<i>Untitled</i>' ) . "</b><br />";
525
+ $result .= "Full-size: <b>" . $meta['width'] . "×" . $meta['height'] . "</b><br />";
526
+ $result .= "Image URL: <a target='_blank' href='" . trailingslashit( $uploads['baseurl'] ) . $meta['file'] . "'>" . trailingslashit( $uploads['baseurl'] ) . $meta['file'] . "</a><br />";
527
+ $result .= "Image Path: " . $fullsize_file . "<br />";
528
+ $result .= "</div><div style='clear: both;'></div><br />";
529
+ $result .= "<div class='scrollable-info'>";
530
+
531
+ foreach ( $sizes as $i => $sizemeta ) {
532
+ $total++;
533
+ $normal_file_system = ""; $retina_file_system = "";
534
+ $normal_file = ""; $retina_file = ""; $width = ""; $height = "";
535
+
536
+ if ( isset( $retina_info[$i] ) && $retina_info[$i] == 'IGNORED' ) {
537
+ $status = "IGNORED";
538
+ }
539
+ else if ( !isset( $meta['sizes'] ) ) {
540
+ $statusText = __( "The metadata is broken! This is not related to the retina plugin. You should probably use a plugin to re-generate the missing metadata and images.", 'wp-retina-2x' );
541
+ $status = "MISSING";
542
+ }
543
+ else if ( !isset( $meta['sizes'][$i] ) ) {
544
+ $statusText = sprintf( __( "The image size '%s' could not be found. You probably changed your image sizes but this specific image was not re-build. This is not related to the retina plugin. You should probably use a plugin to re-generate the missing metadata and images.", 'wp-retina-2x' ), $i );
545
+ $status = "MISSING";
546
+ }
547
+ else {
548
+ $normal_file_system = trailingslashit( $pathinfo_system['dirname'] ) . $meta['sizes'][$i]['file'];
549
+ $retina_file_system = $this->get_retina( $normal_file_system );
550
+ $normal_file = trailingslashit( $basepath_url ) . $meta['sizes'][$i]['file'];
551
+ $retina_file = $this->get_retina_from_url( $normal_file );
552
+ $status = ( isset( $retina_info ) && isset( $retina_info[$i] ) ) ? $retina_info[$i] : null;
553
+ $width = $meta['sizes'][$i]['width'];
554
+ $height = $meta['sizes'][$i]['height'];
555
+ }
556
+
557
+ $result .= "<h3>";
558
+
559
+ // Status Icon
560
+ if ( is_array( $status ) && $i == 'full-size' ) {
561
+ $result .= '<div class="meow-sized-image meow-bk-red"></div>';
562
+ $statusText = sprintf( __( "The retina version of the Full-Size image is missing.<br />Full Size Retina has been checked in the Settings and this image is therefore required.<br />Please drag & drop an image of at least <b>%dx%d</b> in the <b>Full-Size Retina Upload</b> column.", 'wp-retina-2x' ), $status['width'], $status['height'] );
563
+ }
564
+ else if ( is_array( $status ) ) {
565
+ $result .= '<div class="meow-sized-image meow-bk-red"></div>';
566
+ $statusText = sprintf( __( "The Full-Size image is too small (<b>%dx%d</b>) and this size cannot be generated.<br />Please upload an image of at least <b>%dx%d</b>.", 'wp-retina-2x' ), $meta['width'], $meta['height'], $status['width'], $status['height'] );
567
+ $issue++;
568
+ }
569
+ else if ( $status == 'EXISTS' ) {
570
+ $result .= '<div class="meow-sized-image meow-bk-blue"></div>';
571
+ $statusText = "";
572
+ $retina++;
573
+ }
574
+ else if ( $status == 'PENDING' ) {
575
+ $result .= '<div class="meow-sized-image meow-bk-orange"></div>';
576
+ $statusText = __( "The retina image can be created. Please use the 'GENERATE' button.", 'wp-retina-2x' );
577
+ $possible++;
578
+ }
579
+ else if ( $status == 'MISSING' ) {
580
+ $result .= '<div class="meow-sized-image meow-bk-gray"></div>';
581
+ $statusText = __( "The standard image normally created by WordPress is missing.", 'wp-retina-2x' );
582
+ $total--;
583
+ }
584
+ else if ( $status == 'IGNORED' ) {
585
+ $result .= '<div class="meow-sized-image meow-bk-gray"></div>';
586
+ $statusText = __( "This size is ignored by your retina settings.", 'wp-retina-2x' );
587
+ $ignored++;
588
+ $total--;
589
+ }
590
+
591
+ $result .= "&nbsp;Size: $i</h3><p>$statusText</p>";
592
+
593
+ if ( !is_array( $status ) && $status !== 'IGNORED' && $status !== 'MISSING' ) {
594
+ $result .= "<table><tr><th>Normal (" . $width . "×" . $height. ")</th><th>Retina 2x (" . $width * 2 . "×" . $height * 2 . ")</th></tr><tr><td><a target='_blank' href='$normal_file'><img src='$normal_file' width='100'></a></td><td><a target='_blank' href='$retina_file'><img src='$retina_file' width='100'></a></td></tr></table>";
595
+ $result .= "<p><small>";
596
+ $result .= "Image URL: <a target='_blank' href='$normal_file'>$normal_file</a><br />";
597
+ $result .= "Retina URL: <a target='_blank' href='$retina_file'>$retina_file</a><br />";
598
+ $result .= "Image Path: $normal_file_system<br />";
599
+ $result .= "Retina Path: $retina_file_system<br />";
600
+ $result .= "</small></p>";
601
+ }
602
+ }
603
+ $result .= "</table>";
604
+ $result .= "</div>";
605
+ return $result;
606
+ }
607
+
608
+ /**
609
+ *
610
+ * WP RETINA 2X CORE
611
+ *
612
+ */
613
+
614
+ // Get WordPress upload directory
615
+ function get_upload_root() {
616
+ $uploads = wp_upload_dir();
617
+ return $uploads['basedir'];
618
+ }
619
+
620
+ function get_upload_root_url() {
621
+ $uploads = wp_upload_dir();
622
+ return $uploads['baseurl'];
623
+ }
624
+
625
+ // Get WordPress directory
626
+ function get_wordpress_root() {
627
+ return ABSPATH;
628
+ }
629
+
630
+ // Resize the image
631
+ function resize( $file_path, $width, $height, $crop, $newfile, $customCrop = false ) {
632
+ $crop_params = $crop == '1' ? true : $crop;
633
+ $orig_size = getimagesize( $file_path );
634
+ $image_src[0] = $file_path;
635
+ $image_src[1] = $orig_size[0];
636
+ $image_src[2] = $orig_size[1];
637
+ $file_info = pathinfo( $file_path );
638
+ $newfile_info = pathinfo( $newfile );
639
+ $extension = '.' . $newfile_info['extension'];
640
+ $no_ext_path = $file_info['dirname'] . '/' . $file_info['filename'];
641
+ $cropped_img_path = $no_ext_path . '-' . $width . 'x' . $height . "-tmp" . $extension;
642
+ $image = wp_get_image_editor( $file_path );
643
+
644
+ if ( is_wp_error( $image ) ) {
645
+ $this->log( "Resize failure: " . $image->get_error_message() );
646
+ error_log( "Resize failure: " . $image->get_error_message() );
647
+ return null;
648
+ }
649
+
650
+ // Resize or use Custom Crop
651
+ if ( !$customCrop )
652
+ $image->resize( $width, $height, $crop_params );
653
+ else
654
+ $image->crop( $customCrop['x'] * $customCrop['scale'], $customCrop['y'] * $customCrop['scale'], $customCrop['w'] * $customCrop['scale'], $customCrop['h'] * $customCrop['scale'], $width, $height, false );
655
+
656
+ // Quality
657
+ $quality = get_option( 'wr2x_quality', 90 );
658
+ $image->set_quality( $quality );
659
+
660
+ $saved = $image->save( $cropped_img_path );
661
+ if ( is_wp_error( $saved ) ) {
662
+ $error = $saved->get_error_message();
663
+ trigger_error( "Retina: Could not create/resize image " . $file_path . " to " . $newfile . ": " . $error , E_WARNING );
664
+ error_log( "Retina: Could not create/resize image " . $file_path . " to " . $newfile . ":" . $error );
665
+ return null;
666
+ }
667
+ if ( rename( $saved['path'], $newfile ) )
668
+ $cropped_img_path = $newfile;
669
+ else {
670
+ trigger_error( "Retina: Could not move " . $saved['path'] . " to " . $newfile . "." , E_WARNING );
671
+ error_log( "Retina: Could not move " . $saved['path'] . " to " . $newfile . "." );
672
+ return null;
673
+ }
674
+ $new_img_size = getimagesize( $cropped_img_path );
675
+ $new_img = str_replace( basename( $image_src[0] ), basename( $cropped_img_path ), $image_src[0] );
676
+ $vt_image = array ( 'url' => $new_img, 'width' => $new_img_size[0], 'height' => $new_img_size[1] );
677
+ return $vt_image;
678
+ }
679
+
680
+ // Return the retina file if there is any (system path)
681
+ function get_retina( $file ) {
682
+ $pathinfo = pathinfo( $file ) ;
683
+ if ( empty( $pathinfo ) || !isset( $pathinfo['dirname'] ) ) {
684
+ if ( empty( $file ) ) {
685
+ $this->log( "An empty filename was given to $this->get_retina()." );
686
+ error_log( "An empty filename was given to $this->get_retina()." );
687
+ }
688
+ else {
689
+ $this->log( "Pathinfo is null for " . $file . "." );
690
+ error_log( "Pathinfo is null for " . $file . "." );
691
+ }
692
+ return null;
693
+ }
694
+ $retina_file = trailingslashit( $pathinfo['dirname'] ) . $pathinfo['filename'] .
695
+ $this->retina_extension() . ( isset( $pathinfo['extension'] ) ? $pathinfo['extension'] : "" );
696
+ if ( file_exists( $retina_file ) )
697
+ return $retina_file;
698
+ $this->log( "Retina file at '{$retina_file}' does not exist." );
699
+ return null;
700
+ }
701
+
702
+ function get_retina_from_remote_url( $url ) {
703
+ $over_http = get_option( 'wr2x_over_http_check', false ) && $this->admin->is_registered();
704
+ if ( !$over_http )
705
+ return null;
706
+ $potential_retina_url = $this->rewrite_url_to_retina( $url );
707
+ $response = wp_remote_head( $potential_retina_url, array(
708
+ 'user-agent' => "MeowApps-Retina",
709
+ 'sslverify' => false,
710
+ 'timeout' => 10
711
+ ));
712
+ if ( is_array( $response ) && is_array( $response['response'] ) && isset( $response['response']['code'] ) ) {
713
+ if ( $response['response']['code'] == 200 ) {
714
+ $this->log( "Retina URL: " . $potential_retina_url, true);
715
+ return $potential_retina_url;
716
+ }
717
+ else
718
+ $this->log( "Remote head failed with code " . $response['response']['code'] . "." );
719
+ }
720
+ $this->log( "Retina URL couldn't be found (URL -> Retina URL).", true);
721
+ }
722
+
723
+ // Return retina URL from the image URL
724
+ function get_retina_from_url( $url ) {
725
+ $this->log( "Standard URL: " . $url, true);
726
+ $over_http = get_option( 'wr2x_over_http_check', false ) && $this->admin->is_registered();
727
+ $filepath = $this->from_url_to_system( $url );
728
+ if ( empty ( $filepath ) )
729
+ return $this->get_retina_from_remote_url( $url );
730
+ $this->log( "Standard PATH: " . $filepath, true);
731
+ $system_retina = $this->get_retina( $filepath );
732
+ if ( empty ( $system_retina ) )
733
+ return $this->get_retina_from_remote_url( $url );
734
+ $this->log( "Retina PATH: " . $system_retina, true);
735
+ $retina_url = $this->rewrite_url_to_retina( $url );
736
+ $this->log( "Retina URL: " . $retina_url, true);
737
+ return $retina_url;
738
+ }
739
+
740
+ // Get the filepath from the URL
741
+ function from_url_to_system( $url ) {
742
+ $img_pathinfo = $this->get_pathinfo_from_image_src( $url );
743
+ $filepath = trailingslashit( $this->get_wordpress_root() ) . $img_pathinfo;
744
+ if ( file_exists( $filepath ) )
745
+ return $filepath;
746
+ $filepath = trailingslashit( $this->get_upload_root() ) . $img_pathinfo;
747
+ if ( file_exists( $filepath ) )
748
+ return $filepath;
749
+ $this->log( "Standard PATH couldn't be found (URL -> System).", true);
750
+ return null;
751
+ }
752
+
753
+ function rewrite_url_to_retina( $url ) {
754
+ $whereisdot = strrpos( $url, '.' );
755
+ $url = substr( $url, 0, $whereisdot ) . $this->retina_extension() . substr( $url, $whereisdot + 1 );
756
+ return $url;
757
+ }
758
+
759
+ // Clean the PathInfo of the IMG SRC.
760
+ // IMPORTANT: This function STRIPS THE UPLOAD FOLDER if it's found
761
+ // REASON: The reason is that on some installs the uploads folder is linked to a different "unlogical" physical folder
762
+ // http://wordpress.org/support/topic/cant-find-retina-file-with-custom-uploads-constant?replies=3#post-5078892
763
+ function get_pathinfo_from_image_src( $image_src ) {
764
+ $uploads_url = trailingslashit( $this->get_upload_root_url() );
765
+ if ( strpos( $image_src, $uploads_url ) === 0 )
766
+ return ltrim( substr( $image_src, strlen( $uploads_url ) ), '/');
767
+ else if ( strpos( $image_src, wp_make_link_relative( $uploads_url ) ) === 0 )
768
+ return ltrim( substr( $image_src, strlen( wp_make_link_relative( $uploads_url ) ) ), '/');
769
+ $img_info = parse_url( $image_src );
770
+ return ltrim( $img_info['path'], '/' );
771
+ }
772
+
773
+ // Rename this filename with CDN
774
+ function cdn_this( $url ) {
775
+ $cdn_domain = "";
776
+ if ( $this->admin->is_registered() )
777
+ $cdn_domain = get_option( "wr2x_cdn_domain" );
778
+ if ( empty( $cdn_domain ) )
779
+ return $url;
780
+
781
+ $home_url = parse_url( home_url() );
782
+ $uploads_url = trailingslashit( $this->get_upload_root_url() );
783
+ $uploads_url_cdn = str_replace( $home_url['host'], $cdn_domain, $uploads_url );
784
+ // Perform additional CDN check (Issue #1631 by Martin)
785
+ if ( strpos( $url, $uploads_url_cdn ) === 0 ) {
786
+ $this->log( "URL already has CDN: $url" );
787
+ return $url;
788
+ }
789
+ $this->log( "URL before CDN: $url" );
790
+ $site_url = preg_replace( '#^https?://#', '', rtrim( get_site_url(), '/' ) );
791
+ $new_url = str_replace( $site_url, $cdn_domain, $url );
792
+ $this->log( "URL with CDN: $new_url" );
793
+ return $new_url;
794
+ }
795
+
796
+ // function admin_menu() {
797
+ // add_options_page( 'Retina', 'Retina', 'manage_options', 'wr2x_settings', 'wr2x_settings_page' );
798
+ // }
799
+
800
+ function get_image_sizes() {
801
+ $sizes = array();
802
+ global $_wp_additional_image_sizes;
803
+ foreach ( get_intermediate_image_sizes() as $s ) {
804
+ $crop = false;
805
+ if ( isset( $_wp_additional_image_sizes[$s] ) ) {
806
+ $width = intval($_wp_additional_image_sizes[$s]['width']);
807
+ $height = intval($_wp_additional_image_sizes[$s]['height']);
808
+ $crop = $_wp_additional_image_sizes[$s]['crop'];
809
+ } else {
810
+ $width = get_option( $s . '_size_w' );
811
+ $height = get_option( $s . '_size_h' );
812
+ $crop = get_option( $s . '_crop' );
813
+ }
814
+ $sizes[$s] = array( 'width' => $width, 'height' => $height, 'crop' => $crop );
815
+ }
816
+ if ( get_option( 'wr2x_disable_medium_large' ) )
817
+ unset( $sizes['medium_large'] );
818
+ return $sizes;
819
+ }
820
+
821
+ function get_active_image_sizes() {
822
+ $sizes = $this->get_image_sizes();
823
+ $active_sizes = array();
824
+ $ignore = get_option( "wr2x_ignore_sizes", array() );
825
+ if ( empty( $ignore ) )
826
+ $ignore = array();
827
+ $ignore = array_keys( $ignore );
828
+ foreach ( $sizes as $name => $attr ) {
829
+ $validSize = !empty( $attr['width'] ) || !empty( $attr['height'] );
830
+ if ( $validSize && !in_array( $name, $ignore ) ) {
831
+ $active_sizes[$name] = $attr;
832
+ }
833
+ }
834
+ return $active_sizes;
835
+ }
836
+
837
+ function is_wpml_installed() {
838
+ return function_exists( 'icl_object_id' ) && !class_exists( 'Polylang' );
839
+ }
840
+
841
+ // SQL Query if WPML with an AND to check if the p.ID (p is attachment) is indeed an original
842
+ // That is to limit the SQL that queries all the attachments
843
+ function create_sql_if_wpml_original() {
844
+ $whereIsOriginal = "";
845
+ if ( $this->is_wpml_installed() ) {
846
+ global $wpdb;
847
+ global $sitepress;
848
+ $tbl_wpml = $wpdb->prefix . "icl_translations";
849
+ $language = $sitepress->get_default_language();
850
+ $whereIsOriginal = " AND p.ID IN (SELECT element_id FROM $tbl_wpml WHERE element_type = 'post_attachment' AND language_code = '$language') ";
851
+ }
852
+ return $whereIsOriginal;
853
+ }
854
+
855
+ function is_debug() {
856
+ static $debug = -1;
857
+ if ( $debug == -1 ) {
858
+ $debug = get_option( "wr2x_debug" );
859
+ }
860
+ return !!$debug;
861
+ }
862
+
863
+ function log( $data, $isExtra = false ) {
864
+ if ( !$this->is_debug() )
865
+ return;
866
+ $fh = fopen( trailingslashit( dirname(__FILE__) ) . 'wp-retina-2x.log', 'a' );
867
+ $date = date( "Y-m-d H:i:s" );
868
+ fwrite( $fh, "$date: {$data}\n" );
869
+ fclose( $fh );
870
+ }
871
+
872
+ // Based on http://wordpress.stackexchange.com/questions/6645/turn-a-url-into-an-attachment-post-id
873
+ function get_attachment_id( $file ) {
874
+ $query = array(
875
+ 'post_type' => 'attachment',
876
+ 'meta_query' => array(
877
+ array(
878
+ 'key' => '_wp_attached_file',
879
+ 'value' => ltrim( $file, '/' )
880
+ )
881
+ )
882
+ );
883
+ $posts = get_posts( $query );
884
+ foreach( $posts as $post )
885
+ return $post->ID;
886
+ return false;
887
+ }
888
+
889
+ // Return the retina extension followed by a dot
890
+ function retina_extension() {
891
+ return '@2x.';
892
+ }
893
+
894
+ function is_image_meta( $meta ) {
895
+ if ( !isset( $meta ) )
896
+ return false;
897
+ if ( !isset( $meta['sizes'] ) )
898
+ return false;
899
+ if ( !isset( $meta['width'], $meta['height'] ) )
900
+ return false;
901
+ return true;
902
+ }
903
+
904
+ function retina_info( $id ) {
905
+ $result = array();
906
+ $meta = wp_get_attachment_metadata( $id );
907
+ if ( !$this->is_image_meta( $meta ) )
908
+ return $result;
909
+ $original_width = $meta['width'];
910
+ $original_height = $meta['height'];
911
+ $sizes = $this->get_image_sizes();
912
+ $required_files = true;
913
+ $originalfile = get_attached_file( $id );
914
+ $pathinfo = pathinfo( $originalfile );
915
+ $basepath = $pathinfo['dirname'];
916
+ $ignore = get_option( "wr2x_ignore_sizes", array() );
917
+ if ( empty( $ignore ) )
918
+ $ignore = array();
919
+ $ignore = array_keys( $ignore );
920
+
921
+ // Full-Size (if required in the settings)
922
+ $fullsize_required = get_option( "wr2x_full_size" ) && $this->admin->is_registered();
923
+ $retina_file = trailingslashit( $pathinfo['dirname'] ) . $pathinfo['filename'] . $this->retina_extension() . $pathinfo['extension'];
924
+ if ( $retina_file && file_exists( $retina_file ) )
925
+ $result['full-size'] = 'EXISTS';
926
+ else if ( $fullsize_required && $retina_file )
927
+ $result['full-size'] = array( 'width' => $original_width * 2, 'height' => $original_height * 2 );
928
+ //}
929
+
930
+ if ( $sizes ) {
931
+ foreach ( $sizes as $name => $attr ) {
932
+ $validSize = !empty( $attr['width'] ) || !empty( $attr['height'] );
933
+ if ( !$validSize || in_array( $name, $ignore ) ) {
934
+ $result[$name] = 'IGNORED';
935
+ continue;
936
+ }
937
+ // Check if the file related to this size is present
938
+ $pathinfo = null;
939
+ $retina_file = null;
940
+
941
+ if ( isset( $meta['sizes'][$name]['width'] ) && isset( $meta['sizes'][$name]['height']) && isset($meta['sizes'][$name]) && isset($meta['sizes'][$name]['file']) && file_exists( trailingslashit( $basepath ) . $meta['sizes'][$name]['file'] ) ) {
942
+ $normal_file = trailingslashit( $basepath ) . $meta['sizes'][$name]['file'];
943
+ $pathinfo = pathinfo( $normal_file ) ;
944
+ $retina_file = trailingslashit( $pathinfo['dirname'] ) . $pathinfo['filename'] . $this->retina_extension() . $pathinfo['extension'];
945
+ }
946
+ // None of the file exist
947
+ else {
948
+ $result[$name] = 'MISSING';
949
+ $required_files = false;
950
+ continue;
951
+ }
952
+
953
+ // The retina file exists
954
+ if ( $retina_file && file_exists( $retina_file ) ) {
955
+ $result[$name] = 'EXISTS';
956
+ continue;
957
+ }
958
+ // The size file exists
959
+ else if ( $retina_file )
960
+ $result[$name] = 'PENDING';
961
+
962
+ // The retina file exists
963
+ $required_width = $meta['sizes'][$name]['width'] * 2;
964
+ $required_height = $meta['sizes'][$name]['height'] * 2;
965
+ if ( !$this->are_dimensions_ok( $original_width, $original_height, $required_width, $required_height ) ) {
966
+ $result[$name] = array( 'width' => $required_width, 'height' => $required_height );
967
+ }
968
+ }
969
+ }
970
+ return $result;
971
+ }
972
+
973
+ function delete_attachment( $attach_id, $deleteFullSize = true ) {
974
+ $meta = wp_get_attachment_metadata( $attach_id );
975
+ $this->delete_images( $meta, $deleteFullSize );
976
+ $this->remove_issue( $attach_id );
977
+ }
978
+
979
+ function wp_generate_attachment_metadata( $meta ) {
980
+ if ( get_option( "wr2x_auto_generate" ) == true )
981
+ if ( $this->is_image_meta( $meta ) )
982
+ $this->generate_images( $meta );
983
+ return $meta;
984
+ }
985
+
986
+ function generate_images( $meta ) {
987
+ global $_wp_additional_image_sizes;
988
+ $sizes = $this->get_image_sizes();
989
+ if ( !isset( $meta['file'] ) )
990
+ return;
991
+ $originalfile = $meta['file'];
992
+ $uploads = wp_upload_dir();
993
+ $pathinfo = pathinfo( $originalfile );
994
+ $original_basename = $pathinfo['basename'];
995
+ $basepath = trailingslashit( $uploads['basedir'] ) . $pathinfo['dirname'];
996
+ $ignore = get_option( "wr2x_ignore_sizes" );
997
+ if ( empty( $ignore ) )
998
+ $ignore = array();
999
+ $ignore = array_keys( $ignore );
1000
+ $issue = false;
1001
+ $id = $this->get_attachment_id( $meta['file'] );
1002
+
1003
+ $this->log("* GENERATE RETINA FOR ATTACHMENT '{$meta['file']}'");
1004
+ $this->log( "Full-Size is {$original_basename}." );
1005
+
1006
+ foreach ( $sizes as $name => $attr ) {
1007
+ $normal_file = "";
1008
+ if ( in_array( $name, $ignore ) ) {
1009
+ $this->log( "Retina for {$name} ignored (settings)." );
1010
+ continue;
1011
+ }
1012
+ // Is the file related to this size there?
1013
+ $pathinfo = null;
1014
+ $retina_file = null;
1015
+
1016
+ if ( isset( $meta['sizes'][$name] ) && isset( $meta['sizes'][$name]['file'] ) ) {
1017
+ $normal_file = trailingslashit( $basepath ) . $meta['sizes'][$name]['file'];
1018
+ $pathinfo = pathinfo( $normal_file ) ;
1019
+ $retina_file = trailingslashit( $pathinfo['dirname'] ) . $pathinfo['filename'] . $this->retina_extension() . $pathinfo['extension'];
1020
+ }
1021
+
1022
+ if ( $retina_file && file_exists( $retina_file ) ) {
1023
+ $this->log( "Base for {$name} is '{$normal_file }'." );
1024
+ $this->log( "Retina for {$name} already exists: '$retina_file'." );
1025
+ continue;
1026
+ }
1027
+ if ( $retina_file ) {
1028
+ $originalfile = trailingslashit( $pathinfo['dirname'] ) . $original_basename;
1029
+
1030
+ if ( !file_exists( $originalfile ) ) {
1031
+ $this->log( "[ERROR] Original file '{$originalfile}' cannot be found." );
1032
+ return $meta;
1033
+ }
1034
+
1035
+ // Maybe that new image is exactly the size of the original image.
1036
+ // In that case, let's make a copy of it.
1037
+ if ( $meta['sizes'][$name]['width'] * 2 == $meta['width'] && $meta['sizes'][$name]['height'] * 2 == $meta['height'] ) {
1038
+ copy ( $originalfile, $retina_file );
1039
+ $this->log( "Retina for {$name} created: '{$retina_file}' (as a copy of the full-size)." );
1040
+ }
1041
+ // Otherwise let's resize (if the original size is big enough).
1042
+ else if ( $this->are_dimensions_ok( $meta['width'], $meta['height'], $meta['sizes'][$name]['width'] * 2, $meta['sizes'][$name]['height'] * 2 ) ) {
1043
+ // Change proposed by Nicscott01, slighlty modified by Jordy (+isset)
1044
+ // (https://wordpress.org/support/topic/issue-with-crop-position?replies=4#post-6200271)
1045
+ $crop = isset( $_wp_additional_image_sizes[$name] ) ? $_wp_additional_image_sizes[$name]['crop'] : true;
1046
+ $customCrop = null;
1047
+
1048
+ // Support for Manual Image Crop
1049
+ // If the size of the image was manually cropped, let's keep it.
1050
+ if ( class_exists( 'ManualImageCrop' ) && isset( $meta['micSelectedArea'] ) && isset( $meta['micSelectedArea'][$name] ) && isset( $meta['micSelectedArea'][$name]['scale'] ) ) {
1051
+ $customCrop = $meta['micSelectedArea'][$name];
1052
+ }
1053
+ $image = $this->resize( $originalfile, $meta['sizes'][$name]['width'] * 2,
1054
+ $meta['sizes'][$name]['height'] * 2, $crop, $retina_file, $customCrop );
1055
+ }
1056
+ if ( !file_exists( $retina_file ) ) {
1057
+ $is_ok = apply_filters( "wr2x_last_chance_generate", false, $id, $retina_file,
1058
+ $meta['sizes'][$name]['width'] * 2, $meta['sizes'][$name]['height'] * 2 );
1059
+ if ( !$is_ok ) {
1060
+ $this->log( "[ERROR] Retina for {$name} could not be created. Full-Size is " . $meta['width'] . "x" . $meta['height'] . " but Retina requires a file of at least " . $meta['sizes'][$name]['width'] * 2 . "x" . $meta['sizes'][$name]['height'] * 2 . "." );
1061
+ $issue = true;
1062
+ }
1063
+ }
1064
+ else {
1065
+ do_action( 'wr2x_retina_file_added', $id, $retina_file, $name );
1066
+ $this->log( "Retina for {$name} created: '{$retina_file}'." );
1067
+ }
1068
+ } else {
1069
+ if ( empty( $normal_file ) )
1070
+ $this->log( "[ERROR] Base file for '{$name}' does not exist." );
1071
+ else
1072
+ $this->log( "[ERROR] Base file for '{$name}' cannot be found here: '{$normal_file}'." );
1073
+ }
1074
+ }
1075
+
1076
+ // Checks attachment ID + issues
1077
+ if ( !$id )
1078
+ return $meta;
1079
+ if ( $issue )
1080
+ $this->add_issue( $id );
1081
+ else
1082
+ $this->remove_issue( $id );
1083
+ return $meta;
1084
+ }
1085
+
1086
+ function delete_images( $meta, $deleteFullSize = false ) {
1087
+ if ( !$this->is_image_meta( $meta ) )
1088
+ return $meta;
1089
+ $sizes = $meta['sizes'];
1090
+ if ( !$sizes || !is_array( $sizes ) )
1091
+ return $meta;
1092
+ $this->log("* DELETE RETINA FOR ATTACHMENT '{$meta['file']}'");
1093
+ $originalfile = $meta['file'];
1094
+ $id = $this->get_attachment_id( $originalfile );
1095
+ $pathinfo = pathinfo( $originalfile );
1096
+ $uploads = wp_upload_dir();
1097
+ $basepath = trailingslashit( $uploads['basedir'] ) . $pathinfo['dirname'];
1098
+ foreach ( $sizes as $name => $attr ) {
1099
+ $pathinfo = pathinfo( $attr['file'] );
1100
+ $retina_file = $pathinfo['filename'] . $this->retina_extension() . $pathinfo['extension'];
1101
+ if ( file_exists( trailingslashit( $basepath ) . $retina_file ) ) {
1102
+ $fullpath = trailingslashit( $basepath ) . $retina_file;
1103
+ unlink( $fullpath );
1104
+ do_action( 'wr2x_retina_file_removed', $id, $retina_file );
1105
+ $this->log("Deleted '$fullpath'.");
1106
+ }
1107
+ }
1108
+ // Remove full-size if there is any
1109
+ if ( $deleteFullSize ) {
1110
+ $pathinfo = pathinfo( $originalfile );
1111
+ $retina_file = $pathinfo[ 'filename' ] . $this->retina_extension() . $pathinfo[ 'extension' ];
1112
+ if ( file_exists( trailingslashit( $basepath ) . $retina_file ) ) {
1113
+ $fullpath = trailingslashit( $basepath ) . $retina_file;
1114
+ unlink( $fullpath );
1115
+ do_action( 'wr2x_retina_file_removed', $id, $retina_file );
1116
+ $this->log( "Deleted '$fullpath'." );
1117
+ }
1118
+ }
1119
+ return $meta;
1120
+ }
1121
+
1122
+ /**
1123
+ *
1124
+ * FILTERS
1125
+ *
1126
+ */
1127
+
1128
+ function validate_src( $src ) {
1129
+ if ( preg_match( "/^data:/i", $src ) )
1130
+ return null;
1131
+ return $src;
1132
+ }
1133
+
1134
+ /**
1135
+ *
1136
+ * LOAD SCRIPTS IF REQUIRED
1137
+ *
1138
+ */
1139
+
1140
+ function wp_enqueue_scripts () {
1141
+ global $wr2x_version, $wr2x_retinajs, $wr2x_retina_image, $wr2x_picturefill, $wr2x_lazysizes;
1142
+ $method = get_option( "wr2x_method" );
1143
+
1144
+ if ( is_admin() && !get_option( "wr2x_retina_admin" ) ) {
1145
+ wp_enqueue_script( 'wr2x-admin', plugins_url( '/js/admin.js', __FILE__ ), array(), $wr2x_version, false );
1146
+
1147
+ $nonce = array (
1148
+ 'wr2x_generate' => null,
1149
+ 'wr2x_delete' => null,
1150
+ 'wr2x_delete_full' => null,
1151
+ 'wr2x_list_all' => null,
1152
+ 'wr2x_replace' => null,
1153
+ 'wr2x_upload' => null,
1154
+ 'wr2x_retina_details' => null
1155
+ );
1156
+ foreach ( array_keys( $nonce ) as $action )
1157
+ $nonce[$action] = wp_create_nonce( $action );
1158
+
1159
+ wp_localize_script( 'wr2x-admin', 'wr2x_admin_server', array (
1160
+ 'maxFileSize' => $this->get_max_filesize(),
1161
+ 'nonce' => $nonce,
1162
+ 'i18n' => array (
1163
+ 'Refresh' => __( "<a href='?page=wp-retina-2x&view=issues&refresh=true'>Refresh</a> this page.", 'wp-retina-2x' ),
1164
+ 'Wait' => __( "Wait...", 'wp-retina-2x' ),
1165
+ 'Nothing_to_do' => __( "Nothing to do ;)", 'wp-retina-2x' ),
1166
+ 'Generate' => __( "GENERATE", 'wp-retina-2x' )
1167
+ )
1168
+ ) );
1169
+ }
1170
+
1171
+ // Picturefill
1172
+ if ( $method == "Picturefill" ) {
1173
+ if ( $this->is_debug() )
1174
+ wp_enqueue_script( 'wr2x-debug', plugins_url( '/js/debug.js', __FILE__ ), array(), $wr2x_version, false );
1175
+ // Picturefill
1176
+ if ( !get_option( "wr2x_picturefill_noscript" ) )
1177
+ wp_enqueue_script( 'picturefill', plugins_url( '/js/picturefill.min.js', __FILE__ ), array(), $wr2x_picturefill, false );
1178
+ // Lazysizes
1179
+ if ( get_option( "wr2x_picturefill_lazysizes" ) && $this->admin->is_registered() )
1180
+ wp_enqueue_script( 'lazysizes', plugins_url( '/js/lazysizes.min.js', __FILE__ ), array(), $wr2x_lazysizes, false );
1181
+ return;
1182
+ }
1183
+
1184
+ // Debug + HTML Rewrite = No JS!
1185
+ if ( $this->is_debug() && $method == "HTML Rewrite" ) {
1186
+ return;
1187
+ }
1188
+
1189
+ // Debug mode, we force the devicePixelRatio to be Retina
1190
+ if ( $this->is_debug() )
1191
+ wp_enqueue_script( 'wr2x-debug', plugins_url( '/js/debug.js', __FILE__ ), array(), $wr2x_version, false );
1192
+
1193
+ // Retina-Images and HTML Rewrite both need the devicePixelRatio cookie on the server-side
1194
+ if ( $method == "Retina-Images" || $method == "HTML Rewrite" )
1195
+ wp_enqueue_script( 'retina-images', plugins_url( '/js/retina-cookie.js', __FILE__ ), array(), $wr2x_retina_image, false );
1196
+
1197
+ // Retina.js only needs itself
1198
+ if ($method == "retina.js")
1199
+ wp_enqueue_script( 'retinajs', plugins_url( '/js/retina.min.js', __FILE__ ), array(), $wr2x_retinajs, true );
1200
+ }
1201
+
1202
+ }
1203
+
1204
+ // Used by WP Rocket (and maybe by other plugins)
1205
+ function wr2x_is_registered() {
1206
+ global $wr2x_core;
1207
+ return $wr2x_core->admin->is_registered();
1208
+ }
1209
+
1210
+ ?>
trunk/dashboard.php ADDED
@@ -0,0 +1,334 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Meow_WR2X_Dashboard {
4
+
5
+ public $core = null;
6
+
7
+ public function __construct( $core ) {
8
+ $this->core = $core;
9
+ add_action( 'admin_menu', array( $this, 'admin_menu_dashboard' ) );
10
+ }
11
+
12
+ function admin_menu_dashboard () {
13
+ $flagged = count( $this->core->get_issues() );
14
+ $warning_title = __( "Retina images", 'wp-retina-2x' );
15
+ $menu_label = sprintf( __( 'Retina %s' ), "<span class='update-plugins count-$flagged' title='$warning_title'><span class='update-count'>" . number_format_i18n( $flagged ) . "</span></span>" );
16
+ add_media_page( 'Retina', $menu_label, 'manage_options', 'wp-retina-2x', array( $this, 'dashboard' ) );
17
+ }
18
+
19
+ function dashboard() {
20
+ $refresh = isset ( $_GET[ 'refresh' ] ) ? sanitize_text_field( $_GET[ 'refresh' ] ) : 0;
21
+ $clearlogs = isset ( $_GET[ 'clearlogs' ] ) ? sanitize_text_field( $_GET[ 'clearlogs' ] ) : 0;
22
+ $ignore = isset ( $_GET[ 'ignore' ] ) ? sanitize_text_field( $_GET[ 'ignore' ] ) : false;
23
+ if ( $ignore ) {
24
+ if ( !$this->core->admin->is_registered() ) {
25
+ echo "<div class='error' style='margin-top: 20px;'><p>";
26
+ _e( "Ignore is a Pro feature.", 'wp-retina-2x' );
27
+ echo "</p></div>";
28
+ }
29
+ else
30
+ $this->core->add_ignore( $ignore );
31
+ }
32
+ if ( $refresh ) {
33
+ $this->core->calculate_issues();
34
+ }
35
+ if ( $clearlogs ) {
36
+ if ( file_exists( plugin_dir_path( __FILE__ ) . '/wp-retina-2x.log' ) ) {
37
+ unlink( plugin_dir_path( __FILE__ ) . '/wp-retina-2x.log' );
38
+ }
39
+ }
40
+
41
+ $hide_ads = get_option( 'meowapps_hide_ads', false );
42
+ $view = isset( $_GET[ 'view' ] ) ? sanitize_text_field( $_GET[ 'view' ] ) : 'issues';
43
+ $paged = isset( $_GET[ 'paged' ] ) ? sanitize_text_field( $_GET[ 'paged' ] ) : 1;
44
+ $s = isset( $_GET[ 's' ] ) && !empty( $_GET[ 's' ] ) ? sanitize_text_field( $_GET[ 's' ] ) : null;
45
+ $issues = $count = 0;
46
+
47
+ $posts_per_page = get_user_meta( get_current_user_id(), 'upload_per_page', true );
48
+ if ( empty( $posts_per_page ) )
49
+ $posts_per_page = 20;
50
+ $issues = $this->core->get_issues();
51
+ $ignored = $this->core->get_ignores();
52
+
53
+ echo '<div class="wrap">';
54
+ echo $this->core->admin->display_title( "WP Retina 2x" );
55
+ echo '<p></p>';
56
+
57
+ if ( $this->core->admin->is_registered() && $view == 'issues' ) {
58
+ global $wpdb;
59
+ $totalcount = $wpdb->get_var( $wpdb->prepare( "
60
+ SELECT COUNT(*)
61
+ FROM $wpdb->posts p
62
+ WHERE post_status = 'inherit'
63
+ AND post_type = 'attachment'" . $this->core->create_sql_if_wpml_original() . "
64
+ AND post_title LIKE %s
65
+ AND ( post_mime_type = 'image/jpeg' OR
66
+ post_mime_type = 'image/png' OR
67
+ post_mime_type = 'image/gif' )
68
+ ", '%' . $s . '%' ) );
69
+ $postin = count( $issues ) < 1 ? array( -1 ) : $issues;
70
+ $query = new WP_Query(
71
+ array(
72
+ 'post_status' => 'inherit',
73
+ 'post_type' => 'attachment',
74
+ 'post__in' => $postin,
75
+ 'paged' => $paged,
76
+ 'posts_per_page' => $posts_per_page,
77
+ 's' => $s
78
+ )
79
+ );
80
+ }
81
+ else if ( $this->core->admin->is_registered() && $view == 'ignored' ) {
82
+ global $wpdb;
83
+ $totalcount = $wpdb->get_var( $wpdb->prepare( "
84
+ SELECT COUNT(*)
85
+ FROM $wpdb->posts p
86
+ WHERE post_status = 'inherit'
87
+ AND post_type = 'attachment'" . $this->core->create_sql_if_wpml_original() . "
88
+ AND post_title LIKE %s
89
+ AND ( post_mime_type = 'image/jpeg' OR
90
+ post_mime_type = 'image/jpg' OR
91
+ post_mime_type = 'image/png' OR
92
+ post_mime_type = 'image/gif' )
93
+ ", '%' . $s . '%' ) );
94
+ $postin = count( $ignored ) < 1 ? array( -1 ) : $ignored;
95
+ $query = new WP_Query(
96
+ array(
97
+ 'post_status' => 'inherit',
98
+ 'post_type' => 'attachment',
99
+ 'post__in' => $postin,
100
+ 'paged' => $paged,
101
+ 'posts_per_page' => $posts_per_page,
102
+ 's' => $s
103
+ )
104
+ );
105
+ }
106
+ else {
107
+ $query = new WP_Query(
108
+ array(
109
+ 'post_status' => 'inherit',
110
+ 'post_type' => 'attachment',
111
+ 'post_mime_type' => 'image/jpeg,image/gif,image/jpg,image/png',
112
+ 'paged' => $paged,
113
+ 'posts_per_page' => $posts_per_page,
114
+ 's' => $s
115
+ )
116
+ );
117
+
118
+ //$s
119
+ $totalcount = $query->found_posts;
120
+ }
121
+
122
+ $issues_count = count( $issues );
123
+
124
+ // If 'search', then we need to clean-up the issues count
125
+ if ( $s && $issues_count > 0 ) {
126
+ global $wpdb;
127
+ $issues_count = $wpdb->get_var( $wpdb->prepare( "
128
+ SELECT COUNT(*)
129
+ FROM $wpdb->posts p
130
+ WHERE id IN ( " . implode( ',', $issues ) . " )" . $this->core->create_sql_if_wpml_original() . "
131
+ AND post_title LIKE %s
132
+ ", '%' . $s . '%' ) );
133
+ }
134
+
135
+ $results = array();
136
+ $count = $query->found_posts;
137
+ $pagescount = $query->max_num_pages;
138
+ foreach ( $query->posts as $post ) {
139
+ $info = $this->core->retina_info( $post->ID );
140
+ array_push( $results, array( 'post' => $post, 'info' => $info ) );
141
+ }
142
+ ?>
143
+
144
+ <div style='background: #FFF; padding: 5px; border-radius: 4px; height: 28px; box-shadow: 0px 0px 6px #C2C2C2;'>
145
+
146
+ <!-- REFRESH -->
147
+ <a id='wr2x_refresh' href='?page=wp-retina-2x&view=issues&refresh=true' class='button' style='float: left;'><span style="top: 3px; position: relative; left: -5px;" class="dashicons dashicons-controls-repeat"></span><?php _e("Refresh", 'wp-retina-2x'); ?></a>
148
+
149
+ <!-- SEARCH -->
150
+ <form id="posts-filter" action="upload.php" method="get">
151
+ <p class="search-box" style='margin-left: 5px; float: left;'>
152
+ <input type="search" name="s" value="<?php echo $s ? $s : ""; ?>">
153
+ <input type="hidden" name="page" value="wp-retina-2x">
154
+ <input type="hidden" name="view" value="<?php echo $view; ?>">
155
+ <input type="hidden" name="paged" value="<?php echo $paged; ?>">
156
+ <input type="submit" class="button" value="Search">
157
+ </p>
158
+ </form>
159
+
160
+ <!-- REMOVE BUTTON ALL -->
161
+ <a id='wr2x_remove_button_all' onclick='wr2x_delete_all()' class='button button-red' style='float: right;'><span style="top: 3px; position: relative; left: -5px;" class="dashicons dashicons-trash"></span><?php _e("Bulk Delete (Retina Only)", 'wp-retina-2x'); ?></a>
162
+
163
+ <!-- GENERATE ALL -->
164
+ <a id='wr2x_generate_button_all' onclick='wr2x_generate_all()' class='button-primary' style='float: right; margin-right: 5px;'><span style="top: 3px; position: relative; left: -5px;" class="dashicons dashicons-controls-play"></span><?php _e("Bulk Generate (Thumbnails & Retina)", 'wp-retina-2x'); ?></a>
165
+
166
+
167
+ <!-- PROGRESS -->
168
+ <span style='margin-left: 12px; font-size: 13px; top: 5px; position: relative; color: #24547C; font-weight: bold;' id='wr2x_progression'></span>
169
+
170
+ </div>
171
+
172
+ <?php
173
+ if (isset ( $_GET[ 'clearlogs' ] ) ? $_GET[ 'clearlogs' ] : 0) {
174
+ echo "<div class='updated' style='margin-top: 20px;'><p>";
175
+ _e( "The logs have been cleared.", 'wp-retina-2x' );
176
+ echo "</p></div>";
177
+ }
178
+
179
+ $active_sizes = $this->core->get_active_image_sizes();
180
+ $full_size_needed = get_option( "wr2x_full_size" );
181
+
182
+ $max_width = 0;
183
+ $max_height = 0;
184
+ foreach ( $active_sizes as $name => $active_size ) {
185
+ if ( $active_size['height'] != 9999 && $active_size['height'] > $max_height ) {
186
+ $max_height = $active_size['height'];
187
+ }
188
+ if ( $active_size['width'] != 9999 && $active_size['width'] > $max_width ) {
189
+ $max_width = $active_size['width'];
190
+ }
191
+ }
192
+ $max_width = $max_width * 2;
193
+ $max_height = $max_height * 2;
194
+
195
+ $upload_max_size = $this->core->get_max_filesize();
196
+ ?>
197
+
198
+ <p>
199
+ <?php printf( __( 'Based on your <i>image sizes</i> settings, the full-size images should be uploaded at a resolution of at least <b>%d×%d</b> for the plugin to be able generate the <b>%d retina images</b>. Please note that it vares depending on your needs for each image (you will need to discuss this with your developer).', 'wp-retina-2x' ), $max_width, $max_height, count( $active_sizes ) ); ?>
200
+ <?php if ( $full_size_needed ) printf( __( "You <b>also need</b> to upload a retina image for the Full-Size image (might be <b>%d×%d</b>).", 'wp-retina-2x' ), $max_width * 2, $max_height * 2 ); ?>
201
+ <?php _e("You can upload or replace the images by drag & drop.", 'wp-retina-2x' ); ?>
202
+ <?php printf( __( "Your PHP configuration allows uploads of <b>%dMB</b> maximum.", 'wp-retina-2x'), $upload_max_size / 1000000 ); ?>
203
+
204
+ <?php
205
+ if ( file_exists( plugin_dir_path( __FILE__ ) . '/wp-retina-2x.log' ) ) {
206
+ printf( __( 'The <a target="_blank" href="%s/wp-retina-2x.log">log file</a> is available. You can also <a href="?page=wp-retina-2x&view=issues&clearlogs=true">clear</a> it.', 'wp-retina-2x' ), plugin_dir_url( __FILE__ ) );
207
+ }
208
+ ?>
209
+ </p>
210
+
211
+ <?php
212
+ $method = get_option( 'wr2x_method' );
213
+ $cdn = get_option( 'wr2x_cdn_domain' );
214
+ $disable_responsive = get_option( 'wr2x_disable_responsive', false );
215
+ $keep_src = get_option( 'wr2x_picturefill_keep_src', false );
216
+
217
+ if ( $method == 'HTML Rewrite' || $method == 'Retina-Images' || !empty( $cdn ) || $disable_responsive || $keep_src ) {
218
+ echo '<div class="error"><p>';
219
+ echo __( '<b>WARNING</b>. You are using an option that will be removed in a future release. The plan is to remove two methods (HTML Rewrite and Retina-Images), Disable Responsive, Custom CDN Domain, and Keep IMG SRC. Those options are not necessary, and it is better to keep the plugin clean and focus. This warning message will go away if you avoid using those options (and will disappear in a future release). If you are using one of those options and really would like to keep it, please come here to talk about it: <a target= "_blank" href="https://wordpress.org/support/topic/simplifying-wp-retina-2x-by-removing-options/">Discussions about removing options from WP Retina 2x</a>. Thanks :)', 'wp-retina-2x' );
220
+ echo '</p></div>';
221
+ }
222
+ ?>
223
+
224
+ <?php
225
+ if ( !$this->core->admin->is_registered() && !get_option( "wr2x_hide_pro", false ) ) {
226
+ echo '<div class="updated"><p>';
227
+ echo __( '<b>Only Pro users have access to the features of this dashboard.</b> As a standard user, the dashboard allow you to Bulk Generate, Bulk Delete and access the Retina Logs. If you wish to stay a standard user and never see this dashboard aver again, you can hide it in the settings.<br /><br />The Pro version of the plugin allows you to <b>replace directly an image already uploaded in the Media Library</b> by a simple drag & drop, upload a <b>retina image for a full-size image</b>, use <b>lazy-loading</b> to load your images (for better performance) and, more importantly, <b>supports the developer</b> :)<br /><br /><a class="button-primary" href="https://store.meowapps.com/wp-retina-2x/" target="_blank">Get WP Retina 2x Pro</a>', 'wp-retina-2x' );
228
+ echo '</p></div>';
229
+ }
230
+ ?>
231
+
232
+ <div id='wr2x-pages'>
233
+ <?php
234
+ echo paginate_links(array(
235
+ 'base' => '?page=wp-retina-2x&s=' . urlencode($s) . '&view=' . $view . '%_%',
236
+ 'current' => $paged,
237
+ 'format' => '&paged=%#%',
238
+ 'total' => $pagescount,
239
+ 'prev_next' => false
240
+ ));
241
+ ?>
242
+ </div>
243
+
244
+ <ul class="subsubsub">
245
+ <li class="all"><a <?php if ( $view == 'all' ) echo "class='current'"; ?> href='?page=wp-retina-2x&s=<?php echo $s; ?>&view=all'><?php _e( "All", 'wp-retina-2x' ); ?></a><span class="count">(<?php echo $totalcount; ?>)</span></li> |
246
+
247
+ <?php if ( $this->core->admin->is_registered() ): ?>
248
+
249
+ <li class="all"><a <?php if ( $view == 'issues' ) echo "class='current'"; ?> href='?page=wp-retina-2x&s=<?php echo $s; ?>&view=issues'><?php _e( "Issues", 'wp-retina-2x' ); ?></a><span class="count">(<?php echo $issues_count; ?>)</span></li> |
250
+ <li class="all"><a <?php if ( $view == 'ignored' ) echo "class='current'"; ?> href='?page=wp-retina-2x&s=<?php echo $s; ?>&view=ignored'><?php _e( "Ignored", 'wp-retina-2x' ); ?></a><span class="count">(<?php echo count( $ignored ); ?>)</span></li>
251
+
252
+ <?php else: ?>
253
+
254
+ <li class="all"><span><?php _e( "Issues", 'wp-retina-2x' ); ?></span> <span class="count">(<?php echo $issues_count; ?>)</span></li> |
255
+ <li class="all"><span><?php _e( "Ignored", 'wp-retina-2x' ); ?></span> <span class="count">(<?php echo count( $ignored ); ?>)</span></li>
256
+
257
+ <?php endif; ?>
258
+
259
+
260
+ </ul>
261
+ <table class='wp-list-table widefat fixed media wr2x-table'>
262
+ <thead><tr>
263
+ <?php
264
+ echo "<th style='width: 56px;'>Thumbnail</th>";
265
+ echo "<th style=' width: 360px;'>" . __( "Base image", 'wp-retina-2x' ) . "</th>";
266
+ echo "<th style=''>" . __( "Media Sizes<br />Retina-ized", 'wp-retina-2x' ) . "</th>";
267
+ echo "<th style=''>" . __( "Full-Size<br/><b>Replace</b>", 'wp-retina-2x' ) . "</th>";
268
+ echo "<th style=''>" . __( "Full-Size Retina", 'wp-retina-2x' ) . "</th>";
269
+ echo "<th style=''>" . __( "Full-Size Retina<br/><b>Upload</b>", 'wp-retina-2x' ) . "</th>";
270
+ ?>
271
+ </tr></thead>
272
+ <tbody>
273
+ <?php
274
+ foreach ($results as $index => $attr) {
275
+ $post = $attr['post'];
276
+ $info = $attr['info'];
277
+ $meta = wp_get_attachment_metadata( $post->ID );
278
+ // Let's clean the issues status
279
+ if ( $view != 'issues' ) {
280
+ $this->core->update_issue_status( $post->ID, $issues, $info );
281
+ }
282
+ $original_width = ( isset( $meta ) && isset( $meta['width'] ) ) ? $meta['width'] : null;
283
+ $original_height = ( isset( $meta ) && isset( $meta['height'] ) ) ? $meta['height'] : null;
284
+
285
+ $attachmentsrc = wp_get_attachment_image_src( $post->ID, 'thumbnail' );
286
+ echo "<tr class='wr2x-file-row' postId='" . $post->ID . "'>";
287
+
288
+ if ( !$original_width || !$original_height ) {
289
+ echo "<td colspan='2' style='padding: 15px;'>The metadata for the <a href='media.php?attachment_id={$post->ID}&action=edit'>Media #{$post->ID}</a> is broken. You can try <b>Generate</b> for this media (in the Media Library), <b>Bulk Generate</b>, or a <b>Full-Size Replace</b>.</td>";
290
+ }
291
+ else {
292
+ echo "<td class='wr2x-image wr2x-info-thumbnail'><img src='" . $attachmentsrc[0] . "' /></td>";
293
+ echo "<td class='wr2x-title'><a href='media.php?attachment_id=" . $post->ID . "&action=edit'>" . ( $post->post_title ? $post->post_title : '<i>Untitled</i>' ) . '</a><br />' .
294
+ "<span class='resolution'>Full-Size: <span class='" . ( $original_width < $max_width ? "red" : "" ) . "'>" . $original_width . "</span>×<span class='" . ( $original_height < $max_height ? "red" : "" ) . "'>" . $original_height . "</span></span>";
295
+ echo "<div class='actions'>";
296
+ echo "<a style='position: relative;' onclick='wr2x_generate(" . $post->ID . ", true)' id='wr2x_generate_button_" . $post->ID . "' class='wr2x-button'>" . __( "GENERATE", 'wp-retina-2x' ) . "</a>";
297
+ if ( !$this->core->is_ignore( $post->ID ) )
298
+ echo " <a href='?page=wp-retina-2x&view=" . $view . "&paged=" . $paged . "&ignore=" . $post->ID . "' id='wr2x_generate_button_" . $post->ID . "' class='wr2x-button wr2x-button-ignore'>" . __( "IGNORE", 'wp-retina-2x' ) . "</a>";
299
+ echo " <a style='position: relative;' class='wr2x-button wr2x-button-view'>" . __( "DETAILS", 'wp-retina-2x' ) . "</a>";
300
+ echo "</div></td>";
301
+ }
302
+
303
+ // Media Sizes Retina-ized
304
+ echo '<td id="wr2x-info-' . $post->ID . '" style="padding-top: 10px;" class="wr2x-info">';
305
+ if ( $original_width && $original_height )
306
+ echo $this->core->html_get_basic_retina_info( $post, $info );
307
+ echo "</td>";
308
+
309
+ if ( $this->core->admin->is_registered() ) {
310
+ // Full-Size Replace
311
+ echo "<td class='wr2x-fullsize-replace'><div class='wr2x-dragdrop'></div>";
312
+ echo "</td>";
313
+ // Full-Size Retina
314
+ echo '<td id="wr2x-info-full-' . $post->ID . '" class="wr2x-image wr2x-info-full">';
315
+ echo $this->core->html_get_basic_retina_info_full( $post->ID, $info );
316
+ echo "</td>";
317
+ // Full-Size Retina Upload
318
+ echo "<td class='wr2x-fullsize-retina-upload'>";
319
+ echo "<div class='wr2x-dragdrop'></div>";
320
+ echo "</td>";
321
+ }
322
+ else
323
+ echo "<td colspan='3' style='text-align: center; background: #F9F9F9;'><small><br />PRO VERSION ONLY</small></td>";
324
+ echo "</tr>";
325
+ }
326
+ ?>
327
+ </tbody>
328
+ </table>
329
+ </div>
330
+
331
+ <?php
332
+ }
333
+ }
334
+ ?>
trunk/inc/simple_html_dom.php ADDED
@@ -0,0 +1,1742 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Website: http://sourceforge.net/projects/simplehtmldom/
4
+ * Additional projects that may be used: http://sourceforge.net/projects/debugobject/
5
+ * Acknowledge: Jose Solorzano (https://sourceforge.net/projects/php-html/)
6
+ * Contributions by:
7
+ * Yousuke Kumakura (Attribute filters)
8
+ * Vadim Voituk (Negative indexes supports of "find" method)
9
+ * Antcs (Constructor with automatically load contents either text or file/url)
10
+ *
11
+ * all affected sections have comments starting with "PaperG"
12
+ *
13
+ * Paperg - Added case insensitive testing of the value of the selector.
14
+ * Paperg - Added tag_start for the starting index of tags - NOTE: This works but not accurately.
15
+ * This tag_start gets counted AFTER \r\n have been crushed out, and after the remove_noice calls so it will not reflect the REAL position of the tag in the source,
16
+ * it will almost always be smaller by some amount.
17
+ * We use this to determine how far into the file the tag in question is. This "percentage will never be accurate as the $dom->size is the "real" number of bytes the dom was created from.
18
+ * but for most purposes, it's a really good estimation.
19
+ * Paperg - Added the forceTagsClosed to the dom constructor. Forcing tags closed is great for malformed html, but it CAN lead to parsing errors.
20
+ * Allow the user to tell us how much they trust the html.
21
+ * Paperg add the text and plaintext to the selectors for the find syntax. plaintext implies text in the innertext of a node. text implies that the tag is a text node.
22
+ * This allows for us to find tags based on the text they contain.
23
+ * Create find_ancestor_tag to see if a tag is - at any level - inside of another specific tag.
24
+ * Paperg: added parse_charset so that we know about the character set of the source document.
25
+ * NOTE: If the user's system has a routine called get_last_retrieve_url_contents_content_type availalbe, we will assume it's returning the content-type header from the
26
+ * last transfer or curl_exec, and we will parse that and use it in preference to any other method of charset detection.
27
+ *
28
+ * Found infinite loop in the case of broken html in restore_noise. Rewrote to protect from that.
29
+ * PaperG (John Schlick) Added get_display_size for "IMG" tags.
30
+ *
31
+ * Licensed under The MIT License
32
+ * Redistributions of files must retain the above copyright notice.
33
+ *
34
+ * @author S.C. Chen <me578022@gmail.com>
35
+ * @author John Schlick
36
+ * @author Rus Carroll
37
+ * @version 1.5 ($Rev: 210 $)
38
+ * @package PlaceLocalInclude
39
+ * @subpackage simple_html_dom
40
+ */
41
+
42
+ /**
43
+ * All of the Defines for the classes below.
44
+ * @author S.C. Chen <me578022@gmail.com>
45
+ */
46
+ define('HDOM_TYPE_ELEMENT', 1);
47
+ define('HDOM_TYPE_COMMENT', 2);
48
+ define('HDOM_TYPE_TEXT', 3);
49
+ define('HDOM_TYPE_ENDTAG', 4);
50
+ define('HDOM_TYPE_ROOT', 5);
51
+ define('HDOM_TYPE_UNKNOWN', 6);
52
+ define('HDOM_QUOTE_DOUBLE', 0);
53
+ define('HDOM_QUOTE_SINGLE', 1);
54
+ define('HDOM_QUOTE_NO', 3);
55
+ define('HDOM_INFO_BEGIN', 0);
56
+ define('HDOM_INFO_END', 1);
57
+ define('HDOM_INFO_QUOTE', 2);
58
+ define('HDOM_INFO_SPACE', 3);
59
+ define('HDOM_INFO_TEXT', 4);
60
+ define('HDOM_INFO_INNER', 5);
61
+ define('HDOM_INFO_OUTER', 6);
62
+ define('HDOM_INFO_ENDSPACE',7);
63
+ define('DEFAULT_TARGET_CHARSET', 'UTF-8');
64
+ define('DEFAULT_BR_TEXT', "\r\n");
65
+ define('DEFAULT_SPAN_TEXT', " ");
66
+ define('MAX_FILE_SIZE', 600000);
67
+ // helper functions
68
+ // -----------------------------------------------------------------------------
69
+ // get html dom from file
70
+ // $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1.
71
+ function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
72
+ {
73
+ // We DO force the tags to be terminated.
74
+ $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
75
+ // For sourceforge users: uncomment the next line and comment the retreive_url_contents line 2 lines down if it is not already done.
76
+ $contents = file_get_contents($url, $use_include_path, $context, $offset);
77
+ // Paperg - use our own mechanism for getting the contents as we want to control the timeout.
78
+ //$contents = retrieve_url_contents($url);
79
+ if (empty($contents) || strlen($contents) > MAX_FILE_SIZE)
80
+ {
81
+ return false;
82
+ }
83
+ // The second parameter can force the selectors to all be lowercase.
84
+ $dom->load($contents, $lowercase, $stripRN);
85
+ return $dom;
86
+ }
87
+
88
+ // get html dom from string
89
+ function str_get_html($str, $lowercase=true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
90
+ {
91
+ $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
92
+ if (empty($str) || strlen($str) > MAX_FILE_SIZE)
93
+ {
94
+ $dom->clear();
95
+ return false;
96
+ }
97
+ $dom->load($str, $lowercase, $stripRN);
98
+ return $dom;
99
+ }
100
+
101
+ // dump html dom tree
102
+ function dump_html_tree($node, $show_attr=true, $deep=0)
103
+ {
104
+ $node->dump($node);
105
+ }
106
+
107
+
108
+ /**
109
+ * simple html dom node
110
+ * PaperG - added ability for "find" routine to lowercase the value of the selector.
111
+ * PaperG - added $tag_start to track the start position of the tag in the total byte index
112
+ *
113
+ * @package PlaceLocalInclude
114
+ */
115
+ class simple_html_dom_node
116
+ {
117
+ public $nodetype = HDOM_TYPE_TEXT;
118
+ public $tag = 'text';
119
+ public $attr = array();
120
+ public $children = array();
121
+ public $nodes = array();
122
+ public $parent = null;
123
+ // The "info" array - see HDOM_INFO_... for what each element contains.
124
+ public $_ = array();
125
+ public $tag_start = 0;
126
+ private $dom = null;
127
+
128
+ function __construct($dom)
129
+ {
130
+ $this->dom = $dom;
131
+ $dom->nodes[] = $this;
132
+ }
133
+
134
+ function __destruct()
135
+ {
136
+ $this->clear();
137
+ }
138
+
139
+ function __toString()
140
+ {
141
+ return $this->outertext();
142
+ }
143
+
144
+ // clean up memory due to php5 circular references memory leak...
145
+ function clear()
146
+ {
147
+ $this->dom = null;
148
+ $this->nodes = null;
149
+ $this->parent = null;
150
+ $this->children = null;
151
+ }
152
+
153
+ // dump node's tree
154
+ function dump($show_attr=true, $deep=0)
155
+ {
156
+ $lead = str_repeat(' ', $deep);
157
+
158
+ echo $lead.$this->tag;
159
+ if ($show_attr && count($this->attr)>0)
160
+ {
161
+ echo '(';
162
+ foreach ($this->attr as $k=>$v)
163
+ echo "[$k]=>\"".$this->$k.'", ';
164
+ echo ')';
165
+ }
166
+ echo "\n";
167
+
168
+ if ($this->nodes)
169
+ {
170
+ foreach ($this->nodes as $c)
171
+ {
172
+ $c->dump($show_attr, $deep+1);
173
+ }
174
+ }
175
+ }
176
+
177
+
178
+ // Debugging function to dump a single dom node with a bunch of information about it.
179
+ function dump_node($echo=true)
180
+ {
181
+
182
+ $string = $this->tag;
183
+ if (count($this->attr)>0)
184
+ {
185
+ $string .= '(';
186
+ foreach ($this->attr as $k=>$v)
187
+ {
188
+ $string .= "[$k]=>\"".$this->$k.'", ';
189
+ }
190
+ $string .= ')';
191
+ }
192
+ if (count($this->_)>0)
193
+ {
194
+ $string .= ' $_ (';
195
+ foreach ($this->_ as $k=>$v)
196
+ {
197
+ if (is_array($v))
198
+ {
199
+ $string .= "[$k]=>(";
200
+ foreach ($v as $k2=>$v2)
201
+ {
202
+ $string .= "[$k2]=>\"".$v2.'", ';
203
+ }
204
+ $string .= ")";
205
+ } else {
206
+ $string .= "[$k]=>\"".$v.'", ';
207
+ }
208
+ }
209
+ $string .= ")";
210
+ }
211
+
212
+ if (isset($this->text))
213
+ {
214
+ $string .= " text: (" . $this->text . ")";
215
+ }
216
+
217
+ $string .= " HDOM_INNER_INFO: '";
218
+ if (isset($node->_[HDOM_INFO_INNER]))
219
+ {
220
+ $string .= $node->_[HDOM_INFO_INNER] . "'";
221
+ }
222
+ else
223
+ {
224
+ $string .= ' NULL ';
225
+ }
226
+
227
+ $string .= " children: " . count($this->children);
228
+ $string .= " nodes: " . count($this->nodes);
229
+ $string .= " tag_start: " . $this->tag_start;
230
+ $string .= "\n";
231
+
232
+ if ($echo)
233
+ {
234
+ echo $string;
235
+ return;
236
+ }
237
+ else
238
+ {
239
+ return $string;
240
+ }
241
+ }
242
+
243
+ // returns the parent of node
244
+ // If a node is passed in, it will reset the parent of the current node to that one.
245
+ function parent($parent=null)
246
+ {
247
+ // I am SURE that this doesn't work properly.
248
+ // It fails to unset the current node from it's current parents nodes or children list first.
249
+ if ($parent !== null)
250
+ {
251
+ $this->parent = $parent;
252
+ $this->parent->nodes[] = $this;
253
+ $this->parent->children[] = $this;
254
+ }
255
+
256
+ return $this->parent;
257
+ }
258
+
259
+ // verify that node has children
260
+ function has_child()
261
+ {
262
+ return !empty($this->children);
263
+ }
264
+
265
+ // returns children of node
266
+ function children($idx=-1)
267
+ {
268
+ if ($idx===-1)
269
+ {
270
+ return $this->children;
271
+ }
272
+ if (isset($this->children[$idx]))
273
+ {
274
+ return $this->children[$idx];
275
+ }
276
+ return null;
277
+ }
278
+
279
+ // returns the first child of node
280
+ function first_child()
281
+ {
282
+ if (count($this->children)>0)
283
+ {
284
+ return $this->children[0];
285
+ }
286
+ return null;
287
+ }
288
+
289
+ // returns the last child of node
290
+ function last_child()
291
+ {
292
+ if (($count=count($this->children))>0)
293
+ {
294
+ return $this->children[$count-1];
295
+ }
296
+ return null;
297
+ }
298
+
299
+ // returns the next sibling of node
300
+ function next_sibling()
301
+ {
302
+ if ($this->parent===null)
303
+ {
304
+ return null;
305
+ }
306
+
307
+ $idx = 0;
308
+ $count = count($this->parent->children);
309
+ while ($idx<$count && $this!==$this->parent->children[$idx])
310
+ {
311
+ ++$idx;
312
+ }
313
+ if (++$idx>=$count)
314
+ {
315
+ return null;
316
+ }
317
+ return $this->parent->children[$idx];
318
+ }
319
+
320
+ // returns the previous sibling of node
321
+ function prev_sibling()
322
+ {
323
+ if ($this->parent===null) return null;
324
+ $idx = 0;
325
+ $count = count($this->parent->children);
326
+ while ($idx<$count && $this!==$this->parent->children[$idx])
327
+ ++$idx;
328
+ if (--$idx<0) return null;
329
+ return $this->parent->children[$idx];
330
+ }
331
+
332
+ // function to locate a specific ancestor tag in the path to the root.
333
+ function find_ancestor_tag($tag)
334
+ {
335
+ global $debug_object;
336
+ if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
337
+
338
+ // Start by including ourselves in the comparison.
339
+ $returnDom = $this;
340
+
341
+ while (!is_null($returnDom))
342
+ {
343
+ if (is_object($debug_object)) { $debug_object->debug_log(2, "Current tag is: " . $returnDom->tag); }
344
+
345
+ if ($returnDom->tag == $tag)
346
+ {
347
+ break;
348
+ }
349
+ $returnDom = $returnDom->parent;
350
+ }
351
+ return $returnDom;
352
+ }
353
+
354
+ // get dom node's inner html
355
+ function innertext()
356
+ {
357
+ if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER];
358
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
359
+
360
+ $ret = '';
361
+ foreach ($this->nodes as $n)
362
+ $ret .= $n->outertext();
363
+ return $ret;
364
+ }
365
+
366
+ // get dom node's outer text (with tag)
367
+ function outertext()
368
+ {
369
+ global $debug_object;
370
+ if (is_object($debug_object))
371
+ {
372
+ $text = '';
373
+ if ($this->tag == 'text')
374
+ {
375
+ if (!empty($this->text))
376
+ {
377
+ $text = " with text: " . $this->text;
378
+ }
379
+ }
380
+ $debug_object->debug_log(1, 'Innertext of tag: ' . $this->tag . $text);
381
+ }
382
+
383
+ if ($this->tag==='root') return $this->innertext();
384
+
385
+ // trigger callback
386
+ if ($this->dom && $this->dom->callback!==null)
387
+ {
388
+ call_user_func_array($this->dom->callback, array($this));
389
+ }
390
+
391
+ if (isset($this->_[HDOM_INFO_OUTER])) return $this->_[HDOM_INFO_OUTER];
392
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
393
+
394
+ // render begin tag
395
+ if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]])
396
+ {
397
+ $ret = $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]->makeup();
398
+ } else {
399
+ $ret = "";
400
+ }
401
+
402
+ // render inner text
403
+ if (isset($this->_[HDOM_INFO_INNER]))
404
+ {
405
+ // If it's a br tag... don't return the HDOM_INNER_INFO that we may or may not have added.
406
+ if ($this->tag != "br")
407
+ {
408
+ $ret .= $this->_[HDOM_INFO_INNER];
409
+ }
410
+ } else {
411
+ if ($this->nodes)
412
+ {
413
+ foreach ($this->nodes as $n)
414
+ {
415
+ $ret .= $this->convert_text($n->outertext());
416
+ }
417
+ }
418
+ }
419
+
420
+ // render end tag
421
+ if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0)
422
+ $ret .= '</'.$this->tag.'>';
423
+ return $ret;
424
+ }
425
+
426
+ // get dom node's plain text
427
+ function text()
428
+ {
429
+ if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER];
430
+ switch ($this->nodetype)
431
+ {
432
+ case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
433
+ case HDOM_TYPE_COMMENT: return '';
434
+ case HDOM_TYPE_UNKNOWN: return '';
435
+ }
436
+ if (strcasecmp($this->tag, 'script')===0) return '';
437
+ if (strcasecmp($this->tag, 'style')===0) return '';
438
+
439
+ $ret = '';
440
+ // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL.
441
+ // NOTE: This indicates that there is a problem where it's set to NULL without a clear happening.
442
+ // WHY is this happening?
443
+ if (!is_null($this->nodes))
444
+ {
445
+ foreach ($this->nodes as $n)
446
+ {
447
+ $ret .= $this->convert_text($n->text());
448
+ }
449
+
450
+ // If this node is a span... add a space at the end of it so multiple spans don't run into each other. This is plaintext after all.
451
+ if ($this->tag == "span")
452
+ {
453
+ $ret .= $this->dom->default_span_text;
454
+ }
455
+
456
+
457
+ }
458
+ return $ret;
459
+ }
460
+
461
+ function xmltext()
462
+ {
463
+ $ret = $this->innertext();
464
+ $ret = str_ireplace('<![CDATA[', '', $ret);
465
+ $ret = str_replace(']]>', '', $ret);
466
+ return $ret;
467
+ }
468
+
469
+ // build node's text with tag
470
+ function makeup()
471
+ {
472
+ // text, comment, unknown
473
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
474
+
475
+ $ret = '<'.$this->tag;
476
+ $i = -1;
477
+
478
+ foreach ($this->attr as $key=>$val)
479
+ {
480
+ ++$i;
481
+
482
+ // skip removed attribute
483
+ if ($val===null || $val===false)
484
+ continue;
485
+
486
+ $ret .= $this->_[HDOM_INFO_SPACE][$i][0];
487
+ //no value attr: nowrap, checked selected...
488
+ if ($val===true)
489
+ $ret .= $key;
490
+ else {
491
+ switch ($this->_[HDOM_INFO_QUOTE][$i])
492
+ {
493
+ case HDOM_QUOTE_DOUBLE: $quote = '"'; break;
494
+ case HDOM_QUOTE_SINGLE: $quote = '\''; break;
495
+ default: $quote = '';
496
+ }
497
+ $ret .= $key.$this->_[HDOM_INFO_SPACE][$i][1].'='.$this->_[HDOM_INFO_SPACE][$i][2].$quote.$val.$quote;
498
+ }
499
+ }
500
+ $ret = $this->dom->restore_noise($ret);
501
+ return $ret . $this->_[HDOM_INFO_ENDSPACE] . '>';
502
+ }
503
+
504
+ // find elements by css selector
505
+ //PaperG - added ability for find to lowercase the value of the selector.
506
+ function find($selector, $idx=null, $lowercase=false)
507
+ {
508
+ $selectors = $this->parse_selector($selector);
509
+ if (($count=count($selectors))===0) return array();
510
+ $found_keys = array();
511
+
512
+ // find each selector
513
+ for ($c=0; $c<$count; ++$c)
514
+ {
515
+ // The change on the below line was documented on the sourceforge code tracker id 2788009
516
+ // used to be: if (($levle=count($selectors[0]))===0) return array();
517
+ if (($levle=count($selectors[$c]))===0) return array();
518
+ if (!isset($this->_[HDOM_INFO_BEGIN])) return array();
519
+
520
+ $head = array($this->_[HDOM_INFO_BEGIN]=>1);
521
+
522
+ // handle descendant selectors, no recursive!
523
+ for ($l=0; $l<$levle; ++$l)
524
+ {
525
+ $ret = array();
526
+ foreach ($head as $k=>$v)
527
+ {
528
+ $n = ($k===-1) ? $this->dom->root : $this->dom->nodes[$k];
529
+ //PaperG - Pass this optional parameter on to the seek function.
530
+ $n->seek($selectors[$c][$l], $ret, $lowercase);
531
+ }
532
+ $head = $ret;
533
+ }
534
+
535
+ foreach ($head as $k=>$v)
536
+ {
537
+ if (!isset($found_keys[$k]))
538
+ {
539
+ $found_keys[$k] = 1;
540
+ }
541
+ }
542
+ }
543
+
544
+ // sort keys
545
+ ksort($found_keys);
546
+
547
+ $found = array();
548
+ foreach ($found_keys as $k=>$v)
549
+ $found[] = $this->dom->nodes[$k];
550
+
551
+ // return nth-element or array
552
+ if (is_null($idx)) return $found;
553
+ else if ($idx<0) $idx = count($found) + $idx;
554
+ return (isset($found[$idx])) ? $found[$idx] : null;
555
+ }
556
+
557
+ // seek for given conditions
558
+ // PaperG - added parameter to allow for case insensitive testing of the value of a selector.
559
+ protected function seek($selector, &$ret, $lowercase=false)
560
+ {
561
+ global $debug_object;
562
+ if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
563
+
564
+ list($tag, $key, $val, $exp, $no_key) = $selector;
565
+
566
+ // xpath index
567
+ if ($tag && $key && is_numeric($key))
568
+ {
569
+ $count = 0;
570
+ foreach ($this->children as $c)
571
+ {
572
+ if ($tag==='*' || $tag===$c->tag) {
573
+ if (++$count==$key) {
574
+ $ret[$c->_[HDOM_INFO_BEGIN]] = 1;
575
+ return;
576
+ }
577
+ }
578
+ }
579
+ return;
580
+ }
581
+
582
+ $end = (!empty($this->_[HDOM_INFO_END])) ? $this->_[HDOM_INFO_END] : 0;
583
+ if ($end==0) {
584
+ $parent = $this->parent;
585
+ while (!isset($parent->_[HDOM_INFO_END]) && $parent!==null) {
586
+ $end -= 1;
587
+ $parent = $parent->parent;
588
+ }
589
+ $end += $parent->_[HDOM_INFO_END];
590
+ }
591
+
592
+ for ($i=$this->_[HDOM_INFO_BEGIN]+1; $i<$end; ++$i) {
593
+ $node = $this->dom->nodes[$i];
594
+
595
+ $pass = true;
596
+
597
+ if ($tag==='*' && !$key) {
598
+ if (in_array($node, $this->children, true))
599
+ $ret[$i] = 1;
600
+ continue;
601
+ }
602
+
603
+ // compare tag
604
+ if ($tag && $tag!=$node->tag && $tag!=='*') {$pass=false;}
605
+ // compare key
606
+ if ($pass && $key) {
607
+ if ($no_key) {
608
+ if (isset($node->attr[$key])) $pass=false;
609
+ } else {
610
+ if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false;
611
+ }
612
+ }
613
+ // compare value
614
+ if ($pass && $key && $val && $val!=='*') {
615
+ // If they have told us that this is a "plaintext" search then we want the plaintext of the node - right?
616
+ if ($key == "plaintext") {
617
+ // $node->plaintext actually returns $node->text();
618
+ $nodeKeyValue = $node->text();
619
+ } else {
620
+ // this is a normal search, we want the value of that attribute of the tag.
621
+ $nodeKeyValue = $node->attr[$key];
622
+ }
623
+ if (is_object($debug_object)) {$debug_object->debug_log(2, "testing node: " . $node->tag . " for attribute: " . $key . $exp . $val . " where nodes value is: " . $nodeKeyValue);}
624
+
625
+ //PaperG - If lowercase is set, do a case insensitive test of the value of the selector.
626
+ if ($lowercase) {
627
+ $check = $this->match($exp, strtolower($val), strtolower($nodeKeyValue));
628
+ } else {
629
+ $check = $this->match($exp, $val, $nodeKeyValue);
630
+ }
631
+ if (is_object($debug_object)) {$debug_object->debug_log(2, "after match: " . ($check ? "true" : "false"));}
632
+
633
+ // handle multiple class
634
+ if (!$check && strcasecmp($key, 'class')===0) {
635
+ foreach (explode(' ',$node->attr[$key]) as $k) {
636
+ // Without this, there were cases where leading, trailing, or double spaces lead to our comparing blanks - bad form.
637
+ if (!empty($k)) {
638
+ if ($lowercase) {
639
+ $check = $this->match($exp, strtolower($val), strtolower($k));
640
+ } else {
641
+ $check = $this->match($exp, $val, $k);
642
+ }
643
+ if ($check) break;
644
+ }
645
+ }
646
+ }
647
+ if (!$check) $pass = false;
648
+ }
649
+ if ($pass) $ret[$i] = 1;
650
+ unset($node);
651
+ }
652
+ // It's passed by reference so this is actually what this function returns.
653
+ if (is_object($debug_object)) {$debug_object->debug_log(1, "EXIT - ret: ", $ret);}
654
+ }
655
+
656
+ protected function match($exp, $pattern, $value) {
657
+ global $debug_object;
658
+ if (is_object($debug_object)) {$debug_object->debug_log_entry(1);}
659
+
660
+ switch ($exp) {
661
+ case '=':
662
+ return ($value===$pattern);
663
+ case '!=':
664
+ return ($value!==$pattern);
665
+ case '^=':
666
+ return preg_match("/^".preg_quote($pattern,'/')."/", $value);
667
+ case '$=':
668
+ return preg_match("/".preg_quote($pattern,'/')."$/", $value);
669
+ case '*=':
670
+ if ($pattern[0]=='/') {
671
+ return preg_match($pattern, $value);
672
+ }
673
+ return preg_match("/".$pattern."/i", $value);
674
+ }
675
+ return false;
676
+ }
677
+
678
+ protected function parse_selector($selector_string) {
679
+ global $debug_object;
680
+ if (is_object($debug_object)) {$debug_object->debug_log_entry(1);}
681
+
682
+ // pattern of CSS selectors, modified from mootools
683
+ // Paperg: Add the colon to the attrbute, so that it properly finds <tag attr:ibute="something" > like google does.
684
+ // Note: if you try to look at this attribute, yo MUST use getAttribute since $dom->x:y will fail the php syntax check.
685
+ // Notice the \[ starting the attbute? and the @? following? This implies that an attribute can begin with an @ sign that is not captured.
686
+ // This implies that an html attribute specifier may start with an @ sign that is NOT captured by the expression.
687
+ // farther study is required to determine of this should be documented or removed.
688
+ // $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
689
+ $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
690
+ preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER);
691
+ if (is_object($debug_object)) {$debug_object->debug_log(2, "Matches Array: ", $matches);}
692
+
693
+ $selectors = array();
694
+ $result = array();
695
+ //print_r($matches);
696
+
697
+ foreach ($matches as $m) {
698
+ $m[0] = trim($m[0]);
699
+ if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue;
700
+ // for browser generated xpath
701
+ if ($m[1]==='tbody') continue;
702
+
703
+ list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false);
704
+ if (!empty($m[2])) {$key='id'; $val=$m[2];}
705
+ if (!empty($m[3])) {$key='class'; $val=$m[3];}
706
+ if (!empty($m[4])) {$key=$m[4];}
707
+ if (!empty($m[5])) {$exp=$m[5];}
708
+ if (!empty($m[6])) {$val=$m[6];}
709
+
710
+ // convert to lowercase
711
+ if ($this->dom->lowercase) {$tag=strtolower($tag); $key=strtolower($key);}
712
+ //elements that do NOT have the specified attribute
713
+ if (isset($key[0]) && $key[0]==='!') {$key=substr($key, 1); $no_key=true;}
714
+
715
+ $result[] = array($tag, $key, $val, $exp, $no_key);
716
+ if (trim($m[7])===',') {
717
+ $selectors[] = $result;
718
+ $result = array();
719
+ }
720
+ }
721
+ if (count($result)>0)
722
+ $selectors[] = $result;
723
+ return $selectors;
724
+ }
725
+
726
+ function __get($name)
727
+ {
728
+ if (isset($this->attr[$name]))
729
+ {
730
+ return $this->convert_text($this->attr[$name]);
731
+ }
732
+ switch ($name)
733
+ {
734
+ case 'outertext': return $this->outertext();
735
+ case 'innertext': return $this->innertext();
736
+ case 'plaintext': return $this->text();
737
+ case 'xmltext': return $this->xmltext();
738
+ default: return array_key_exists($name, $this->attr);
739
+ }
740
+ }
741
+
742
+ function __set($name, $value)
743
+ {
744
+ global $debug_object;
745
+ if (is_object($debug_object)) {$debug_object->debug_log_entry(1);}
746
+
747
+ switch ($name)
748
+ {
749
+ case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value;
750
+ case 'innertext':
751
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->_[HDOM_INFO_TEXT] = $value;
752
+ return $this->_[HDOM_INFO_INNER] = $value;
753
+ }
754
+ if (!isset($this->attr[$name]))
755
+ {
756
+ $this->_[HDOM_INFO_SPACE][] = array(' ', '', '');
757
+ $this->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE;
758
+ }
759
+ $this->attr[$name] = $value;
760
+ }
761
+
762
+ function __isset($name)
763
+ {
764
+ switch ($name)
765
+ {
766
+ case 'outertext': return true;
767
+ case 'innertext': return true;
768
+ case 'plaintext': return true;
769
+ }
770
+ //no value attr: nowrap, checked selected...
771
+ return (array_key_exists($name, $this->attr)) ? true : isset($this->attr[$name]);
772
+ }
773
+
774
+ function __unset($name) {
775
+ if (isset($this->attr[$name]))
776
+ unset($this->attr[$name]);
777
+ }
778
+
779
+ // PaperG - Function to convert the text from one character set to another if the two sets are not the same.
780
+ function convert_text($text)
781
+ {
782
+ global $debug_object;
783
+ if (is_object($debug_object)) {$debug_object->debug_log_entry(1);}
784
+
785
+ $converted_text = $text;
786
+
787
+ $sourceCharset = "";
788
+ $targetCharset = "";
789
+
790
+ if ($this->dom)
791
+ {
792
+ $sourceCharset = strtoupper($this->dom->_charset);
793
+ $targetCharset = strtoupper($this->dom->_target_charset);
794
+ }
795
+ if (is_object($debug_object)) {$debug_object->debug_log(3, "source charset: " . $sourceCharset . " target charaset: " . $targetCharset);}
796
+
797
+ if (!empty($sourceCharset) && !empty($targetCharset) && (strcasecmp($sourceCharset, $targetCharset) != 0))
798
+ {
799
+ // Check if the reported encoding could have been incorrect and the text is actually already UTF-8
800
+ if ((strcasecmp($targetCharset, 'UTF-8') == 0) && ($this->is_utf8($text)))
801
+ {
802
+ $converted_text = $text;
803
+ }
804
+ else
805
+ {
806
+ $converted_text = iconv($sourceCharset, $targetCharset, $text);
807
+ }
808
+ }
809
+
810
+ // Lets make sure that we don't have that silly BOM issue with any of the utf-8 text we output.
811
+ if ($targetCharset == 'UTF-8')
812
+ {
813
+ if (substr($converted_text, 0, 3) == "\xef\xbb\xbf")
814
+ {
815
+ $converted_text = substr($converted_text, 3);
816
+ }
817
+ if (substr($converted_text, -3) == "\xef\xbb\xbf")
818
+ {
819
+ $converted_text = substr($converted_text, 0, -3);
820
+ }
821
+ }
822
+
823
+ return $converted_text;
824
+ }
825
+
826
+ /**
827
+ * Returns true if $string is valid UTF-8 and false otherwise.
828
+ *
829
+ * @param mixed $str String to be tested
830
+ * @return boolean
831
+ */
832
+ static function is_utf8($str)
833
+ {
834
+ $c=0; $b=0;
835
+ $bits=0;
836
+ $len=strlen($str);
837
+ for($i=0; $i<$len; $i++)
838
+ {
839
+ $c=ord($str[$i]);
840
+ if($c > 128)
841
+ {
842
+ if(($c >= 254)) return false;
843
+ elseif($c >= 252) $bits=6;
844
+ elseif($c >= 248) $bits=5;
845
+ elseif($c >= 240) $bits=4;
846
+ elseif($c >= 224) $bits=3;
847
+ elseif($c >= 192) $bits=2;
848
+ else return false;
849
+ if(($i+$bits) > $len) return false;
850
+ while($bits > 1)
851
+ {
852
+ $i++;
853
+ $b=ord($str[$i]);
854
+ if($b < 128 || $b > 191) return false;
855
+ $bits--;
856
+ }
857
+ }
858
+ }
859
+ return true;
860
+ }
861
+ /*
862
+ function is_utf8($string)
863
+ {
864
+ //this is buggy
865
+ return (utf8_encode(utf8_decode($string)) == $string);
866
+ }
867
+ */
868
+
869
+ /**
870
+ * Function to try a few tricks to determine the displayed size of an img on the page.
871
+ * NOTE: This will ONLY work on an IMG tag. Returns FALSE on all other tag types.
872
+ *
873
+ * @author John Schlick
874
+ * @version April 19 2012
875
+ * @return array an array containing the 'height' and 'width' of the image on the page or -1 if we can't figure it out.
876
+ */
877
+ function get_display_size()
878
+ {
879
+ global $debug_object;
880
+
881
+ $width = -1;
882
+ $height = -1;
883
+
884
+ if ($this->tag !== 'img')
885
+ {
886
+ return false;
887
+ }
888
+
889
+ // See if there is aheight or width attribute in the tag itself.
890
+ if (isset($this->attr['width']))
891
+ {
892
+ $width = $this->attr['width'];
893
+ }
894
+
895
+ if (isset($this->attr['height']))
896
+ {
897
+ $height = $this->attr['height'];
898
+ }
899
+
900
+ // Now look for an inline style.
901
+ if (isset($this->attr['style']))
902
+ {
903
+ // Thanks to user gnarf from stackoverflow for this regular expression.
904
+ $attributes = array();
905
+ preg_match_all("/([\w-]+)\s*:\s*([^;]+)\s*;?/", $this->attr['style'], $matches, PREG_SET_ORDER);
906
+ foreach ($matches as $match) {
907
+ $attributes[$match[1]] = $match[2];
908
+ }
909
+
910
+ // If there is a width in the style attributes:
911
+ if (isset($attributes['width']) && $width == -1)
912
+ {
913
+ // check that the last two characters are px (pixels)
914
+ if (strtolower(substr($attributes['width'], -2)) == 'px')
915
+ {
916
+ $proposed_width = substr($attributes['width'], 0, -2);
917
+ // Now make sure that it's an integer and not something stupid.
918
+ if (filter_var($proposed_width, FILTER_VALIDATE_INT))
919
+ {
920
+ $width = $proposed_width;
921
+ }
922
+ }
923
+ }
924
+
925
+ // If there is a width in the style attributes:
926
+ if (isset($attributes['height']) && $height == -1)
927
+ {
928
+ // check that the last two characters are px (pixels)
929
+ if (strtolower(substr($attributes['height'], -2)) == 'px')
930
+ {
931
+ $proposed_height = substr($attributes['height'], 0, -2);
932
+ // Now make sure that it's an integer and not something stupid.
933
+ if (filter_var($proposed_height, FILTER_VALIDATE_INT))
934
+ {
935
+ $height = $proposed_height;
936
+ }
937
+ }
938
+ }
939
+
940
+ }
941
+
942
+ // Future enhancement:
943
+ // Look in the tag to see if there is a class or id specified that has a height or width attribute to it.
944
+
945
+ // Far future enhancement
946
+ // Look at all the parent tags of this image to see if they specify a class or id that has an img selector that specifies a height or width
947
+ // Note that in this case, the class or id will have the img subselector for it to apply to the image.
948
+
949
+ // ridiculously far future development
950
+ // If the class or id is specified in a SEPARATE css file thats not on the page, go get it and do what we were just doing for the ones on the page.
951
+
952
+ $result = array('height' => $height,
953
+ 'width' => $width);
954
+ return $result;
955
+ }
956
+
957
+ // camel naming conventions
958
+ function getAllAttributes() {return $this->attr;}
959
+ function getAttribute($name) {return $this->__get($name);}
960
+ function setAttribute($name, $value) {$this->__set($name, $value);}
961
+ function hasAttribute($name) {return $this->__isset($name);}
962
+ function removeAttribute($name) {$this->__set($name, null);}
963
+ function getElementById($id) {return $this->find("#$id", 0);}
964
+ function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);}
965
+ function getElementByTagName($name) {return $this->find($name, 0);}
966
+ function getElementsByTagName($name, $idx=null) {return $this->find($name, $idx);}
967
+ function parentNode() {return $this->parent();}
968
+ function childNodes($idx=-1) {return $this->children($idx);}
969
+ function firstChild() {return $this->first_child();}
970
+ function lastChild() {return $this->last_child();}
971
+ function nextSibling() {return $this->next_sibling();}
972
+ function previousSibling() {return $this->prev_sibling();}
973
+ function hasChildNodes() {return $this->has_child();}
974
+ function nodeName() {return $this->tag;}
975
+ function appendChild($node) {$node->parent($this); return $node;}
976
+
977
+ }
978
+
979
+ /**
980
+ * simple html dom parser
981
+ * Paperg - in the find routine: allow us to specify that we want case insensitive testing of the value of the selector.
982
+ * Paperg - change $size from protected to public so we can easily access it
983
+ * Paperg - added ForceTagsClosed in the constructor which tells us whether we trust the html or not. Default is to NOT trust it.
984
+ *
985
+ * @package PlaceLocalInclude
986
+ */
987
+ class simple_html_dom
988
+ {
989
+ public $root = null;
990
+ public $nodes = array();
991
+ public $callback = null;
992
+ public $lowercase = false;
993
+ // Used to keep track of how large the text was when we started.
994
+ public $original_size;
995
+ public $size;
996
+ protected $pos;
997
+ protected $doc;
998
+ protected $char;
999
+ protected $cursor;
1000
+ protected $parent;
1001
+ protected $noise = array();
1002
+ protected $token_blank = " \t\r\n";
1003
+ protected $token_equal = ' =/>';
1004
+ protected $token_slash = " />\r\n\t";
1005
+ protected $token_attr = ' >';
1006
+ // Note that this is referenced by a child node, and so it needs to be public for that node to see this information.
1007
+ public $_charset = '';
1008
+ public $_target_charset = '';
1009
+ protected $default_br_text = "";
1010
+ public $default_span_text = "";
1011
+
1012
+ // use isset instead of in_array, performance boost about 30%...
1013
+ protected $self_closing_tags = array('img'=>1, 'br'=>1, 'input'=>1, 'meta'=>1, 'link'=>1, 'hr'=>1, 'base'=>1, 'embed'=>1, 'spacer'=>1);
1014
+ protected $block_tags = array('root'=>1, 'body'=>1, 'form'=>1, 'div'=>1, 'span'=>1, 'table'=>1);
1015
+ // Known sourceforge issue #2977341
1016
+ // B tags that are not closed cause us to return everything to the end of the document.
1017
+ protected $optional_closing_tags = array(
1018
+ 'tr'=>array('tr'=>1, 'td'=>1, 'th'=>1),
1019
+ 'th'=>array('th'=>1),
1020
+ 'td'=>array('td'=>1),
1021
+ 'li'=>array('li'=>1),
1022
+ 'dt'=>array('dt'=>1, 'dd'=>1),
1023
+ 'dd'=>array('dd'=>1, 'dt'=>1),
1024
+ 'dl'=>array('dd'=>1, 'dt'=>1),
1025
+ 'p'=>array('p'=>1),
1026
+ 'nobr'=>array('nobr'=>1),
1027
+ 'b'=>array('b'=>1),
1028
+ 'option'=>array('option'=>1),
1029
+ );
1030
+
1031
+ function __construct($str=null, $lowercase=true, $forceTagsClosed=true, $target_charset=DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
1032
+ {
1033
+ if ($str)
1034
+ {
1035
+ if (preg_match("/^http:\/\//i",$str) || is_file($str))
1036
+ {
1037
+ $this->load_file($str);
1038
+ }
1039
+ else
1040
+ {
1041
+ $this->load($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText);
1042
+ }
1043
+ }
1044
+ // Forcing tags to be closed implies that we don't trust the html, but it can lead to parsing errors if we SHOULD trust the html.
1045
+ if (!$forceTagsClosed) {
1046
+ $this->optional_closing_array=array();
1047
+ }
1048
+ $this->_target_charset = $target_charset;
1049
+ }
1050
+
1051
+ function __destruct()
1052
+ {
1053
+ $this->clear();
1054
+ }
1055
+
1056
+ // load html from string
1057
+ function load($str, $lowercase=true, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
1058
+ {
1059
+ global $debug_object;
1060
+
1061
+ // prepare
1062
+ $this->prepare($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText);
1063
+ // strip out cdata
1064
+ $this->remove_noise("'<!\[CDATA\[(.*?)\]\]>'is", true);
1065
+ // strip out comments
1066
+ $this->remove_noise("'<!--(.*?)-->'is");
1067
+ // Per sourceforge http://sourceforge.net/tracker/?func=detail&aid=2949097&group_id=218559&atid=1044037
1068
+ // Script tags removal now preceeds style tag removal.
1069
+ // strip out <script> tags
1070
+ $this->remove_noise("'<\s*script[^>]*[^/]>(.*?)<\s*/\s*script\s*>'is");
1071
+ $this->remove_noise("'<\s*script\s*>(.*?)<\s*/\s*script\s*>'is");
1072
+ // strip out <style> tags
1073
+ $this->remove_noise("'<\s*style[^>]*[^/]>(.*?)<\s*/\s*style\s*>'is");
1074
+ $this->remove_noise("'<\s*style\s*>(.*?)<\s*/\s*style\s*>'is");
1075
+ // strip out preformatted tags
1076
+ $this->remove_noise("'<\s*(?:code)[^>]*>(.*?)<\s*/\s*(?:code)\s*>'is");
1077
+ // strip out server side scripts
1078
+ $this->remove_noise("'(<\?)(.*?)(\?>)'s", true);
1079
+ // strip smarty scripts
1080
+ $this->remove_noise("'(\{\w)(.*?)(\})'s", true);
1081
+
1082
+ // parsing
1083
+ while ($this->parse());
1084
+ // end
1085
+ $this->root->_[HDOM_INFO_END] = $this->cursor;
1086
+ $this->parse_charset();
1087
+
1088
+ // make load function chainable
1089
+ return $this;
1090
+
1091
+ }
1092
+
1093
+ // load html from file
1094
+ function load_file()
1095
+ {
1096
+ $args = func_get_args();
1097
+ $this->load(call_user_func_array('file_get_contents', $args), true);
1098
+ // Throw an error if we can't properly load the dom.
1099
+ if (($error=error_get_last())!==null) {
1100
+ $this->clear();
1101
+ return false;
1102
+ }
1103
+ }
1104
+
1105
+ // set callback function
1106
+ function set_callback($function_name)
1107
+ {
1108
+ $this->callback = $function_name;
1109
+ }
1110
+
1111
+ // remove callback function
1112
+ function remove_callback()
1113
+ {
1114
+ $this->callback = null;
1115
+ }
1116
+
1117
+ // save dom as string
1118
+ function save($filepath='')
1119
+ {
1120
+ $ret = $this->root->innertext();
1121
+ if ($filepath!=='') file_put_contents($filepath, $ret, LOCK_EX);
1122
+ return $ret;
1123
+ }
1124
+
1125
+ // find dom node by css selector
1126
+ // Paperg - allow us to specify that we want case insensitive testing of the value of the selector.
1127
+ function find($selector, $idx=null, $lowercase=false)
1128
+ {
1129
+ return $this->root->find($selector, $idx, $lowercase);
1130
+ }
1131
+
1132
+ // clean up memory due to php5 circular references memory leak...
1133
+ function clear()
1134
+ {
1135
+ foreach ($this->nodes as $n) {$n->clear(); $n = null;}
1136
+ // This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear.
1137
+ if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null;}
1138
+ if (isset($this->parent)) {$this->parent->clear(); unset($this->parent);}
1139
+ if (isset($this->root)) {$this->root->clear(); unset($this->root);}
1140
+ unset($this->doc);
1141
+ unset($this->noise);
1142
+ }
1143
+
1144
+ function dump($show_attr=true)
1145
+ {
1146
+ $this->root->dump($show_attr);
1147
+ }
1148
+
1149
+ // prepare HTML data and init everything
1150
+ protected function prepare($str, $lowercase=true, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
1151
+ {
1152
+ $this->clear();
1153
+
1154
+ // set the length of content before we do anything to it.
1155
+ $this->size = strlen($str);
1156
+ // Save the original size of the html that we got in. It might be useful to someone.
1157
+ $this->original_size = $this->size;
1158
+
1159
+ //before we save the string as the doc... strip out the \r \n's if we are told to.
1160
+ if ($stripRN) {
1161
+ $str = str_replace("\r", " ", $str);
1162
+ $str = str_replace("\n", " ", $str);
1163
+
1164
+ // set the length of content since we have changed it.
1165
+ $this->size = strlen($str);
1166
+ }
1167
+
1168
+ $this->doc = $str;
1169
+ $this->pos = 0;
1170
+ $this->cursor = 1;
1171
+ $this->noise = array();
1172
+ $this->nodes = array();
1173
+ $this->lowercase = $lowercase;
1174
+ $this->default_br_text = $defaultBRText;
1175
+ $this->default_span_text = $defaultSpanText;
1176
+ $this->root = new simple_html_dom_node($this);
1177
+ $this->root->tag = 'root';
1178
+ $this->root->_[HDOM_INFO_BEGIN] = -1;
1179
+ $this->root->nodetype = HDOM_TYPE_ROOT;
1180
+ $this->parent = $this->root;
1181
+ if ($this->size>0) $this->char = $this->doc[0];
1182
+ }
1183
+
1184
+ // parse html content
1185
+ protected function parse()
1186
+ {
1187
+ if (($s = $this->copy_until_char('<'))==='')
1188
+ {
1189
+ return $this->read_tag();
1190
+ }
1191
+
1192
+ // text
1193
+ $node = new simple_html_dom_node($this);
1194
+ ++$this->cursor;
1195
+ $node->_[HDOM_INFO_TEXT] = $s;
1196
+ $this->link_nodes($node, false);
1197
+ return true;
1198
+ }
1199
+
1200
+ // PAPERG - dkchou - added this to try to identify the character set of the page we have just parsed so we know better how to spit it out later.
1201
+ // NOTE: IF you provide a routine called get_last_retrieve_url_contents_content_type which returns the CURLINFO_CONTENT_TYPE from the last curl_exec
1202
+ // (or the content_type header from the last transfer), we will parse THAT, and if a charset is specified, we will use it over any other mechanism.
1203
+ protected function parse_charset()
1204
+ {
1205
+ global $debug_object;
1206
+
1207
+ $charset = null;
1208
+
1209
+ if (function_exists('get_last_retrieve_url_contents_content_type'))
1210
+ {
1211
+ $contentTypeHeader = get_last_retrieve_url_contents_content_type();
1212
+ $success = preg_match('/charset=(.+)/', $contentTypeHeader, $matches);
1213
+ if ($success)
1214
+ {
1215
+ $charset = $matches[1];
1216
+ if (is_object($debug_object)) {$debug_object->debug_log(2, 'header content-type found charset of: ' . $charset);}
1217
+ }
1218
+
1219
+ }
1220
+
1221
+ if (empty($charset))
1222
+ {
1223
+ $el = $this->root->find('meta[http-equiv=Content-Type]',0, true);
1224
+ if (!empty($el))
1225
+ {
1226
+ $fullvalue = $el->content;
1227
+ if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag found' . $fullvalue);}
1228
+
1229
+ if (!empty($fullvalue))
1230
+ {
1231
+ $success = preg_match('/charset=(.+)/i', $fullvalue, $matches);
1232
+ if ($success)
1233
+ {
1234
+ $charset = $matches[1];
1235
+ }
1236
+ else
1237
+ {
1238
+ // If there is a meta tag, and they don't specify the character set, research says that it's typically ISO-8859-1
1239
+ if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.');}
1240
+ $charset = 'ISO-8859-1';
1241
+ }
1242
+ }
1243
+ }
1244
+ }
1245
+
1246
+ // If we couldn't find a charset above, then lets try to detect one based on the text we got...
1247
+ if (empty($charset))
1248
+ {
1249
+ // Use this in case mb_detect_charset isn't installed/loaded on this machine.
1250
+ $charset = false;
1251
+ if (function_exists('mb_detect_encoding'))
1252
+ {
1253
+ // Have php try to detect the encoding from the text given to us.
1254
+ $charset = mb_detect_encoding($this->root->plaintext . "ascii", $encoding_list = array( "UTF-8", "CP1252" ) );
1255
+ if (is_object($debug_object)) {$debug_object->debug_log(2, 'mb_detect found: ' . $charset);}
1256
+ }
1257
+
1258
+ // and if this doesn't work... then we need to just wrongheadedly assume it's UTF-8 so that we can move on - cause this will usually give us most of what we need...
1259
+ if ($charset === false)
1260
+ {
1261
+ if (is_object($debug_object)) {$debug_object->debug_log(2, 'since mb_detect failed - using default of utf-8');}
1262
+ $charset = 'UTF-8';
1263
+ }
1264
+ }
1265
+
1266
+ // Since CP1252 is a superset, if we get one of it's subsets, we want it instead.
1267
+ if ((strtolower($charset) == strtolower('ISO-8859-1')) || (strtolower($charset) == strtolower('Latin1')) || (strtolower($charset) == strtolower('Latin-1')))
1268
+ {
1269
+ if (is_object($debug_object)) {$debug_object->debug_log(2, 'replacing ' . $charset . ' with CP1252 as its a superset');}
1270
+ $charset = 'CP1252';
1271
+ }
1272
+
1273
+ if (is_object($debug_object)) {$debug_object->debug_log(1, 'EXIT - ' . $charset);}
1274
+
1275
+ return $this->_charset = $charset;
1276
+ }
1277
+
1278
+ // read tag info
1279
+ protected function read_tag()
1280
+ {
1281
+ if ($this->char!=='<')
1282
+ {
1283
+ $this->root->_[HDOM_INFO_END] = $this->cursor;
1284
+ return false;
1285
+ }
1286
+ $begin_tag_pos = $this->pos;
1287
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1288
+
1289
+ // end tag
1290
+ if ($this->char==='/')
1291
+ {
1292
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1293
+ // This represents the change in the simple_html_dom trunk from revision 180 to 181.
1294
+ // $this->skip($this->token_blank_t);
1295
+ $this->skip($this->token_blank);
1296
+ $tag = $this->copy_until_char('>');
1297
+
1298
+ // skip attributes in end tag
1299
+ if (($pos = strpos($tag, ' '))!==false)
1300
+ $tag = substr($tag, 0, $pos);
1301
+
1302
+ $parent_lower = strtolower($this->parent->tag);
1303
+ $tag_lower = strtolower($tag);
1304
+
1305
+ if ($parent_lower!==$tag_lower)
1306
+ {
1307
+ if (isset($this->optional_closing_tags[$parent_lower]) && isset($this->block_tags[$tag_lower]))
1308
+ {
1309
+ $this->parent->_[HDOM_INFO_END] = 0;
1310
+ $org_parent = $this->parent;
1311
+
1312
+ while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower)
1313
+ $this->parent = $this->parent->parent;
1314
+
1315
+ if (strtolower($this->parent->tag)!==$tag_lower) {
1316
+ $this->parent = $org_parent; // restore origonal parent
1317
+ if ($this->parent->parent) $this->parent = $this->parent->parent;
1318
+ $this->parent->_[HDOM_INFO_END] = $this->cursor;
1319
+ return $this->as_text_node($tag);
1320
+ }
1321
+ }
1322
+ else if (($this->parent->parent) && isset($this->block_tags[$tag_lower]))
1323
+ {
1324
+ $this->parent->_[HDOM_INFO_END] = 0;
1325
+ $org_parent = $this->parent;
1326
+
1327
+ while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower)
1328
+ $this->parent = $this->parent->parent;
1329
+
1330
+ if (strtolower($this->parent->tag)!==$tag_lower)
1331
+ {
1332
+ $this->parent = $org_parent; // restore origonal parent
1333
+ $this->parent->_[HDOM_INFO_END] = $this->cursor;
1334
+ return $this->as_text_node($tag);
1335
+ }
1336
+ }
1337
+ else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower)
1338
+ {
1339
+ $this->parent->_[HDOM_INFO_END] = 0;
1340
+ $this->parent = $this->parent->parent;
1341
+ }
1342
+ else
1343
+ return $this->as_text_node($tag);
1344
+ }
1345
+
1346
+ $this->parent->_[HDOM_INFO_END] = $this->cursor;
1347
+ if ($this->parent->parent) $this->parent = $this->parent->parent;
1348
+
1349
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1350
+ return true;
1351
+ }
1352
+
1353
+ $node = new simple_html_dom_node($this);
1354
+ $node->_[HDOM_INFO_BEGIN] = $this->cursor;
1355
+ ++$this->cursor;
1356
+ $tag = $this->copy_until($this->token_slash);
1357
+ $node->tag_start = $begin_tag_pos;
1358
+
1359
+ // doctype, cdata & comments...
1360
+ if (isset($tag[0]) && $tag[0]==='!') {
1361
+ $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until_char('>');
1362
+
1363
+ if (isset($tag[2]) && $tag[1]==='-' && $tag[2]==='-') {
1364
+ $node->nodetype = HDOM_TYPE_COMMENT;
1365
+ $node->tag = 'comment';
1366
+ } else {
1367
+ $node->nodetype = HDOM_TYPE_UNKNOWN;
1368
+ $node->tag = 'unknown';
1369
+ }
1370
+ if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>';
1371
+ $this->link_nodes($node, true);
1372
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1373
+ return true;
1374
+ }
1375
+
1376
+ // text
1377
+ if ($pos=strpos($tag, '<')!==false) {
1378
+ $tag = '<' . substr($tag, 0, -1);
1379
+ $node->_[HDOM_INFO_TEXT] = $tag;
1380
+ $this->link_nodes($node, false);
1381
+ $this->char = $this->doc[--$this->pos]; // prev
1382
+ return true;
1383
+ }
1384
+
1385
+ if (!preg_match("/^[\w-:]+$/", $tag)) {
1386
+ $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until('<>');
1387
+ if ($this->char==='<') {
1388
+ $this->link_nodes($node, false);
1389
+ return true;
1390
+ }
1391
+
1392
+ if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>';
1393
+ $this->link_nodes($node, false);
1394
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1395
+ return true;
1396
+ }
1397
+
1398
+ // begin tag
1399
+ $node->nodetype = HDOM_TYPE_ELEMENT;
1400
+ $tag_lower = strtolower($tag);
1401
+ $node->tag = ($this->lowercase) ? $tag_lower : $tag;
1402
+
1403
+ // handle optional closing tags
1404
+ if (isset($this->optional_closing_tags[$tag_lower]) )
1405
+ {
1406
+ while (isset($this->optional_closing_tags[$tag_lower][strtolower($this->parent->tag)]))
1407
+ {
1408
+ $this->parent->_[HDOM_INFO_END] = 0;
1409
+ $this->parent = $this->parent->parent;
1410
+ }
1411
+ $node->parent = $this->parent;
1412
+ }
1413
+
1414
+ $guard = 0; // prevent infinity loop
1415
+ $space = array($this->copy_skip($this->token_blank), '', '');
1416
+
1417
+ // attributes
1418
+ do
1419
+ {
1420
+ if ($this->char!==null && $space[0]==='')
1421
+ {
1422
+ break;
1423
+ }
1424
+ $name = $this->copy_until($this->token_equal);
1425
+ if ($guard===$this->pos)
1426
+ {
1427
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1428
+ continue;
1429
+ }
1430
+ $guard = $this->pos;
1431
+
1432
+ // handle endless '<'
1433
+ if ($this->pos>=$this->size-1 && $this->char!=='>') {
1434
+ $node->nodetype = HDOM_TYPE_TEXT;
1435
+ $node->_[HDOM_INFO_END] = 0;
1436
+ $node->_[HDOM_INFO_TEXT] = '<'.$tag . $space[0] . $name;
1437
+ $node->tag = 'text';
1438
+ $this->link_nodes($node, false);
1439
+ return true;
1440
+ }
1441
+
1442
+ // handle mismatch '<'
1443
+ if ($this->doc[$this->pos-1]=='<') {
1444
+ $node->nodetype = HDOM_TYPE_TEXT;
1445
+ $node->tag = 'text';
1446
+ $node->attr = array();
1447
+ $node->_[HDOM_INFO_END] = 0;
1448
+ $node->_[HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos-$begin_tag_pos-1);
1449
+ $this->pos -= 2;
1450
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1451
+ $this->link_nodes($node, false);
1452
+ return true;
1453
+ }
1454
+
1455
+ if ($name!=='/' && $name!=='') {
1456
+ $space[1] = $this->copy_skip($this->token_blank);
1457
+ $name = $this->restore_noise($name);
1458
+ if ($this->lowercase) $name = strtolower($name);
1459
+ if ($this->char==='=') {
1460
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1461
+ $this->parse_attr($node, $name, $space);
1462
+ }
1463
+ else {
1464
+ //no value attr: nowrap, checked selected...
1465
+ $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO;
1466
+ $node->attr[$name] = true;
1467
+ if ($this->char!='>') $this->char = $this->doc[--$this->pos]; // prev
1468
+ }
1469
+ $node->_[HDOM_INFO_SPACE][] = $space;
1470
+ $space = array($this->copy_skip($this->token_blank), '', '');
1471
+ }
1472
+ else
1473
+ break;
1474
+ } while ($this->char!=='>' && $this->char!=='/');
1475
+
1476
+ $this->link_nodes($node, true);
1477
+ $node->_[HDOM_INFO_ENDSPACE] = $space[0];
1478
+
1479
+ // check self closing
1480
+ if ($this->copy_until_char_escape('>')==='/')
1481
+ {
1482
+ $node->_[HDOM_INFO_ENDSPACE] .= '/';
1483
+ $node->_[HDOM_INFO_END] = 0;
1484
+ }
1485
+ else
1486
+ {
1487
+ // reset parent
1488
+ if (!isset($this->self_closing_tags[strtolower($node->tag)])) $this->parent = $node;
1489
+ }
1490
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1491
+
1492
+ // If it's a BR tag, we need to set it's text to the default text.
1493
+ // This way when we see it in plaintext, we can generate formatting that the user wants.
1494
+ // since a br tag never has sub nodes, this works well.
1495
+ if ($node->tag == "br")
1496
+ {
1497
+ $node->_[HDOM_INFO_INNER] = $this->default_br_text;
1498
+ }
1499
+
1500
+ return true;
1501
+ }
1502
+
1503
+ // parse attributes
1504
+ protected function parse_attr($node, $name, &$space)
1505
+ {
1506
+ // Per sourceforge: http://sourceforge.net/tracker/?func=detail&aid=3061408&group_id=218559&atid=1044037
1507
+ // If the attribute is already defined inside a tag, only pay atetntion to the first one as opposed to the last one.
1508
+ if (isset($node->attr[$name]))
1509
+ {
1510
+ return;
1511
+ }
1512
+
1513
+ $space[2] = $this->copy_skip($this->token_blank);
1514
+ switch ($this->char) {
1515
+ case '"':
1516
+ $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE;
1517
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1518
+ $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('"'));
1519
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1520
+ break;
1521
+ case '\'':
1522
+ $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_SINGLE;
1523
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1524
+ $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('\''));
1525
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1526
+ break;
1527
+ default:
1528
+ $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO;
1529
+ $node->attr[$name] = $this->restore_noise($this->copy_until($this->token_attr));
1530
+ }
1531
+ // PaperG: Attributes should not have \r or \n in them, that counts as html whitespace.
1532
+ $node->attr[$name] = str_replace("\r", "", $node->attr[$name]);
1533
+ $node->attr[$name] = str_replace("\n", "", $node->attr[$name]);
1534
+ // PaperG: If this is a "class" selector, lets get rid of the preceeding and trailing space since some people leave it in the multi class case.
1535
+ if ($name == "class") {
1536
+ $node->attr[$name] = $node->attr[$name];
1537
+ }
1538
+ }
1539
+
1540
+ // link node's parent
1541
+ protected function link_nodes(&$node, $is_child)
1542
+ {
1543
+ $node->parent = $this->parent;
1544
+ $this->parent->nodes[] = $node;
1545
+ if ($is_child)
1546
+ {
1547
+ $this->parent->children[] = $node;
1548
+ }
1549
+ }
1550
+
1551
+ // as a text node
1552
+ protected function as_text_node($tag)
1553
+ {
1554
+ $node = new simple_html_dom_node($this);
1555
+ ++$this->cursor;
1556
+ $node->_[HDOM_INFO_TEXT] = '</' . $tag . '>';
1557
+ $this->link_nodes($node, false);
1558
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1559
+ return true;
1560
+ }
1561
+
1562
+ protected function skip($chars)
1563
+ {
1564
+ $this->pos += strspn($this->doc, $chars, $this->pos);
1565
+ $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1566
+ }
1567
+
1568
+ protected function copy_skip($chars)
1569
+ {
1570
+ $pos = $this->pos;
1571
+ $len = strspn($this->doc, $chars, $pos);
1572
+ $this->pos += $len;
1573
+ $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1574
+ if ($len===0) return '';
1575
+ return substr($this->doc, $pos, $len);
1576
+ }
1577
+
1578
+ protected function copy_until($chars)
1579
+ {
1580
+ $pos = $this->pos;
1581
+ $len = strcspn($this->doc, $chars, $pos);
1582
+ $this->pos += $len;
1583
+ $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1584
+ return substr($this->doc, $pos, $len);
1585
+ }
1586
+
1587
+ protected function copy_until_char($char)
1588
+ {
1589
+ if ($this->char===null) return '';
1590
+
1591
+ if (($pos = strpos($this->doc, $char, $this->pos))===false) {
1592
+ $ret = substr($this->doc, $this->pos, $this->size-$this->pos);
1593
+ $this->char = null;
1594
+ $this->pos = $this->size;
1595
+ return $ret;
1596
+ }
1597
+
1598
+ if ($pos===$this->pos) return '';
1599
+ $pos_old = $this->pos;
1600
+ $this->char = $this->doc[$pos];
1601
+ $this->pos = $pos;
1602
+ return substr($this->doc, $pos_old, $pos-$pos_old);
1603
+ }
1604
+
1605
+ protected function copy_until_char_escape($char)
1606
+ {
1607
+ if ($this->char===null) return '';
1608
+
1609
+ $start = $this->pos;
1610
+ while (1)
1611
+ {
1612
+ if (($pos = strpos($this->doc, $char, $start))===false)
1613
+ {
1614
+ $ret = substr($this->doc, $this->pos, $this->size-$this->pos);
1615
+ $this->char = null;
1616
+ $this->pos = $this->size;
1617
+ return $ret;
1618
+ }
1619
+
1620
+ if ($pos===$this->pos) return '';
1621
+
1622
+ if ($this->doc[$pos-1]==='\\') {
1623
+ $start = $pos+1;
1624
+ continue;
1625
+ }
1626
+
1627
+ $pos_old = $this->pos;
1628
+ $this->char = $this->doc[$pos];
1629
+ $this->pos = $pos;
1630
+ return substr($this->doc, $pos_old, $pos-$pos_old);
1631
+ }
1632
+ }
1633
+
1634
+ // remove noise from html content
1635
+ // save the noise in the $this->noise array.
1636
+ protected function remove_noise($pattern, $remove_tag=false)
1637
+ {
1638
+ global $debug_object;
1639
+ if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
1640
+
1641
+ $count = preg_match_all($pattern, $this->doc, $matches, PREG_SET_ORDER|PREG_OFFSET_CAPTURE);
1642
+
1643
+ for ($i=$count-1; $i>-1; --$i)
1644
+ {
1645
+ $key = '___noise___'.sprintf('% 5d', count($this->noise)+1000);
1646
+ if (is_object($debug_object)) { $debug_object->debug_log(2, 'key is: ' . $key); }
1647
+ $idx = ($remove_tag) ? 0 : 1;
1648
+ $this->noise[$key] = $matches[$i][$idx][0];
1649
+ $this->doc = substr_replace($this->doc, $key, $matches[$i][$idx][1], strlen($matches[$i][$idx][0]));
1650
+ }
1651
+
1652
+ // reset the length of content
1653
+ $this->size = strlen($this->doc);
1654
+ if ($this->size>0)
1655
+ {
1656
+ $this->char = $this->doc[0];
1657
+ }
1658
+ }
1659
+
1660
+ // restore noise to html content
1661
+ function restore_noise($text)
1662
+ {
1663
+ global $debug_object;
1664
+ if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
1665
+
1666
+ while (($pos=strpos($text, '___noise___'))!==false)
1667
+ {
1668
+ // Sometimes there is a broken piece of markup, and we don't GET the pos+11 etc... token which indicates a problem outside of us...
1669
+ if (strlen($text) > $pos+15)
1670
+ {
1671
+ $key = '___noise___'.$text[$pos+11].$text[$pos+12].$text[$pos+13].$text[$pos+14].$text[$pos+15];
1672
+ if (is_object($debug_object)) { $debug_object->debug_log(2, 'located key of: ' . $key); }
1673
+
1674
+ if (isset($this->noise[$key]))
1675
+ {
1676
+ $text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos+16);
1677
+ }
1678
+ else
1679
+ {
1680
+ // do this to prevent an infinite loop.
1681
+ $text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key . substr($text, $pos+16);
1682
+ }
1683
+ }
1684
+ else
1685
+ {
1686
+ // There is no valid key being given back to us... We must get rid of the ___noise___ or we will have a problem.
1687
+ $text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY' . substr($text, $pos+11);
1688
+ }
1689
+ }
1690
+ return $text;
1691
+ }
1692
+
1693
+ // Sometimes we NEED one of the noise elements.
1694
+ function search_noise($text)
1695
+ {
1696
+ global $debug_object;
1697
+ if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
1698
+
1699
+ foreach($this->noise as $noiseElement)
1700
+ {
1701
+ if (strpos($noiseElement, $text)!==false)
1702
+ {
1703
+ return $noiseElement;
1704
+ }
1705
+ }
1706
+ }
1707
+ function __toString()
1708
+ {
1709
+ return $this->root->innertext();
1710
+ }
1711
+
1712
+ function __get($name)
1713
+ {
1714
+ switch ($name)
1715
+ {
1716
+ case 'outertext':
1717
+ return $this->root->innertext();
1718
+ case 'innertext':
1719
+ return $this->root->innertext();
1720
+ case 'plaintext':
1721
+ return $this->root->text();
1722
+ case 'charset':
1723
+ return $this->_charset;
1724
+ case 'target_charset':
1725
+ return $this->_target_charset;
1726
+ }
1727
+ }
1728
+
1729
+ // camel naming conventions
1730
+ function childNodes($idx=-1) {return $this->root->childNodes($idx);}
1731
+ function firstChild() {return $this->root->first_child();}
1732
+ function lastChild() {return $this->root->last_child();}
1733
+ function createElement($name, $value=null) {return @str_get_html("<$name>$value</$name>")->first_child();}
1734
+ function createTextNode($value) {return @end(str_get_html($value)->nodes);}
1735
+ function getElementById($id) {return $this->find("#$id", 0);}
1736
+ function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);}
1737
+ function getElementByTagName($name) {return $this->find($name, 0);}
1738
+ function getElementsByTagName($name, $idx=-1) {return $this->find($name, $idx);}
1739
+ function loadFile() {$args = func_get_args();$this->load_file($args);}
1740
+ }
1741
+
1742
+ ?>
trunk/js/admin.js ADDED
@@ -0,0 +1,320 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* GENERATE RETINA IMAGES ACTION */
2
+
3
+ var current;
4
+ var maxPhpSize = wr2x_admin_server.maxFileSize;
5
+ var ids = [];
6
+ var errors = 0;
7
+ var ajax_action = "generate"; // generate | delete
8
+
9
+ function wr2x_display_please_refresh() {
10
+ wr2x_refresh_progress_status();
11
+ jQuery('#wr2x_progression').html(jQuery('#wr2x_progression').html() + " - " + wr2x_admin_server.i18n.Refresh);
12
+ }
13
+
14
+ function wr2x_refresh_progress_status() {
15
+ var errortext = "";
16
+ if ( errors > 0 ) {
17
+ errortext = ' - ' + errors + ' error(s)';
18
+ }
19
+ jQuery('#wr2x_progression').text(current + "/" + ids.length +
20
+ " (" + Math.round(current / ids.length * 100) + "%)" + errortext);
21
+ }
22
+
23
+ function wr2x_do_next () {
24
+ var data = { action: 'wr2x_' + ajax_action, attachmentId: ids[current - 1] };
25
+ data.nonce = wr2x_admin_server.nonce[data.action];
26
+
27
+ wr2x_refresh_progress_status();
28
+ jQuery.post(ajaxurl, data, function (response) {
29
+ try {
30
+ reply = jQuery.parseJSON(response);
31
+ }
32
+ catch (e) {
33
+ reply = null;
34
+ }
35
+ if ( !reply || !reply.success )
36
+ errors++;
37
+ else {
38
+ wr2x_refresh_media_sizes(reply.results);
39
+ if (reply.results_full)
40
+ wr2x_refresh_full(reply.results_full);
41
+ }
42
+ if (++current <= ids.length)
43
+ wr2x_do_next();
44
+ else {
45
+ current--;
46
+ wr2x_display_please_refresh();
47
+ }
48
+ }).fail(function () {
49
+ errors++;
50
+ if (++current <= ids.length)
51
+ wr2x_do_next();
52
+ else {
53
+ current--;
54
+ wr2x_display_please_refresh();
55
+ }
56
+ });
57
+ }
58
+
59
+ function wr2x_do_all () {
60
+ current = 1;
61
+ ids = [];
62
+ errors = 0;
63
+ var data = { action: 'wr2x_list_all', issuesOnly: 0 };
64
+ data.nonce = wr2x_admin_server.nonce[data.action];
65
+
66
+ jQuery('#wr2x_progression').text(wr2x_admin_server.i18n.Wait);
67
+ jQuery.post(ajaxurl, data, function (response) {
68
+ reply = jQuery.parseJSON(response);
69
+ if (reply.success = false) {
70
+ alert('Error: ' + reply.message);
71
+ return;
72
+ }
73
+ if (reply.total == 0) {
74
+ jQuery('#wr2x_progression').html(wr2x_admin_server.i18n.Nothing_to_do);
75
+ return;
76
+ }
77
+ ids = reply.ids;
78
+ jQuery('#wr2x_progression').text(current + "/" + ids.length + " (" + Math.round(current / ids.length * 100) + "%)");
79
+ wr2x_do_next();
80
+ });
81
+ }
82
+
83
+ function wr2x_delete_all () {
84
+ ajax_action = 'delete';
85
+ wr2x_do_all();
86
+ }
87
+
88
+ function wr2x_generate_all () {
89
+ ajax_action = 'generate';
90
+ wr2x_do_all();
91
+ }
92
+
93
+ // Refresh the dashboard retina full with the results from the Ajax operation (Upload)
94
+ function wr2x_refresh_full (results) {
95
+ jQuery.each(results, function (id, html) {
96
+ jQuery('#wr2x-info-full-' + id).html(html);
97
+ jQuery('#wr2x-info-full-' + id + ' img').attr('src', jQuery('#wr2x-info-full-' + id + ' img').attr('src')+'?'+ Math.random());
98
+ jQuery('#wr2x-info-full-' + id + ' img').on('click', function (evt) {
99
+ wr2x_delete_full( jQuery(evt.target).parents('.wr2x-file-row').attr('postid') );
100
+ });
101
+ });
102
+ }
103
+
104
+ // Refresh the dashboard media sizes with the results from the Ajax operation (Replace or Generate)
105
+ function wr2x_refresh_media_sizes (results) {
106
+ jQuery.each(results, function (id, html) {
107
+ jQuery('#wr2x-info-' + id).html(html);
108
+ });
109
+ }
110
+
111
+ function wr2x_generate (attachmentId, retinaDashboard) {
112
+ var data = { action: 'wr2x_generate', attachmentId: attachmentId };
113
+ data.nonce = wr2x_admin_server.nonce[data.action];
114
+
115
+ jQuery('#wr2x_generate_button_' + attachmentId).text(wr2x_admin_server.i18n.Wait);
116
+ jQuery.post(ajaxurl, data, function (response) {
117
+ var reply = jQuery.parseJSON(response);
118
+ if (!reply.success) {
119
+ alert(reply.message);
120
+ return;
121
+ }
122
+ jQuery('#wr2x_generate_button_' + attachmentId).html(wr2x_admin_server.i18n.Generate);
123
+ wr2x_refresh_media_sizes(reply.results);
124
+ });
125
+ }
126
+
127
+ /* REPLACE FUNCTION */
128
+
129
+ function wr2x_stop_propagation(evt) {
130
+ evt.stopPropagation();
131
+ evt.preventDefault();
132
+ }
133
+
134
+ function wr2x_delete_full(attachmentId) {
135
+ var data = {
136
+ action: 'wr2x_delete_full',
137
+ isAjax: true,
138
+ attachmentId: attachmentId
139
+ };
140
+ data.nonce = wr2x_admin_server.nonce[data.action];
141
+
142
+ jQuery.post(ajaxurl, data, function (response) {
143
+ var data = jQuery.parseJSON(response);
144
+ if (data.success === false) {
145
+ alert(data.message);
146
+ }
147
+ else {
148
+ wr2x_refresh_full(data.results);
149
+ wr2x_display_please_refresh();
150
+ }
151
+ });
152
+ }
153
+
154
+ function wr2x_load_details(attachmentId) {
155
+ var data = {
156
+ action: 'wr2x_retina_details',
157
+ isAjax: true,
158
+ attachmentId: attachmentId
159
+ };
160
+ data.nonce = wr2x_admin_server.nonce[data.action];
161
+
162
+ jQuery.post(ajaxurl, data, function (response) {
163
+ var data = jQuery.parseJSON(response);
164
+ if (data.success === false) {
165
+ alert(data.message);
166
+ }
167
+ else {
168
+ jQuery('#meow-modal-info .loading').css('display', 'none');
169
+ jQuery('#meow-modal-info .content').html(data.result);
170
+ }
171
+ });
172
+ }
173
+
174
+ function wr2x_filedropped (evt) {
175
+ wr2x_stop_propagation(evt);
176
+ var files = evt.dataTransfer.files;
177
+ var count = files.length;
178
+ if (count < 0) {
179
+ return;
180
+ }
181
+
182
+ var wr2x_replace = jQuery(evt.target).parent().hasClass('wr2x-fullsize-replace');
183
+ var wr2x_upload = jQuery(evt.target).parent().hasClass('wr2x-fullsize-retina-upload');
184
+
185
+ function wr2x_handleprogress(prg) {
186
+ console.debug("Upload of " + prg.srcElement.filename + ": " + prg.loaded / prg.total * 100 + "%");
187
+ }
188
+
189
+ function wr2x_uploadFile(file, attachmentId, filename) {
190
+ var action = "";
191
+ if (wr2x_replace) {
192
+ action = 'wr2x_replace';
193
+ }
194
+ else if (wr2x_upload) {
195
+ action = 'wr2x_upload';
196
+ }
197
+ else {
198
+ alert("Unknown command. Contact the developer.");
199
+ }
200
+ var data = new FormData();
201
+ data.append('file', file);
202
+ data.append('action', action);
203
+ data.append('attachmentId', attachmentId);
204
+ data.append('isAjax', true);
205
+ data.append('filename', filename);
206
+ data.append('nonce', wr2x_admin_server.nonce[action]);
207
+
208
+ // var data = {
209
+ // action: action,
210
+ // isAjax: true,
211
+ // filename: evt.target.filename,
212
+ // data: form_data,
213
+ // attachmentId: attachmentId
214
+ // };
215
+
216
+ jQuery.ajax({
217
+ type: 'POST',
218
+ url: ajaxurl,
219
+ contentType: false,
220
+ processData: false,
221
+ data: data,
222
+ success: function (response) {
223
+ jQuery('[postid=' + attachmentId + '] td').removeClass('wr2x-loading-file');
224
+ jQuery('[postid=' + attachmentId + '] .wr2x-dragdrop').removeClass('wr2x-hover-drop');
225
+ try {
226
+ var data = jQuery.parseJSON(response);
227
+ }
228
+ catch (e) {
229
+ alert("The server-side returned an abnormal response. Check your PHP error logs and also your browser console (WP Retina 2x will try to display it there).");
230
+ console.debug(response);
231
+ return;
232
+ }
233
+ if (wr2x_replace) {
234
+ var imgSelector = '[postid=' + attachmentId + '] .wr2x-info-thumbnail img';
235
+ jQuery(imgSelector).attr('src', jQuery(imgSelector).attr('src')+'?'+ Math.random());
236
+ }
237
+ if (wr2x_upload) {
238
+ var imgSelector = '[postid=' + attachmentId + '] .wr2x-info-full img';
239
+ jQuery(imgSelector).attr('src', jQuery(imgSelector).attr('src')+'?'+ Math.random());
240
+ }
241
+ if (data.success === false) {
242
+ alert(data.message);
243
+ }
244
+ else {
245
+ if ( wr2x_replace ) {
246
+ wr2x_refresh_media_sizes(data.results);
247
+ }
248
+ else if ( wr2x_upload ) {
249
+ wr2x_refresh_full(data.results);
250
+ }
251
+ }
252
+ },
253
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
254
+ jQuery('[postid=' + attachmentId + '] td').removeClass('wr2x-loading-file');
255
+ jQuery('[postid=' + attachmentId + '] .wr2x-dragdrop').removeClass('wr2x-hover-drop');
256
+ alert("An error occurred on the server-side. Please check your PHP error logs.");
257
+ }
258
+ });
259
+ }
260
+ var file = files[0];
261
+ if (file.size > maxPhpSize) {
262
+ jQuery(this).removeClass('wr2x-hover-drop');
263
+ alert( "Your PHP configuration only allows file upload of a maximum of " + (maxPhpSize / 1000000) + "MB." );
264
+ return;
265
+ }
266
+ var postId = jQuery(evt.target).parents('.wr2x-file-row').attr('postid');
267
+ jQuery(evt.target).parents('td').addClass('wr2x-loading-file');
268
+ wr2x_uploadFile(file, postId, file.name);
269
+ }
270
+
271
+ jQuery(document).ready(function () {
272
+ jQuery('.wr2x-dragdrop').on('dragenter', function (evt) {
273
+ wr2x_stop_propagation(evt);
274
+ jQuery(this).addClass('wr2x-hover-drop');
275
+ });
276
+
277
+ jQuery('.wr2x-dragdrop').on('dragover', function (evt) {
278
+ wr2x_stop_propagation(evt);
279
+ jQuery(this).addClass('wr2x-hover-drop');
280
+ });
281
+
282
+ jQuery('.wr2x-dragdrop').on('dragleave', function (evt) {
283
+ wr2x_stop_propagation(evt);
284
+ jQuery(this).removeClass('wr2x-hover-drop');
285
+ });
286
+
287
+ jQuery('.wr2x-dragdrop').on('dragexit', wr2x_stop_propagation);
288
+
289
+ jQuery('.wr2x-dragdrop').each(function (index, elem) {
290
+ this.addEventListener('drop', wr2x_filedropped);
291
+ });
292
+
293
+ jQuery('.wr2x-info, .wr2x-button-view').on('click', function (evt) {
294
+ jQuery('#meow-modal-info-backdrop').css('display', 'block');
295
+ jQuery('#meow-modal-info .content').html("");
296
+ jQuery('#meow-modal-info .loading').css('display', 'block');
297
+ jQuery('#meow-modal-info').css('display', 'block');
298
+ jQuery('#meow-modal-info').focus();
299
+ var postid = jQuery(evt.target).parents('.wr2x-info').attr('postid');
300
+ if (!postid)
301
+ postid = jQuery(evt.target).parents('.wr2x-file-row').attr('postid');
302
+ wr2x_load_details(postid);
303
+ });
304
+
305
+ jQuery('#meow-modal-info .close, #meow-modal-info-backdrop').on('click', function (evt) {
306
+ jQuery('#meow-modal-info').css('display', 'none');
307
+ jQuery('#meow-modal-info-backdrop').css('display', 'none');
308
+ });
309
+
310
+ jQuery('.wr2x-info-full img').on('click', function (evt) {
311
+ wr2x_delete_full( jQuery(evt.target).parents('.wr2x-file-row').attr('postid') );
312
+ });
313
+
314
+ jQuery('#meow-modal-info').bind('keydown', function (evt) {
315
+ if (evt.keyCode === 27) {
316
+ jQuery('#meow-modal-info').css('display', 'none');
317
+ jQuery('#meow-modal-info-backdrop').css('display', 'none');
318
+ }
319
+ });
320
+ });
trunk/js/debug.js ADDED
@@ -0,0 +1 @@
 
1
+ window.devicePixelRatio = 2;
trunk/js/lazysizes.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ /*! lazysizes - v4.0.3 */
2
+ !function(a,b){var c=b(a,a.document);a.lazySizes=c,"object"==typeof module&&module.exports&&(module.exports=c)}(window,function(a,b){"use strict";if(b.getElementsByClassName){var c,d,e=b.documentElement,f=a.Date,g=a.HTMLPictureElement,h="addEventListener",i="getAttribute",j=a[h],k=a.setTimeout,l=a.requestAnimationFrame||k,m=a.requestIdleCallback,n=/^picture$/i,o=["load","error","lazyincluded","_lazyloaded"],p={},q=Array.prototype.forEach,r=function(a,b){return p[b]||(p[b]=new RegExp("(\\s|^)"+b+"(\\s|$)")),p[b].test(a[i]("class")||"")&&p[b]},s=function(a,b){r(a,b)||a.setAttribute("class",(a[i]("class")||"").trim()+" "+b)},t=function(a,b){var c;(c=r(a,b))&&a.setAttribute("class",(a[i]("class")||"").replace(c," "))},u=function(a,b,c){var d=c?h:"removeEventListener";c&&u(a,b),o.forEach(function(c){a[d](c,b)})},v=function(a,d,e,f,g){var h=b.createEvent("CustomEvent");return e||(e={}),e.instance=c,h.initCustomEvent(d,!f,!g,e),a.dispatchEvent(h),h},w=function(b,c){var e;!g&&(e=a.picturefill||d.pf)?e({reevaluate:!0,elements:[b]}):c&&c.src&&(b.src=c.src)},x=function(a,b){return(getComputedStyle(a,null)||{})[b]},y=function(a,b,c){for(c=c||a.offsetWidth;c<d.minSize&&b&&!a._lazysizesWidth;)c=b.offsetWidth,b=b.parentNode;return c},z=function(){var a,c,d=[],e=[],f=d,g=function(){var b=f;for(f=d.length?e:d,a=!0,c=!1;b.length;)b.shift()();a=!1},h=function(d,e){a&&!e?d.apply(this,arguments):(f.push(d),c||(c=!0,(b.hidden?k:l)(g)))};return h._lsFlush=g,h}(),A=function(a,b){return b?function(){z(a)}:function(){var b=this,c=arguments;z(function(){a.apply(b,c)})}},B=function(a){var b,c=0,e=d.throttleDelay,g=d.ricTimeout,h=function(){b=!1,c=f.now(),a()},i=m&&g>49?function(){m(h,{timeout:g}),g!==d.ricTimeout&&(g=d.ricTimeout)}:A(function(){k(h)},!0);return function(a){var d;(a=a===!0)&&(g=33),b||(b=!0,d=e-(f.now()-c),0>d&&(d=0),a||9>d?i():k(i,d))}},C=function(a){var b,c,d=99,e=function(){b=null,a()},g=function(){var a=f.now()-c;d>a?k(g,d-a):(m||e)(e)};return function(){c=f.now(),b||(b=k(g,d))}};!function(){var b,c={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",errorClass:"lazyerror",autosizesClass:"lazyautosizes",srcAttr:"data-src",srcsetAttr:"data-srcset",sizesAttr:"data-sizes",minSize:40,customMedia:{},init:!0,expFactor:1.5,hFac:.8,loadMode:2,loadHidden:!0,ricTimeout:0,throttleDelay:125};d=a.lazySizesConfig||a.lazysizesConfig||{};for(b in c)b in d||(d[b]=c[b]);a.lazySizesConfig=d,k(function(){d.init&&F()})}();var D=function(){var g,l,m,o,p,y,D,F,G,H,I,J,K,L,M=/^img$/i,N=/^iframe$/i,O="onscroll"in a&&!/glebot/.test(navigator.userAgent),P=0,Q=0,R=0,S=-1,T=function(a){R--,a&&a.target&&u(a.target,T),(!a||0>R||!a.target)&&(R=0)},U=function(a,c){var d,f=a,g="hidden"==x(b.body,"visibility")||"hidden"!=x(a,"visibility");for(F-=c,I+=c,G-=c,H+=c;g&&(f=f.offsetParent)&&f!=b.body&&f!=e;)g=(x(f,"opacity")||1)>0,g&&"visible"!=x(f,"overflow")&&(d=f.getBoundingClientRect(),g=H>d.left&&G<d.right&&I>d.top-1&&F<d.bottom+1);return g},V=function(){var a,f,h,j,k,m,n,p,q,r=c.elements;if((o=d.loadMode)&&8>R&&(a=r.length)){f=0,S++,null==K&&("expand"in d||(d.expand=e.clientHeight>500&&e.clientWidth>500?500:370),J=d.expand,K=J*d.expFactor),K>Q&&1>R&&S>2&&o>2&&!b.hidden?(Q=K,S=0):Q=o>1&&S>1&&6>R?J:P;for(;a>f;f++)if(r[f]&&!r[f]._lazyRace)if(O)if((p=r[f][i]("data-expand"))&&(m=1*p)||(m=Q),q!==m&&(y=innerWidth+m*L,D=innerHeight+m,n=-1*m,q=m),h=r[f].getBoundingClientRect(),(I=h.bottom)>=n&&(F=h.top)<=D&&(H=h.right)>=n*L&&(G=h.left)<=y&&(I||H||G||F)&&(d.loadHidden||"hidden"!=x(r[f],"visibility"))&&(l&&3>R&&!p&&(3>o||4>S)||U(r[f],m))){if(ba(r[f]),k=!0,R>9)break}else!k&&l&&!j&&4>R&&4>S&&o>2&&(g[0]||d.preloadAfterLoad)&&(g[0]||!p&&(I||H||G||F||"auto"!=r[f][i](d.sizesAttr)))&&(j=g[0]||r[f]);else ba(r[f]);j&&!k&&ba(j)}},W=B(V),X=function(a){s(a.target,d.loadedClass),t(a.target,d.loadingClass),u(a.target,Z),v(a.target,"lazyloaded")},Y=A(X),Z=function(a){Y({target:a.target})},$=function(a,b){try{a.contentWindow.location.replace(b)}catch(c){a.src=b}},_=function(a){var b,c=a[i](d.srcsetAttr);(b=d.customMedia[a[i]("data-media")||a[i]("media")])&&a.setAttribute("media",b),c&&a.setAttribute("srcset",c)},aa=A(function(a,b,c,e,f){var g,h,j,l,o,p;(o=v(a,"lazybeforeunveil",b)).defaultPrevented||(e&&(c?s(a,d.autosizesClass):a.setAttribute("sizes",e)),h=a[i](d.srcsetAttr),g=a[i](d.srcAttr),f&&(j=a.parentNode,l=j&&n.test(j.nodeName||"")),p=b.firesLoad||"src"in a&&(h||g||l),o={target:a},p&&(u(a,T,!0),clearTimeout(m),m=k(T,2500),s(a,d.loadingClass),u(a,Z,!0)),l&&q.call(j.getElementsByTagName("source"),_),h?a.setAttribute("srcset",h):g&&!l&&(N.test(a.nodeName)?$(a,g):a.src=g),f&&(h||l)&&w(a,{src:g})),a._lazyRace&&delete a._lazyRace,t(a,d.lazyClass),z(function(){(!p||a.complete&&a.naturalWidth>1)&&(p?T(o):R--,X(o))},!0)}),ba=function(a){var b,c=M.test(a.nodeName),e=c&&(a[i](d.sizesAttr)||a[i]("sizes")),f="auto"==e;(!f&&l||!c||!a[i]("src")&&!a.srcset||a.complete||r(a,d.errorClass)||!r(a,d.lazyClass))&&(b=v(a,"lazyunveilread").detail,f&&E.updateElem(a,!0,a.offsetWidth),a._lazyRace=!0,R++,aa(a,b,f,e,c))},ca=function(){if(!l){if(f.now()-p<999)return void k(ca,999);var a=C(function(){d.loadMode=3,W()});l=!0,d.loadMode=3,W(),j("scroll",function(){3==d.loadMode&&(d.loadMode=2),a()},!0)}};return{_:function(){p=f.now(),c.elements=b.getElementsByClassName(d.lazyClass),g=b.getElementsByClassName(d.lazyClass+" "+d.preloadClass),L=d.hFac,j("scroll",W,!0),j("resize",W,!0),a.MutationObserver?new MutationObserver(W).observe(e,{childList:!0,subtree:!0,attributes:!0}):(e[h]("DOMNodeInserted",W,!0),e[h]("DOMAttrModified",W,!0),setInterval(W,999)),j("hashchange",W,!0),["focus","mouseover","click","load","transitionend","animationend","webkitAnimationEnd"].forEach(function(a){b[h](a,W,!0)}),/d$|^c/.test(b.readyState)?ca():(j("load",ca),b[h]("DOMContentLoaded",W),k(ca,2e4)),c.elements.length?(V(),z._lsFlush()):W()},checkElems:W,unveil:ba}}(),E=function(){var a,c=A(function(a,b,c,d){var e,f,g;if(a._lazysizesWidth=d,d+="px",a.setAttribute("sizes",d),n.test(b.nodeName||""))for(e=b.getElementsByTagName("source"),f=0,g=e.length;g>f;f++)e[f].setAttribute("sizes",d);c.detail.dataAttr||w(a,c.detail)}),e=function(a,b,d){var e,f=a.parentNode;f&&(d=y(a,f,d),e=v(a,"lazybeforesizes",{width:d,dataAttr:!!b}),e.defaultPrevented||(d=e.detail.width,d&&d!==a._lazysizesWidth&&c(a,f,e,d)))},f=function(){var b,c=a.length;if(c)for(b=0;c>b;b++)e(a[b])},g=C(f);return{_:function(){a=b.getElementsByClassName(d.autosizesClass),j("resize",g)},checkElems:g,updateElem:e}}(),F=function(){F.i||(F.i=!0,E._(),D._())};return c={cfg:d,autoSizer:E,loader:D,init:F,uP:w,aC:s,rC:t,hC:r,fire:v,gW:y,rAF:z}}});
trunk/js/picturefill.min.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ /*! picturefill - v3.0.2 - 2016-02-12
2
+ * https://scottjehl.github.io/picturefill/
3
+ * Copyright (c) 2016 https://github.com/scottjehl/picturefill/blob/master/Authors.txt; Licensed MIT
4
+ */
5
+ !function(a){var b=navigator.userAgent;a.HTMLPictureElement&&/ecko/.test(b)&&b.match(/rv\:(\d+)/)&&RegExp.$1<45&&addEventListener("resize",function(){var b,c=document.createElement("source"),d=function(a){var b,d,e=a.parentNode;"PICTURE"===e.nodeName.toUpperCase()?(b=c.cloneNode(),e.insertBefore(b,e.firstElementChild),setTimeout(function(){e.removeChild(b)})):(!a._pfLastSize||a.offsetWidth>a._pfLastSize)&&(a._pfLastSize=a.offsetWidth,d=a.sizes,a.sizes+=",100vw",setTimeout(function(){a.sizes=d}))},e=function(){var a,b=document.querySelectorAll("picture > img, img[srcset][sizes]");for(a=0;a<b.length;a++)d(b[a])},f=function(){clearTimeout(b),b=setTimeout(e,99)},g=a.matchMedia&&matchMedia("(orientation: landscape)"),h=function(){f(),g&&g.addListener&&g.addListener(f)};return c.srcset="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",/^[c|i]|d$/.test(document.readyState||"")?h():document.addEventListener("DOMContentLoaded",h),f}())}(window),function(a,b,c){"use strict";function d(a){return" "===a||" "===a||"\n"===a||"\f"===a||"\r"===a}function e(b,c){var d=new a.Image;return d.onerror=function(){A[b]=!1,ba()},d.onload=function(){A[b]=1===d.width,ba()},d.src=c,"pending"}function f(){M=!1,P=a.devicePixelRatio,N={},O={},s.DPR=P||1,Q.width=Math.max(a.innerWidth||0,z.clientWidth),Q.height=Math.max(a.innerHeight||0,z.clientHeight),Q.vw=Q.width/100,Q.vh=Q.height/100,r=[Q.height,Q.width,P].join("-"),Q.em=s.getEmValue(),Q.rem=Q.em}function g(a,b,c,d){var e,f,g,h;return"saveData"===B.algorithm?a>2.7?h=c+1:(f=b-c,e=Math.pow(a-.6,1.5),g=f*e,d&&(g+=.1*e),h=a+g):h=c>1?Math.sqrt(a*b):a,h>c}function h(a){var b,c=s.getSet(a),d=!1;"pending"!==c&&(d=r,c&&(b=s.setRes(c),s.applySetCandidate(b,a))),a[s.ns].evaled=d}function i(a,b){return a.res-b.res}function j(a,b,c){var d;return!c&&b&&(c=a[s.ns].sets,c=c&&c[c.length-1]),d=k(b,c),d&&(b=s.makeUrl(b),a[s.ns].curSrc=b,a[s.ns].curCan=d,d.res||aa(d,d.set.sizes)),d}function k(a,b){var c,d,e;if(a&&b)for(e=s.parseSet(b),a=s.makeUrl(a),c=0;c<e.length;c++)if(a===s.makeUrl(e[c].url)){d=e[c];break}return d}function l(a,b){var c,d,e,f,g=a.getElementsByTagName("source");for(c=0,d=g.length;d>c;c++)e=g[c],e[s.ns]=!0,f=e.getAttribute("srcset"),f&&b.push({srcset:f,media:e.getAttribute("media"),type:e.getAttribute("type"),sizes:e.getAttribute("sizes")})}function m(a,b){function c(b){var c,d=b.exec(a.substring(m));return d?(c=d[0],m+=c.length,c):void 0}function e(){var a,c,d,e,f,i,j,k,l,m=!1,o={};for(e=0;e<h.length;e++)f=h[e],i=f[f.length-1],j=f.substring(0,f.length-1),k=parseInt(j,10),l=parseFloat(j),X.test(j)&&"w"===i?((a||c)&&(m=!0),0===k?m=!0:a=k):Y.test(j)&&"x"===i?((a||c||d)&&(m=!0),0>l?m=!0:c=l):X.test(j)&&"h"===i?((d||c)&&(m=!0),0===k?m=!0:d=k):m=!0;m||(o.url=g,a&&(o.w=a),c&&(o.d=c),d&&(o.h=d),d||c||a||(o.d=1),1===o.d&&(b.has1x=!0),o.set=b,n.push(o))}function f(){for(c(T),i="",j="in descriptor";;){if(k=a.charAt(m),"in descriptor"===j)if(d(k))i&&(h.push(i),i="",j="after descriptor");else{if(","===k)return m+=1,i&&h.push(i),void e();if("("===k)i+=k,j="in parens";else{if(""===k)return i&&h.push(i),void e();i+=k}}else if("in parens"===j)if(")"===k)i+=k,j="in descriptor";else{if(""===k)return h.push(i),void e();i+=k}else if("after descriptor"===j)if(d(k));else{if(""===k)return void e();j="in descriptor",m-=1}m+=1}}for(var g,h,i,j,k,l=a.length,m=0,n=[];;){if(c(U),m>=l)return n;g=c(V),h=[],","===g.slice(-1)?(g=g.replace(W,""),e()):f()}}function n(a){function b(a){function b(){f&&(g.push(f),f="")}function c(){g[0]&&(h.push(g),g=[])}for(var e,f="",g=[],h=[],i=0,j=0,k=!1;;){if(e=a.charAt(j),""===e)return b(),c(),h;if(k){if("*"===e&&"/"===a[j+1]){k=!1,j+=2,b();continue}j+=1}else{if(d(e)){if(a.charAt(j-1)&&d(a.charAt(j-1))||!f){j+=1;continue}if(0===i){b(),j+=1;continue}e=" "}else if("("===e)i+=1;else if(")"===e)i-=1;else{if(","===e){b(),c(),j+=1;continue}if("/"===e&&"*"===a.charAt(j+1)){k=!0,j+=2;continue}}f+=e,j+=1}}}function c(a){return k.test(a)&&parseFloat(a)>=0?!0:l.test(a)?!0:"0"===a||"-0"===a||"+0"===a?!0:!1}var e,f,g,h,i,j,k=/^(?:[+-]?[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?(?:ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmin|vmax|vw)$/i,l=/^calc\((?:[0-9a-z \.\+\-\*\/\(\)]+)\)$/i;for(f=b(a),g=f.length,e=0;g>e;e++)if(h=f[e],i=h[h.length-1],c(i)){if(j=i,h.pop(),0===h.length)return j;if(h=h.join(" "),s.matchesMedia(h))return j}return"100vw"}b.createElement("picture");var o,p,q,r,s={},t=!1,u=function(){},v=b.createElement("img"),w=v.getAttribute,x=v.setAttribute,y=v.removeAttribute,z=b.documentElement,A={},B={algorithm:""},C="data-pfsrc",D=C+"set",E=navigator.userAgent,F=/rident/.test(E)||/ecko/.test(E)&&E.match(/rv\:(\d+)/)&&RegExp.$1>35,G="currentSrc",H=/\s+\+?\d+(e\d+)?w/,I=/(\([^)]+\))?\s*(.+)/,J=a.picturefillCFG,K="position:absolute;left:0;visibility:hidden;display:block;padding:0;border:none;font-size:1em;width:1em;overflow:hidden;clip:rect(0px, 0px, 0px, 0px)",L="font-size:100%!important;",M=!0,N={},O={},P=a.devicePixelRatio,Q={px:1,"in":96},R=b.createElement("a"),S=!1,T=/^[ \t\n\r\u000c]+/,U=/^[, \t\n\r\u000c]+/,V=/^[^ \t\n\r\u000c]+/,W=/[,]+$/,X=/^\d+$/,Y=/^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/,Z=function(a,b,c,d){a.addEventListener?a.addEventListener(b,c,d||!1):a.attachEvent&&a.attachEvent("on"+b,c)},$=function(a){var b={};return function(c){return c in b||(b[c]=a(c)),b[c]}},_=function(){var a=/^([\d\.]+)(em|vw|px)$/,b=function(){for(var a=arguments,b=0,c=a[0];++b in a;)c=c.replace(a[b],a[++b]);return c},c=$(function(a){return"return "+b((a||"").toLowerCase(),/\band\b/g,"&&",/,/g,"||",/min-([a-z-\s]+):/g,"e.$1>=",/max-([a-z-\s]+):/g,"e.$1<=",/calc([^)]+)/g,"($1)",/(\d+[\.]*[\d]*)([a-z]+)/g,"($1 * e.$2)",/^(?!(e.[a-z]|[0-9\.&=|><\+\-\*\(\)\/])).*/gi,"")+";"});return function(b,d){var e;if(!(b in N))if(N[b]=!1,d&&(e=b.match(a)))N[b]=e[1]*Q[e[2]];else try{N[b]=new Function("e",c(b))(Q)}catch(f){}return N[b]}}(),aa=function(a,b){return a.w?(a.cWidth=s.calcListLength(b||"100vw"),a.res=a.w/a.cWidth):a.res=a.d,a},ba=function(a){if(t){var c,d,e,f=a||{};if(f.elements&&1===f.elements.nodeType&&("IMG"===f.elements.nodeName.toUpperCase()?f.elements=[f.elements]:(f.context=f.elements,f.elements=null)),c=f.elements||s.qsa(f.context||b,f.reevaluate||f.reselect?s.sel:s.selShort),e=c.length){for(s.setupRun(f),S=!0,d=0;e>d;d++)s.fillImg(c[d],f);s.teardownRun(f)}}};o=a.console&&console.warn?function(a){console.warn(a)}:u,G in v||(G="src"),A["image/jpeg"]=!0,A["image/gif"]=!0,A["image/png"]=!0,A["image/svg+xml"]=b.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image","1.1"),s.ns=("pf"+(new Date).getTime()).substr(0,9),s.supSrcset="srcset"in v,s.supSizes="sizes"in v,s.supPicture=!!a.HTMLPictureElement,s.supSrcset&&s.supPicture&&!s.supSizes&&!function(a){v.srcset="data:,a",a.src="data:,a",s.supSrcset=v.complete===a.complete,s.supPicture=s.supSrcset&&s.supPicture}(b.createElement("img")),s.supSrcset&&!s.supSizes?!function(){var a="data:image/gif;base64,R0lGODlhAgABAPAAAP///wAAACH5BAAAAAAALAAAAAACAAEAAAICBAoAOw==",c="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",d=b.createElement("img"),e=function(){var a=d.width;2===a&&(s.supSizes=!0),q=s.supSrcset&&!s.supSizes,t=!0,setTimeout(ba)};d.onload=e,d.onerror=e,d.setAttribute("sizes","9px"),d.srcset=c+" 1w,"+a+" 9w",d.src=c}():t=!0,s.selShort="picture>img,img[srcset]",s.sel=s.selShort,s.cfg=B,s.DPR=P||1,s.u=Q,s.types=A,s.setSize=u,s.makeUrl=$(function(a){return R.href=a,R.href}),s.qsa=function(a,b){return"querySelector"in a?a.querySelectorAll(b):[]},s.matchesMedia=function(){return a.matchMedia&&(matchMedia("(min-width: 0.1em)")||{}).matches?s.matchesMedia=function(a){return!a||matchMedia(a).matches}:s.matchesMedia=s.mMQ,s.matchesMedia.apply(this,arguments)},s.mMQ=function(a){return a?_(a):!0},s.calcLength=function(a){var b=_(a,!0)||!1;return 0>b&&(b=!1),b},s.supportsType=function(a){return a?A[a]:!0},s.parseSize=$(function(a){var b=(a||"").match(I);return{media:b&&b[1],length:b&&b[2]}}),s.parseSet=function(a){return a.cands||(a.cands=m(a.srcset,a)),a.cands},s.getEmValue=function(){var a;if(!p&&(a=b.body)){var c=b.createElement("div"),d=z.style.cssText,e=a.style.cssText;c.style.cssText=K,z.style.cssText=L,a.style.cssText=L,a.appendChild(c),p=c.offsetWidth,a.removeChild(c),p=parseFloat(p,10),z.style.cssText=d,a.style.cssText=e}return p||16},s.calcListLength=function(a){if(!(a in O)||B.uT){var b=s.calcLength(n(a));O[a]=b?b:Q.width}return O[a]},s.setRes=function(a){var b;if(a){b=s.parseSet(a);for(var c=0,d=b.length;d>c;c++)aa(b[c],a.sizes)}return b},s.setRes.res=aa,s.applySetCandidate=function(a,b){if(a.length){var c,d,e,f,h,k,l,m,n,o=b[s.ns],p=s.DPR;if(k=o.curSrc||b[G],l=o.curCan||j(b,k,a[0].set),l&&l.set===a[0].set&&(n=F&&!b.complete&&l.res-.1>p,n||(l.cached=!0,l.res>=p&&(h=l))),!h)for(a.sort(i),f=a.length,h=a[f-1],d=0;f>d;d++)if(c=a[d],c.res>=p){e=d-1,h=a[e]&&(n||k!==s.makeUrl(c.url))&&g(a[e].res,c.res,p,a[e].cached)?a[e]:c;break}h&&(m=s.makeUrl(h.url),o.curSrc=m,o.curCan=h,m!==k&&s.setSrc(b,h),s.setSize(b))}},s.setSrc=function(a,b){var c;a.src=b.url,"image/svg+xml"===b.set.type&&(c=a.style.width,a.style.width=a.offsetWidth+1+"px",a.offsetWidth+1&&(a.style.width=c))},s.getSet=function(a){var b,c,d,e=!1,f=a[s.ns].sets;for(b=0;b<f.length&&!e;b++)if(c=f[b],c.srcset&&s.matchesMedia(c.media)&&(d=s.supportsType(c.type))){"pending"===d&&(c=d),e=c;break}return e},s.parseSets=function(a,b,d){var e,f,g,h,i=b&&"PICTURE"===b.nodeName.toUpperCase(),j=a[s.ns];(j.src===c||d.src)&&(j.src=w.call(a,"src"),j.src?x.call(a,C,j.src):y.call(a,C)),(j.srcset===c||d.srcset||!s.supSrcset||a.srcset)&&(e=w.call(a,"srcset"),j.srcset=e,h=!0),j.sets=[],i&&(j.pic=!0,l(b,j.sets)),j.srcset?(f={srcset:j.srcset,sizes:w.call(a,"sizes")},j.sets.push(f),g=(q||j.src)&&H.test(j.srcset||""),g||!j.src||k(j.src,f)||f.has1x||(f.srcset+=", "+j.src,f.cands.push({url:j.src,d:1,set:f}))):j.src&&j.sets.push({srcset:j.src,sizes:null}),j.curCan=null,j.curSrc=c,j.supported=!(i||f&&!s.supSrcset||g&&!s.supSizes),h&&s.supSrcset&&!j.supported&&(e?(x.call(a,D,e),a.srcset=""):y.call(a,D)),j.supported&&!j.srcset&&(!j.src&&a.src||a.src!==s.makeUrl(j.src))&&(null===j.src?a.removeAttribute("src"):a.src=j.src),j.parsed=!0},s.fillImg=function(a,b){var c,d=b.reselect||b.reevaluate;a[s.ns]||(a[s.ns]={}),c=a[s.ns],(d||c.evaled!==r)&&((!c.parsed||b.reevaluate)&&s.parseSets(a,a.parentNode,b),c.supported?c.evaled=r:h(a))},s.setupRun=function(){(!S||M||P!==a.devicePixelRatio)&&f()},s.supPicture?(ba=u,s.fillImg=u):!function(){var c,d=a.attachEvent?/d$|^c/:/d$|^c|^i/,e=function(){var a=b.readyState||"";f=setTimeout(e,"loading"===a?200:999),b.body&&(s.fillImgs(),c=c||d.test(a),c&&clearTimeout(f))},f=setTimeout(e,b.body?9:99),g=function(a,b){var c,d,e=function(){var f=new Date-d;b>f?c=setTimeout(e,b-f):(c=null,a())};return function(){d=new Date,c||(c=setTimeout(e,b))}},h=z.clientHeight,i=function(){M=Math.max(a.innerWidth||0,z.clientWidth)!==Q.width||z.clientHeight!==h,h=z.clientHeight,M&&s.fillImgs()};Z(a,"resize",g(i,99)),Z(b,"readystatechange",e)}(),s.picturefill=ba,s.fillImgs=ba,s.teardownRun=u,ba._=s,a.picturefillCFG={pf:s,push:function(a){var b=a.shift();"function"==typeof s[b]?s[b].apply(s,a):(B[b]=a[0],S&&s.fillImgs({reselect:!0}))}};for(;J&&J.length;)a.picturefillCFG.push(J.shift());a.picturefill=ba,"object"==typeof module&&"object"==typeof module.exports?module.exports=ba:"function"==typeof define&&define.amd&&define("picturefill",function(){return ba}),s.supPicture||(A["image/webp"]=e("image/webp","data:image/webp;base64,UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAABBxAR/Q9ERP8DAABWUDggGAAAADABAJ0BKgEAAQADADQlpAADcAD++/1QAA=="))}(window,document);
trunk/js/retina-cookie.js ADDED
@@ -0,0 +1 @@
 
1
+ document.cookie='devicePixelRatio='+((window.devicePixelRatio === undefined) ? 1 : window.devicePixelRatio)+'; path=/';
trunk/js/retina.js ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * Retina.js v1.4.0
3
+ *
4
+ * Copyright 2016 Imulus, LLC
5
+ * Released under the MIT license
6
+ *
7
+ * Retina.js is an open source script that makes it easy to serve
8
+ * high-resolution images to devices with retina displays.
9
+ */
10
+
11
+ (function() {
12
+ var root = (typeof exports === 'undefined' ? window : exports);
13
+ var config = {
14
+ // An option to choose a suffix for 2x images
15
+ retinaImageSuffix: '@2x',
16
+
17
+ // Ensure Content-Type is an image before trying to load @2x image
18
+ // https://github.com/imulus/retinajs/pull/45)
19
+ check_mime_type: true,
20
+
21
+ // An option to select some of the img tags to make their image retina.
22
+ // https://github.com/imulus/retinajs/commit/e7930be
23
+ retinaImgTagSelector: 'body img',
24
+ // Resize high-resolution images to original image's pixel dimensions
25
+ // https://github.com/imulus/retinajs/issues/8
26
+ force_original_dimensions: true
27
+ };
28
+
29
+ function Retina() {
30
+ }
31
+
32
+ root.Retina = Retina;
33
+
34
+ Retina.configure = function(options) {
35
+ if (options === null) {
36
+ options = {};
37
+ }
38
+
39
+ for (var prop in options) {
40
+ if (options.hasOwnProperty(prop)) {
41
+ config[prop] = options[prop];
42
+ }
43
+ }
44
+ };
45
+
46
+ Retina.init = function(context) {
47
+ if (context === null) {
48
+ context = root;
49
+ }
50
+ context.addEventListener('load', function() {
51
+ // https://github.com/imulus/retinajs/commit/e7930be
52
+ var images = document.querySelectorAll(config.retinaImgTagSelector),
53
+ retinaImages = [],
54
+ i,
55
+ image;
56
+ for (i = 0; i < images.length; i += 1) {
57
+ image = images[i];
58
+
59
+ if (!image.getAttributeNode('data-no-retina')) {
60
+ if (image.src) {
61
+ retinaImages.push(new RetinaImage(image));
62
+ }
63
+ }
64
+ }
65
+ });
66
+ };
67
+
68
+ Retina.isRetina = function() {
69
+ var mediaQuery = '(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)';
70
+
71
+ if (root.devicePixelRatio > 1) {
72
+ return true;
73
+ }
74
+
75
+ if (root.matchMedia && root.matchMedia(mediaQuery).matches) {
76
+ return true;
77
+ }
78
+
79
+ return false;
80
+ };
81
+
82
+
83
+ var regexMatch = /\.[\w\?=]+$/;
84
+ function suffixReplace(match) {
85
+ return config.retinaImageSuffix + match;
86
+ }
87
+
88
+ function RetinaImagePath(path, at_2x_path) {
89
+ this.path = path || '';
90
+ if (typeof at_2x_path !== 'undefined' && at_2x_path !== null) {
91
+ this.at_2x_path = at_2x_path;
92
+ this.perform_check = false;
93
+ } else {
94
+ if (undefined !== document.createElement) {
95
+ var locationObject = document.createElement('a');
96
+ locationObject.href = this.path;
97
+ locationObject.pathname = locationObject.pathname.replace(regexMatch, suffixReplace);
98
+ this.at_2x_path = locationObject.href;
99
+ } else {
100
+ var parts = this.path.split('?');
101
+ parts[0] = parts[0].replace(regexMatch, suffixReplace);
102
+ this.at_2x_path = parts.join('?');
103
+ }
104
+ this.perform_check = true;
105
+ }
106
+ }
107
+
108
+ root.RetinaImagePath = RetinaImagePath;
109
+
110
+ RetinaImagePath.confirmed_paths = [];
111
+
112
+ RetinaImagePath.prototype.is_external = function() {
113
+ return !!(this.path.match(/^(https?\:|\/\/)/i) && !this.path.match('//' + document.domain));
114
+ };
115
+
116
+ RetinaImagePath.prototype.check_2x_variant = function(callback) {
117
+ var http,
118
+ that = this;
119
+ if (!this.perform_check && typeof this.at_2x_path !== 'undefined' && this.at_2x_path !== null) {
120
+ return callback(true);
121
+ } else if (this.at_2x_path in RetinaImagePath.confirmed_paths) {
122
+ return callback(true);
123
+ } else if (this.is_external()) {
124
+ return callback(false);
125
+ } else {
126
+ http = new XMLHttpRequest();
127
+ http.open('HEAD', this.at_2x_path);
128
+ http.onreadystatechange = function() {
129
+ if (http.readyState !== 4) {
130
+ return callback(false);
131
+ }
132
+
133
+ if (http.status >= 200 && http.status <= 399) {
134
+ if (config.check_mime_type) {
135
+ var type = http.getResponseHeader('Content-Type');
136
+ if (type === null || !type.match(/^image/i)) {
137
+ return callback(false);
138
+ }
139
+ }
140
+
141
+ RetinaImagePath.confirmed_paths.push(that.at_2x_path);
142
+ return callback(true);
143
+ } else {
144
+ return callback(false);
145
+ }
146
+ };
147
+ http.send();
148
+ }
149
+ };
150
+
151
+ function RetinaImage(el) {
152
+ this.el = el;
153
+ this.path = new RetinaImagePath(this.el.getAttribute('src'), this.el.getAttribute('data-at2x'));
154
+ var that = this;
155
+ this.path.check_2x_variant(function(hasVariant) {
156
+ if (hasVariant) {
157
+ that.swap();
158
+ }
159
+ });
160
+ }
161
+
162
+ root.RetinaImage = RetinaImage;
163
+
164
+ RetinaImage.prototype.swap = function(path) {
165
+ if (typeof path === 'undefined') {
166
+ path = this.path.at_2x_path;
167
+ }
168
+
169
+ var that = this;
170
+ function load() {
171
+ if (!that.el.complete) {
172
+ setTimeout(load, 5);
173
+ } else {
174
+ if (config.force_original_dimensions) {
175
+ if (that.el.offsetWidth === 0 && that.el.offsetHeight === 0) {
176
+ that.el.setAttribute('width', that.el.naturalWidth);
177
+ that.el.setAttribute('height', that.el.naturalHeight);
178
+ } else {
179
+ that.el.setAttribute('width', that.el.offsetWidth);
180
+ that.el.setAttribute('height', that.el.offsetHeight);
181
+ }
182
+ }
183
+
184
+ that.el.setAttribute('src', path);
185
+ }
186
+ }
187
+ load();
188
+ };
189
+
190
+
191
+ if (Retina.isRetina()) {
192
+ Retina.init(root);
193
+ }
194
+ })();
trunk/js/retina.min.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * Retina.js v1.4.0
3
+ *
4
+ * Copyright 2016 Imulus, LLC
5
+ * Released under the MIT license
6
+ *
7
+ * Retina.js is an open source script that makes it easy to serve
8
+ * high-resolution images to devices with retina displays.
9
+ */
10
+ !function(){function a(){}function b(a){return f.retinaImageSuffix+a}function c(a,c){if(this.path=a||"","undefined"!=typeof c&&null!==c)this.at_2x_path=c,this.perform_check=!1;else{if(void 0!==document.createElement){var d=document.createElement("a");d.href=this.path,d.pathname=d.pathname.replace(g,b),this.at_2x_path=d.href}else{var e=this.path.split("?");e[0]=e[0].replace(g,b),this.at_2x_path=e.join("?")}this.perform_check=!0}}function d(a){this.el=a,this.path=new c(this.el.getAttribute("src"),this.el.getAttribute("data-at2x"));var b=this;this.path.check_2x_variant(function(a){a&&b.swap()})}var e="undefined"==typeof exports?window:exports,f={retinaImageSuffix:"@2x",check_mime_type:!0,retinaImgTagSelector:"body img",force_original_dimensions:!0};e.Retina=a,a.configure=function(a){null===a&&(a={});for(var b in a)a.hasOwnProperty(b)&&(f[b]=a[b])},a.init=function(a){null===a&&(a=e),a.addEventListener("load",function(){var a,b,c=document.querySelectorAll(f.retinaImgTagSelector),e=[];for(a=0;a<c.length;a+=1)b=c[a],b.getAttributeNode("data-no-retina")||b.src&&e.push(new d(b))})},a.isRetina=function(){var a="(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)";return e.devicePixelRatio>1?!0:!(!e.matchMedia||!e.matchMedia(a).matches)};var g=/\.[\w\?=]+$/;e.RetinaImagePath=c,c.confirmed_paths=[],c.prototype.is_external=function(){return!(!this.path.match(/^(https?\:|\/\/)/i)||this.path.match("//"+document.domain))},c.prototype.check_2x_variant=function(a){var b,d=this;return this.perform_check||"undefined"==typeof this.at_2x_path||null===this.at_2x_path?this.at_2x_path in c.confirmed_paths?a(!0):this.is_external()?a(!1):(b=new XMLHttpRequest,b.open("HEAD",this.at_2x_path),b.onreadystatechange=function(){if(4!==b.readyState)return a(!1);if(b.status>=200&&b.status<=399){if(f.check_mime_type){var e=b.getResponseHeader("Content-Type");if(null===e||!e.match(/^image/i))return a(!1)}return c.confirmed_paths.push(d.at_2x_path),a(!0)}return a(!1)},b.send(),void 0):a(!0)},e.RetinaImage=d,d.prototype.swap=function(a){function b(){c.el.complete?(f.force_original_dimensions&&(0===c.el.offsetWidth&&0===c.el.offsetHeight?(c.el.setAttribute("width",c.el.naturalWidth),c.el.setAttribute("height",c.el.naturalHeight)):(c.el.setAttribute("width",c.el.offsetWidth),c.el.setAttribute("height",c.el.offsetHeight))),c.el.setAttribute("src",a)):setTimeout(b,5)}"undefined"==typeof a&&(a=this.path.at_2x_path);var c=this;b()},a.isRetina()&&a.init(e)}();
trunk/languages/wp-retina-2x-de_DE.mo ADDED
Binary file
trunk/languages/wp-retina-2x-de_DE.po ADDED
@@ -0,0 +1,359 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: WP Retina 2x\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2013-08-02 11:53+0900\n"
6
+ "PO-Revision-Date: 2013-08-02 11:54+0900\n"
7
+ "Last-Translator: Jordy Meow <work@meow.fr>\n"
8
+ "Language-Team: Jordy Meow <work@meow.fr>\n"
9
+ "Language: fr_FR\n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Poedit-KeywordsList: _e;__\n"
14
+ "X-Poedit-Basepath: ../\n"
15
+ "X-Generator: Poedit 1.5.5\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: wr2x_ajax.php:39
20
+ msgid "Done. Please <a href='javascript:history.go(0)'>refresh</a> this page."
21
+ msgstr ""
22
+ "Erledigt. Bitte <a href='javascript:history.go(0)'>lade die Seite neu</a>"
23
+
24
+ #: wr2x_ajax.php:42
25
+ msgid ""
26
+ "Done. You might want to <a href='?page=wp-"
27
+ "retina-2x&view=issues&refresh=true'>refresh</a> the issues."
28
+ msgstr ""
29
+ "Erledigt. Du solltest die Meldungen <a href='?page=wp-"
30
+ "retina-2x&view=issues&refresh=true'>neu laden</a>."
31
+
32
+ #: wr2x_ajax.php:52 wr2x_ajax.php:103
33
+ msgid "Please wait..."
34
+ msgstr "Bitte warten…"
35
+
36
+ #: wr2x_ajax.php:60
37
+ msgid "Nothing to do ;)"
38
+ msgstr "Es gibt nichts zu tun ;-)"
39
+
40
+ #: wr2x_ajax.php:110 wr2x_retina-dashboard.php:247
41
+ msgid "GENERATE"
42
+ msgstr "Generieren"
43
+
44
+ #: wr2x_ajax.php:258 wr2x_ajax.php:287
45
+ msgid "The attachment ID is missing."
46
+ msgstr ""
47
+
48
+ #: wr2x_ajax.php:275
49
+ msgid "Retina files deleted."
50
+ msgstr "Retina Dateien gelöscht."
51
+
52
+ #: wr2x_ajax.php:305
53
+ msgid "Retina files generated."
54
+ msgstr "Retina Dateien erstellt."
55
+
56
+ #: wr2x_ajax.php:316
57
+ msgid "You do not have permission to upload files."
58
+ msgstr "Du hast keine Berechtigung um Dateien hochzuladen."
59
+
60
+ #: wr2x_ajax.php:332
61
+ #, fuzzy
62
+ msgid "You don't have the rights to use a temporary directory."
63
+ msgstr "Du hast keine Berechtigung um Dateien hochzuladen."
64
+
65
+ #: wr2x_ajax.php:337
66
+ msgid "The temporary directory could not be created."
67
+ msgstr ""
68
+
69
+ #: wr2x_ajax.php:352
70
+ msgid "The file is not an image or the upload went wrong."
71
+ msgstr ""
72
+ "Das Hochladen ist fehlgeschlagen. Womöglich ist die ausgewählte Datei kein "
73
+ "Bild."
74
+
75
+ #: wr2x_ajax.php:362
76
+ msgid "You cannot use this file (wrong extension? wrong type?)."
77
+ msgstr "Du kannst diese Datei nicht hochladen (falscher Dateityp?)."
78
+
79
+ #: wr2x_ajax.php:411
80
+ msgid "Replaced successfully."
81
+ msgstr "Ersetzen erfolgreich."
82
+
83
+ #: wr2x_retina-dashboard.php:19
84
+ msgid "Retina images"
85
+ msgstr "Retina Bilder"
86
+
87
+ #: wr2x_retina-dashboard.php:20
88
+ #, php-format
89
+ msgid "Retina %s"
90
+ msgstr "Retina %s"
91
+
92
+ #: wr2x_retina-dashboard.php:132
93
+ msgid "Generate"
94
+ msgstr "Generieren"
95
+
96
+ #: wr2x_retina-dashboard.php:146
97
+ msgid "Delete all @2x"
98
+ msgstr "Alle (@2x) Dateien löschen."
99
+
100
+ #: wr2x_retina-dashboard.php:149
101
+ msgid "Refresh issues"
102
+ msgstr "Neu Laden."
103
+
104
+ #: wr2x_retina-dashboard.php:159
105
+ msgid "Issues has been refreshed."
106
+ msgstr "Alle Problemmeldungen wurden neu geladen."
107
+
108
+ #: wr2x_retina-dashboard.php:164
109
+ msgid ""
110
+ "This screen allows you to check the media for which the retina files are "
111
+ "missing. You can then create the files independently for each media or for "
112
+ "all of them. You can also upload and replace the images by drag & drop them "
113
+ "on the grid."
114
+ msgstr ""
115
+ "Diese Ansicht erlaubt es dir zu sehen für welche Bilder Retina Versionen "
116
+ "fehlen. Du kannst diese für jedes Bild einzeln oder für alle gleichzeitig "
117
+ "erstellen. Du kannst auch per drag & drop Bilder hochladen und ersetzen."
118
+
119
+ #: wr2x_retina-dashboard.php:179
120
+ msgid "All"
121
+ msgstr "Alle"
122
+
123
+ #: wr2x_retina-dashboard.php:180
124
+ msgid "Issues"
125
+ msgstr "Probleme"
126
+
127
+ #: wr2x_retina-dashboard.php:181
128
+ msgid "Ignored"
129
+ msgstr "Ignorieren"
130
+
131
+ #: wr2x_retina-dashboard.php:187
132
+ msgid "Title"
133
+ msgstr "Titel"
134
+
135
+ #: wr2x_retina-dashboard.php:195
136
+ msgid "Actions"
137
+ msgstr "Aktionen"
138
+
139
+ #: wr2x_retina-dashboard.php:250
140
+ msgid "IGNORE"
141
+ msgstr "Ingorieren"
142
+
143
+ #: wr2x_settings.php:18 wr2x_settings.php:21
144
+ msgid "Current method:"
145
+ msgstr "Derzeitige Methode:"
146
+
147
+ #: wr2x_settings.php:18 wr2x_settings.php:106
148
+ msgid "Client side"
149
+ msgstr "Benutzerseitig"
150
+
151
+ #: wr2x_settings.php:21 wr2x_settings.php:107
152
+ msgid "Server side"
153
+ msgstr "Serverseitig"
154
+
155
+ #: wr2x_settings.php:26
156
+ msgid ""
157
+ "By the way, you are using a <b>WordPress Multi-Site installation</b>! You "
158
+ "must edit your .htaccess manually and add '<b>RewriteRule ^files/(.+) wp-"
159
+ "content/plugins/wp-retina-2x/wr2x_image.php?ms=true&file=$1 [L]</b>' as the "
160
+ "first RewriteRule if you want the server-side to work."
161
+ msgstr ""
162
+ "Du nutzt eine <b> WordPress Multi-Site Installation</b>! Du musst deine ."
163
+ "htaccess Datei manuell editieren und diesen Code als erste Regel einfügen, "
164
+ "wenn du Serverseitig arbeiten willst:\"<b>RewriteRule ^files/(.+) wp-content/"
165
+ "plugins/wp-retina-2x/wr2x_image.php?ms=true&file=$1 [L]</b>\""
166
+
167
+ #: wr2x_settings.php:29
168
+ #, fuzzy
169
+ msgid ""
170
+ "By the way, you are using a <b>WordPress Multi-Site installation</b>! You "
171
+ "must edit your .htaccess manually and add '<b>RewriteRule ^(wp-content/.+\\."
172
+ "(png|gif|jpg|jpeg|bmp|PNG|GIF|JPG|JPEG|BMP)) wp-content/plugins/wp-retina-2x/"
173
+ "wr2x_image.php?ms=true&file=$1 [L]</b>' as the first RewriteRule if you want "
174
+ "the server-side to work."
175
+ msgstr ""
176
+ "Du nutzt eine <b> WordPress Multi-Site Installation</b>! Du musst deine ."
177
+ "htaccess Datei manuell editieren und diesen Code als erste Regel einfügen, "
178
+ "wenn du Serverseitig arbeiten willst:\"<b>RewriteRule ^files/(.+) wp-content/"
179
+ "plugins/wp-retina-2x/wr2x_image.php?ms=true&file=$1 [L]</b>\""
180
+
181
+ #: wr2x_settings.php:33
182
+ msgid ""
183
+ "The permalinks are not enabled. They need to be enabled in order to use the "
184
+ "server-side method."
185
+ msgstr ""
186
+ "Permalinks sind nicht aktiviert. Permalinks müssen aktiviert sein um "
187
+ "Serverseitig arbeiten zu können."
188
+
189
+ #: wr2x_settings.php:62
190
+ msgid "Basics"
191
+ msgstr "Grundlagen"
192
+
193
+ #: wr2x_settings.php:66
194
+ msgid "Advanced"
195
+ msgstr "Erweitert"
196
+
197
+ #: wr2x_settings.php:79
198
+ msgid "Disabled Sizes"
199
+ msgstr "Unbrauchbare Größen."
200
+
201
+ #: wr2x_settings.php:80
202
+ msgid "The checked sizes will not be generated for Retina displays."
203
+ msgstr "Die ausgewählten Größen werden nicht für Retina Bildschirme generiert."
204
+
205
+ #: wr2x_settings.php:86
206
+ msgid "Auto Generate"
207
+ msgstr "Automatisch erstellen."
208
+
209
+ #: wr2x_settings.php:87
210
+ msgid ""
211
+ "Generate Retina images automatically when images are uploaded to the Media "
212
+ "Library."
213
+ msgstr ""
214
+ "Retina Dateien automatisch erstellen wenn Bilder in die Mediathek "
215
+ "hochgeladen werden."
216
+
217
+ #: wr2x_settings.php:95
218
+ msgid "Method"
219
+ msgstr "Methode"
220
+
221
+ #: wr2x_settings.php:97
222
+ #, fuzzy
223
+ msgid ""
224
+ "<br />\n"
225
+ " \t\tThe <b>HTML Rewrite method</b> is probably the best, "
226
+ "especially when used with Cloudflare or Google PageSpeed Service! You cannot "
227
+ "use a basic HTML caching plugin with it (or you have to hack the options "
228
+ "properly). <br /><br />\n"
229
+ " \t\tThe <b>Server-side method</b> is very fast and "
230
+ "efficient. However, depending on the hosting and cache system you are using "
231
+ "(including services like Cloudflare) you might encounter issues.<br /><br /"
232
+ ">\n"
233
+ " \t\tThe <b>Client-side method</b> is fail-safe and only uses "
234
+ "a JavaScript file. When a Retina Display is detected, requests for every "
235
+ "images on the page will be sent to the server and a high resolution image "
236
+ "will be retrieved if available. It requires more bandwidth.\n"
237
+ " \t"
238
+ msgstr ""
239
+ "<br />Die<b>Serverseitige Methode</b> ist sehr schnell und effizient. Jedoch "
240
+ "können abhängig von dem Hosting und Nachhing System welches sie benutzen "
241
+ "(insbesondere Dienstleistungen wie z.B. Cloudflare.) Fehler auftreten.<br /"
242
+ "><br />Die <b>Nutzerseitige Methode</b> ist Fehlersicher und nutzt nur "
243
+ "JavaScript Dateien. Wenn ein Retina Bildschirm erkannt wird, werden alle "
244
+ "Anfragen zu Bilddateien auf eine hohe Auflösung weitergeleitet (wenn "
245
+ "verfügbar). Die meisten Webseiten nutzen diese Methode."
246
+
247
+ #: wr2x_settings.php:105
248
+ msgid "HTML Rewrite"
249
+ msgstr "HTML Rewrite"
250
+
251
+ #: wr2x_settings.php:108
252
+ msgid "None"
253
+ msgstr ""
254
+
255
+ #: wr2x_settings.php:113
256
+ msgid "Quality"
257
+ msgstr "Qualität"
258
+
259
+ #: wr2x_settings.php:114
260
+ msgid "Image Compression quality (between 0 and 100)."
261
+ msgstr ""
262
+
263
+ #: wr2x_settings.php:120
264
+ msgid "Debug Mode"
265
+ msgstr "Debug Modus"
266
+
267
+ #: wr2x_settings.php:121
268
+ msgid ""
269
+ "If checked, the client will be always served Retina images. Convenient for "
270
+ "testing."
271
+ msgstr "Wenn aktiviert werden immer Retina Dateien angezeigt. Zum Testen."
272
+
273
+ #: wr2x_settings.php:127
274
+ msgid "Hide 'Retina' column"
275
+ msgstr "Retina Spalte nicht anzeigen."
276
+
277
+ #: wr2x_settings.php:128
278
+ msgid "Will hide the 'Retina Column' from the Media Library."
279
+ msgstr "Versteckt die \"Retina Spalte\" in der Mediathek."
280
+
281
+ #: wr2x_settings.php:134
282
+ msgid "Hide Retina Dashboard"
283
+ msgstr "Retina Dashboard verstecken."
284
+
285
+ #: wr2x_settings.php:135
286
+ msgid "Doesn't show the Retina Dashboard menu and tools."
287
+ msgstr "Retina Dashboard und Werkzeuge nicht anzeigen."
288
+
289
+ #: wr2x_settings.php:141
290
+ #, fuzzy
291
+ msgid "Ignore Mobile"
292
+ msgstr "Ignorieren"
293
+
294
+ #: wr2x_settings.php:142
295
+ msgid "Doesn't deliver Retina images to mobiles."
296
+ msgstr ""
297
+
298
+ #~ msgid "Titre"
299
+ #~ msgstr "Titre"
300
+
301
+ #~ msgid ""
302
+ #~ "Current method: <u>Server-side</u>.</span> Oh, and don't forget to check "
303
+ #~ "the tutorial of this plugin on <a href='http://www.totorotimes.com/news/"
304
+ #~ "retina-display-wordpress-plugin'>Totoro Times</a>."
305
+ #~ msgstr ""
306
+ #~ "Méthode sélectionnée: <u>Server-side</u>.</span> Oh, n'oubliez pas de "
307
+ #~ "lire mon tutoriel sur ce plugin sur <a href='http://www.totorotimes.com/"
308
+ #~ "news/retina-display-wordpress-plugin'>Totoro Times</a>."
309
+
310
+ #~ msgid "Done."
311
+ #~ msgstr "Terminé."
312
+
313
+ #~ msgid "ERROR"
314
+ #~ msgstr "ERREUR"
315
+
316
+ #~ msgid "Not created yet."
317
+ #~ msgstr "Pas encore créé."
318
+
319
+ #~ msgid "Generate for all files"
320
+ #~ msgstr "Générer tous les fichiers"
321
+
322
+ #~ msgid ""
323
+ #~ "By the way, you are also using a <b>WordPress Network installation</b>. "
324
+ #~ "The server-side might not work for you, so <b>please try the client-side "
325
+ #~ "method instead</b>. If you really want to use this method, you will have "
326
+ #~ "to work on your .htaccess manually."
327
+ #~ msgstr ""
328
+ #~ "Vous utilisez une version de WordPress <b>Multisite</b>. Il est possible "
329
+ #~ "que la méthode côté serveur ne fonctionne pas, alors dans ce cas essayé "
330
+ #~ "la méthode <b>côté client</b>. Si vous voulez vraiment utiliser cette "
331
+ #~ "méthode, vous aurez peut-être besoin de bidouiller votre .htaccess "
332
+ #~ "manuellement."
333
+
334
+ #~ msgid ""
335
+ #~ "This plugin supports and uses the <a href='http://wordpress.org/extend/"
336
+ #~ "plugins/enable-media-replace/'>Enable Media Replace</a> plugin if "
337
+ #~ "available. A 'Replace' button will appear in case your images are too "
338
+ #~ "small. It is strongly recommended to install it."
339
+ #~ msgstr ""
340
+ #~ "WP Retina 2x peut automatiquement utiliser le plugin <a href='http://"
341
+ #~ "wordpress.org/extend/plugins/enable-media-replace/'>Enable Media Replace</"
342
+ #~ "a> si il est installé. Un bouton 'Réuploader' apparaîtra alors lorsque "
343
+ #~ "l'image originale est trop petite."
344
+
345
+ #~ msgid ""
346
+ #~ "This plugin is actively developped and maintained by <a href='https://"
347
+ #~ "plus.google.com/106075761239802324012'>Jordy Meow</a>.<br />Please visit "
348
+ #~ "me at <a href='http://www.totorotimes.com'>Totoro Times</a>, a website "
349
+ #~ "about Japan, photography and abandoned places.<br />And thanks for "
350
+ #~ "linking us on <a href='https://www.facebook.com/totorotimes'>Facebook</a> "
351
+ #~ "and <a href='https://plus.google.com/106832157268594698217'>Google+</a> :)"
352
+ #~ msgstr ""
353
+ #~ "Ce plugin est activement développé et maintenu par <a href='https://plus."
354
+ #~ "google.com/106075761239802324012'>Jordy Meow</a>.<br />Merci de me "
355
+ #~ "visiter sur <a href='http://www.totorotimes.fr'>Totoro Times</a>, un site "
356
+ #~ "sur le Japan, la photographie et les endroits abandonnés.<br />Et merci "
357
+ #~ "de nous adorer sur <a href='https://www.facebook.com/"
358
+ #~ "totorotimes'>Facebook</a> et <a href='https://plus.google."
359
+ #~ "com/106832157268594698217'>Google+</a> :)"
trunk/languages/wp-retina-2x-fr_FR.mo ADDED
Binary file
trunk/languages/wp-retina-2x-fr_FR.po ADDED
@@ -0,0 +1,711 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: WP Retina 2x\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2015-06-23 15:58+0900\n"
6
+ "PO-Revision-Date: 2015-06-23 16:19+0900\n"
7
+ "Last-Translator: Jordy Meow <work@meow.fr>\n"
8
+ "Language-Team: Jordy Meow <work@meow.fr>\n"
9
+ "Language: fr_FR\n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Poedit-KeywordsList: _e;__\n"
14
+ "X-Poedit-Basepath: ../\n"
15
+ "X-Generator: Poedit 1.8.1\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: wp-retina-2x.php:354
20
+ msgid "N/A"
21
+ msgstr "N/A"
22
+
23
+ #: wp-retina-2x.php:387
24
+ msgid ""
25
+ "PRO VERSION ONLY<br /><br />You can buy a serial from here: <a "
26
+ "target='_blank' href='http://apps.meow.fr/wp-retina-2x/'>WP Retina 2x</a>."
27
+ "<br />Then add this serial in the settings. That's all! :)<br />Thanks a lot "
28
+ "for your support."
29
+ msgstr ""
30
+ "PRO VERSION SEULEMENT<br /><br />Vous pouvez obtenir un serial code ici : <a "
31
+ "target='_blank' href='http://apps.meow.fr/wp-retina-2x/'>WP Retina 2x</a>."
32
+ "<br />Ajouter le ensuite dans les paramètres de Retina.<br />Merci beaucoup "
33
+ "pour votre support :)"
34
+
35
+ #: wp-retina-2x.php:422
36
+ msgid ""
37
+ "The metadata is broken! This is not related to the retina plugin. You should "
38
+ "probably use a plugin to re-generate the missing metadata and images."
39
+ msgstr ""
40
+
41
+ #: wp-retina-2x.php:426
42
+ #, php-format
43
+ msgid ""
44
+ "The image size '%s' could not be found. You probably changed your image "
45
+ "sizes but this specific image was not re-build. This is not related to the "
46
+ "retina plugin. You should probably use a plugin to re-generate the missing "
47
+ "metadata and images."
48
+ msgstr ""
49
+
50
+ #: wp-retina-2x.php:444
51
+ #, php-format
52
+ msgid ""
53
+ "The retina version of the Full-Size image is missing.<br />Full Size Retina "
54
+ "has been checked in the Settings and this image is therefore required.<br /"
55
+ ">Please drag & drop an image of at least <b>%dx%d</b> in the <b>Full-Size "
56
+ "Retina Upload</b> column."
57
+ msgstr ""
58
+
59
+ #: wp-retina-2x.php:448
60
+ #, php-format
61
+ msgid ""
62
+ "The Full-Size image is too small (<b>%dx%d</b>) and this size cannot be "
63
+ "generated.<br />Please upload an image of at least <b>%dx%d</b>."
64
+ msgstr ""
65
+
66
+ #: wp-retina-2x.php:458
67
+ msgid "The retina image can be created. Please use the 'GENERATE' button."
68
+ msgstr ""
69
+
70
+ #: wp-retina-2x.php:463
71
+ msgid "The standard image normally created by WordPress is missing."
72
+ msgstr ""
73
+
74
+ #: wp-retina-2x.php:468
75
+ msgid "This size is ignored by your retina settings."
76
+ msgstr "Cette taille est ignorée par vos paramètres."
77
+
78
+ #: wp-retina-2x.php:952
79
+ msgid "Your serial does not seem right."
80
+ msgstr ""
81
+
82
+ #: wp-retina-2x.php:955
83
+ msgid "Your subscription is not active."
84
+ msgstr "Votre plugin n'est pas enregistré."
85
+
86
+ #: wp-retina-2x.php:958
87
+ msgid "Too many URLs are linked to your subscription."
88
+ msgstr ""
89
+
90
+ #: wp-retina-2x.php:970
91
+ msgid "Your subscription is enabled."
92
+ msgstr "Votre plugin est enregistré."
93
+
94
+ #: wr2x_ajax.php:30
95
+ msgid ""
96
+ "<a href='?page=wp-retina-2x&view=issues&refresh=true'>Refresh</a> this page."
97
+ msgstr ""
98
+
99
+ #: wr2x_ajax.php:58 wr2x_ajax.php:105
100
+ msgid "Wait..."
101
+ msgstr "Patientez..."
102
+
103
+ #: wr2x_ajax.php:66
104
+ msgid "Nothing to do ;)"
105
+ msgstr "Rien à faire ;)"
106
+
107
+ #: wr2x_ajax.php:112 wr2x_retina-dashboard.php:251
108
+ msgid "GENERATE"
109
+ msgstr "GÉNÉRER"
110
+
111
+ #: wr2x_ajax.php:356 wr2x_ajax.php:392 wr2x_ajax.php:425 wr2x_ajax.php:449
112
+ msgid "The attachment ID is missing."
113
+ msgstr "The attachment ID is missing."
114
+
115
+ #: wr2x_ajax.php:380
116
+ msgid "Full retina file deleted."
117
+ msgstr ""
118
+
119
+ #: wr2x_ajax.php:414
120
+ msgid "Retina files deleted."
121
+ msgstr "Les images Retina ont été supprimées."
122
+
123
+ #: wr2x_ajax.php:437
124
+ msgid "Details retrieved."
125
+ msgstr "Détails téléchargés."
126
+
127
+ #: wr2x_ajax.php:467
128
+ msgid "Retina files generated."
129
+ msgstr "Les images Retina ont été générées."
130
+
131
+ #: wr2x_ajax.php:477
132
+ msgid "You do not have permission to upload files."
133
+ msgstr "Vous n'avez pas la permission d'uploader des fichiers."
134
+
135
+ #: wr2x_ajax.php:499
136
+ msgid "The temporary directory could not be created."
137
+ msgstr "The temporary directory could not be created."
138
+
139
+ #: wr2x_ajax.php:515
140
+ msgid "The file is not an image or the upload went wrong."
141
+ msgstr ""
142
+ "Ce fichier n'est pas une image ou alors il y a eu un problème durant "
143
+ "l'upload."
144
+
145
+ #: wr2x_ajax.php:525
146
+ msgid "You cannot use this file (wrong extension? wrong type?)."
147
+ msgstr "Vous ne pouvez pas utiliser ce fichier (mauvaise extension ou type ?)."
148
+
149
+ #: wr2x_ajax.php:568
150
+ msgid "Uploaded successfully."
151
+ msgstr "Mise à jour réussie."
152
+
153
+ #: wr2x_ajax.php:619
154
+ msgid "Replaced successfully."
155
+ msgstr "Remplacé avec succès."
156
+
157
+ #: wr2x_retina-dashboard.php:26
158
+ msgid "Retina images"
159
+ msgstr "Images Retina"
160
+
161
+ #: wr2x_retina-dashboard.php:27
162
+ #, php-format
163
+ msgid "Retina %s"
164
+ msgstr "Retina %s"
165
+
166
+ #: wr2x_retina-dashboard.php:138
167
+ msgid "Refresh"
168
+ msgstr "Rafraîchir"
169
+
170
+ #: wr2x_retina-dashboard.php:152
171
+ msgid "Bulk Delete"
172
+ msgstr "Tout Supprimer"
173
+
174
+ #: wr2x_retina-dashboard.php:155
175
+ msgid "Bulk Generate"
176
+ msgstr "Tout Générer"
177
+
178
+ #: wr2x_retina-dashboard.php:166
179
+ msgid "The logs have been cleared."
180
+ msgstr "Les logs ont été supprimés."
181
+
182
+ #: wr2x_retina-dashboard.php:190
183
+ #, php-format
184
+ msgid ""
185
+ "The full-size images should have a resolution of <b>%d×%d</b> at least for "
186
+ "the plugin to be able generate the <b>%d retina images</b> required by your "
187
+ "website."
188
+ msgstr ""
189
+ "Les images Full-Size images doivent avoir une résolution d'au moins <b>%d×"
190
+ "%d</b> pour que le plugin puisse générer les <b>%d images retina</b>."
191
+
192
+ #: wr2x_retina-dashboard.php:191
193
+ #, php-format
194
+ msgid ""
195
+ "You <b>also need</b> to upload a retina image for the Full-Size image (might "
196
+ "be <b>%d×%d</b>)."
197
+ msgstr ""
198
+
199
+ #: wr2x_retina-dashboard.php:192
200
+ msgid "You can upload or replace the images by drag & drop."
201
+ msgstr ""
202
+
203
+ #: wr2x_retina-dashboard.php:193
204
+ #, php-format
205
+ msgid "Your PHP configuration allows uploads of <b>%dMB</b> maximum."
206
+ msgstr ""
207
+
208
+ #: wr2x_retina-dashboard.php:197
209
+ #, php-format
210
+ msgid ""
211
+ "The <a target=\"_blank\" href=\"%s/wp-retina-2x.log\">log file</a> is "
212
+ "available. You can also <a href=\"?page=wp-"
213
+ "retina-2x&view=issues&clearlogs=true\">clear</a> it."
214
+ msgstr ""
215
+
216
+ #: wr2x_retina-dashboard.php:215
217
+ msgid "All"
218
+ msgstr "Tous"
219
+
220
+ #: wr2x_retina-dashboard.php:216
221
+ msgid "Issues"
222
+ msgstr "Problèmes"
223
+
224
+ #: wr2x_retina-dashboard.php:217
225
+ msgid "Ignored"
226
+ msgstr "Ignorés"
227
+
228
+ #: wr2x_retina-dashboard.php:223
229
+ msgid "Base image"
230
+ msgstr ""
231
+
232
+ #: wr2x_retina-dashboard.php:224
233
+ msgid "Media Sizes<br />Retina-ized"
234
+ msgstr ""
235
+
236
+ #: wr2x_retina-dashboard.php:225
237
+ msgid "Full-Size<br/><b>Replace</b>"
238
+ msgstr ""
239
+
240
+ #: wr2x_retina-dashboard.php:226
241
+ msgid "Full-Size Retina"
242
+ msgstr ""
243
+
244
+ #: wr2x_retina-dashboard.php:227
245
+ msgid "Full-Size Retina<br/><b>Upload</b>"
246
+ msgstr ""
247
+
248
+ #: wr2x_retina-dashboard.php:253
249
+ msgid "IGNORE"
250
+ msgstr "IGNORER"
251
+
252
+ #: wr2x_retina-dashboard.php:254
253
+ msgid "DETAILS"
254
+ msgstr "DETAILS"
255
+
256
+ #: wr2x_settings.php:21 wr2x_settings.php:24 wr2x_settings.php:27
257
+ msgid "Current method:"
258
+ msgstr "Methode utilisée :"
259
+
260
+ #: wr2x_settings.php:21
261
+ msgid "Client side"
262
+ msgstr "Client side"
263
+
264
+ #: wr2x_settings.php:24
265
+ msgid "PictureFill"
266
+ msgstr "PictureFill"
267
+
268
+ #: wr2x_settings.php:27
269
+ msgid "Server side"
270
+ msgstr "Server side"
271
+
272
+ #: wr2x_settings.php:32
273
+ msgid ""
274
+ "By the way, you are using a <b>WordPress Multi-Site installation</b>! You "
275
+ "must edit your .htaccess manually and add '<b>RewriteRule ^files/(.+) wp-"
276
+ "content/plugins/wp-retina-2x/wr2x_image.php?ms=true&file=$1 [L]</b>' as the "
277
+ "first RewriteRule if you want the server-side to work."
278
+ msgstr ""
279
+ "Vous avez une <b>installation Multi-Site de WordPress</b> ! Vous devez "
280
+ "éditer votre .htaccess manuellement et rajouter '<b>RewriteRule ^files/(.+."
281
+ "(?:jpe?g|gif|png)) wp-content/plugins/wp-retina-2x/wr2x_image.php?"
282
+ "ms=true&file=$1 [L]</b>' en tant que première RewriteRule si vous voulez que "
283
+ "le Client side fonctionne."
284
+
285
+ #: wr2x_settings.php:35
286
+ msgid ""
287
+ "By the way, you are using a <b>WordPress Multi-Site installation</b>! You "
288
+ "must edit your .htaccess manually and add '<b>RewriteRule ^(wp-content/.+\\."
289
+ "(png|gif|jpg|jpeg|bmp|PNG|GIF|JPG|JPEG|BMP)) wp-content/plugins/wp-retina-2x/"
290
+ "wr2x_image.php?ms=true&file=$1 [L]</b>' as the first RewriteRule if you want "
291
+ "the server-side to work."
292
+ msgstr ""
293
+ "Vous avez une <b>installation Multi-Site de WordPress</b> ! Vous devez "
294
+ "éditer votre .htaccess manuellement et rajouter '<b>RewriteRule ^(wp-"
295
+ "content/.+\\.(png|gif|jpg|jpeg|bmp|PNG|GIF|JPG|JPEG|BMP)) wp-content/plugins/"
296
+ "wp-retina-2x/wr2x_image.php?ms=true&file=$1 [L]</b>' en tant que première "
297
+ "RewriteRule si vous voulez que le Client side fonctionne."
298
+
299
+ #: wr2x_settings.php:39
300
+ msgid ""
301
+ "The permalinks are not enabled. They need to be enabled in order to use the "
302
+ "server-side method."
303
+ msgstr ""
304
+ "Les permaliens n'étant pas activés, la méthode côté serveur ne pourra pas "
305
+ "fonctionner."
306
+
307
+ #: wr2x_settings.php:85
308
+ msgid "Basics"
309
+ msgstr "Basic"
310
+
311
+ #: wr2x_settings.php:89
312
+ msgid "Advanced"
313
+ msgstr "Avancé"
314
+
315
+ #: wr2x_settings.php:93
316
+ msgid "Pro"
317
+ msgstr "Pro"
318
+
319
+ #: wr2x_settings.php:111
320
+ msgid "Disabled Sizes"
321
+ msgstr "Tailles désactivés"
322
+
323
+ #: wr2x_settings.php:112
324
+ msgid ""
325
+ "<br />The selected sizes will not have their retina equivalent generated."
326
+ msgstr ""
327
+
328
+ #: wr2x_settings.php:118
329
+ msgid "Auto Generate"
330
+ msgstr "Auto-Génération"
331
+
332
+ #: wr2x_settings.php:119
333
+ msgid ""
334
+ "Generate retina images automatically when images are uploaded or re-"
335
+ "generated.<br />The 'Disabled Sizes' will be skipped."
336
+ msgstr ""
337
+
338
+ #: wr2x_settings.php:125
339
+ msgid "Full Size Retina (Pro)"
340
+ msgstr ""
341
+
342
+ #: wr2x_settings.php:126
343
+ msgid ""
344
+ "Retina for the full-size image will be considered required.<br />Checks and "
345
+ "upload feature are available."
346
+ msgstr ""
347
+
348
+ #: wr2x_settings.php:134
349
+ msgid "Method"
350
+ msgstr "Méthode"
351
+
352
+ #: wr2x_settings.php:135
353
+ msgid ""
354
+ "<br />Check the <a href=\"http://apps.meow.fr/wp-retina-2x/\">plugin "
355
+ "official page</a> if you want to know more about the methods to deliver the "
356
+ "retina images."
357
+ msgstr ""
358
+
359
+ #: wr2x_settings.php:139
360
+ msgid "Picturefill (Recommended)"
361
+ msgstr ""
362
+
363
+ #: wr2x_settings.php:140
364
+ msgid "Retina.js"
365
+ msgstr "Retina.js"
366
+
367
+ #: wr2x_settings.php:141
368
+ msgid "IMG Rewrite"
369
+ msgstr ""
370
+
371
+ #: wr2x_settings.php:142
372
+ msgid "Retina-Images"
373
+ msgstr "Retina-Images"
374
+
375
+ #: wr2x_settings.php:143
376
+ msgid "None"
377
+ msgstr "Aucune"
378
+
379
+ #: wr2x_settings.php:148
380
+ msgid "Quality"
381
+ msgstr "Qualité"
382
+
383
+ #: wr2x_settings.php:149
384
+ msgid ""
385
+ "<br />Image Compression quality (between 0 and 100).<br />That doesn't "
386
+ "always actually work depending on your hosting service."
387
+ msgstr ""
388
+
389
+ #: wr2x_settings.php:155
390
+ msgid "Debug Mode"
391
+ msgstr "Mode Debug"
392
+
393
+ #: wr2x_settings.php:156
394
+ msgid ""
395
+ "If checked, the client will be always served Retina images. <br />Please use "
396
+ "it for testing purposes. It creates a <a href=\""
397
+ msgstr ""
398
+
399
+ #: wr2x_settings.php:162
400
+ msgid "Custom CDN Domain (Pro)"
401
+ msgstr ""
402
+
403
+ #: wr2x_settings.php:163
404
+ msgid ""
405
+ "<br />If not empty, your site domain will be replaced with this CDN domain "
406
+ "(PictureFill and HTML Rewrite only)."
407
+ msgstr ""
408
+
409
+ #: wr2x_settings.php:170
410
+ msgid "<h2>For PictureFill</h2>"
411
+ msgstr ""
412
+
413
+ #: wr2x_settings.php:175
414
+ msgid "Keep IMG SRC (Pro)"
415
+ msgstr ""
416
+
417
+ #: wr2x_settings.php:176
418
+ msgid ""
419
+ "With PictureFill, <b>src</b> tags are replaced by <b>src-set</b> tags and "
420
+ "consequently search engines might not be able to find and reference those "
421
+ "images. Keeping it will load images twice for retina devices on old browsers."
422
+ msgstr ""
423
+
424
+ #: wr2x_settings.php:182
425
+ msgid "Use Lazysizes (Pro)"
426
+ msgstr ""
427
+
428
+ #: wr2x_settings.php:183
429
+ msgid ""
430
+ "HTML will be rewritten to support the lazysizes and the script will be also "
431
+ "loaded. The images will be loaded in a lazy way (when the visitor is getting "
432
+ "close to them)."
433
+ msgstr ""
434
+
435
+ #: wr2x_settings.php:189
436
+ msgid "No Picturefill Script"
437
+ msgstr ""
438
+
439
+ #: wr2x_settings.php:190
440
+ msgid ""
441
+ "The script for Picturefill will not be loaded. Only the browsers with src-"
442
+ "set support (e.g. Chrome) will display images. You can also load the "
443
+ "Picturefill script manually."
444
+ msgstr ""
445
+
446
+ #: wr2x_settings.php:197
447
+ msgid "<h2>Admin Screens</h2>"
448
+ msgstr ""
449
+
450
+ #: wr2x_settings.php:202
451
+ msgid "Hide 'Retina' column"
452
+ msgstr "Cacher la colonne 'Retina'"
453
+
454
+ #: wr2x_settings.php:203
455
+ msgid "Will hide the 'Retina Column' from the Media Library."
456
+ msgstr "La colonne Retina ne s'affichera plus dans la Bibliothèque."
457
+
458
+ #: wr2x_settings.php:209
459
+ msgid "Hide Retina Dashboard"
460
+ msgstr "Cacher le Retina Dashboard"
461
+
462
+ #: wr2x_settings.php:210
463
+ msgid "Doesn't show the Retina Dashboard menu and tools."
464
+ msgstr "Le Retina Dashboard ne s'affichera plus dans les menus."
465
+
466
+ #: wr2x_settings.php:216
467
+ msgid "Admin in Retina"
468
+ msgstr ""
469
+
470
+ #: wr2x_settings.php:217
471
+ msgid ""
472
+ "If checked, the WordPress Admin will also be Retina. Some plugins (like "
473
+ "NextGen) do not like Retina enabled in the admin."
474
+ msgstr ""
475
+
476
+ #: wr2x_settings.php:224
477
+ msgid "<h2>Mobiles</h2>"
478
+ msgstr ""
479
+
480
+ #: wr2x_settings.php:229
481
+ msgid "Ignore Mobile"
482
+ msgstr "Ignorer Mobiles"
483
+
484
+ #: wr2x_settings.php:230
485
+ msgid ""
486
+ "Doesn't deliver Retina images to mobiles.<br />PictureFill doesn't support "
487
+ "it and cache will also prevent it from working."
488
+ msgstr ""
489
+
490
+ #: wr2x_settings.php:244
491
+ msgid "Serial"
492
+ msgstr ""
493
+
494
+ #: wr2x_settings.php:245
495
+ msgid ""
496
+ "<br />Enter your serial or subscription ID here. If you don't have one yet, "
497
+ "get one <a target=\"_blank\" href=\"http://apps.meow.fr/wp-retina-2x/"
498
+ "\">right here</a>."
499
+ msgstr ""
500
+
501
+ #~ msgid ""
502
+ #~ "Done. Please <a href='javascript:history.go(0)'>refresh</a> this page."
503
+ #~ msgstr ""
504
+ #~ "Fait. <a href='javascript:history.go(0)'>Rafraîchissez</a> cette page."
505
+
506
+ #~ msgid ""
507
+ #~ "Done. You might want to <a href='?page=wp-"
508
+ #~ "retina-2x&view=issues&refresh=true'>refresh</a> the issues."
509
+ #~ msgstr ""
510
+ #~ "Fait. Vous devriez peut-être <a href='?page=wp-"
511
+ #~ "retina-2x&view=issues&refresh=true'>rafraîchir</a> la liste des problèmes."
512
+
513
+ #~ msgid "Please wait..."
514
+ #~ msgstr "Patientez SVP..."
515
+
516
+ #~ msgid "You don't have the rights to use a temporary directory."
517
+ #~ msgstr "Vous n'avez pas la permission d'utiliser un répertoire temporaire."
518
+
519
+ #~ msgid "WP Retina 2x %s"
520
+ #~ msgstr "WP Retina 2x %s"
521
+
522
+ #~ msgid "Generate"
523
+ #~ msgstr "Générer"
524
+
525
+ #~ msgid "Delete all @2x"
526
+ #~ msgstr "Tout supprimer (@2x)"
527
+
528
+ #~ msgid "Refresh issues"
529
+ #~ msgstr "Rafraîchir"
530
+
531
+ #~ msgid "Issues has been refreshed."
532
+ #~ msgstr "La liste des problèmes a été rafraîchie."
533
+
534
+ #~ msgid ""
535
+ #~ "This screen allows you to check the media for which the retina files are "
536
+ #~ "missing. You can then create the files independently for each media or "
537
+ #~ "for all of them. You can also upload and replace the images by drag & "
538
+ #~ "drop them on the grid."
539
+ #~ msgstr ""
540
+ #~ "Cet écran vous permet de vérifier pour quels médias les fichiers Retina "
541
+ #~ "n'ont pas encore été créés. Vous pouvez ensuite créer les fichiers "
542
+ #~ "indépendemment ou pour l'ensemble d'entre-eux. Vous pouvez aussi glisser "
543
+ #~ "& déposer les nouveaux fichiers dans le tableau."
544
+
545
+ #~ msgid "Title"
546
+ #~ msgstr "Titre"
547
+
548
+ #~ msgid "Actions"
549
+ #~ msgstr "Actions"
550
+
551
+ #~ msgid "The checked sizes will not be generated for Retina displays."
552
+ #~ msgstr ""
553
+ #~ "Les tailles sélectionnés ne seront pas prises en compte pour Retina."
554
+
555
+ #~ msgid ""
556
+ #~ "Generate Retina images automatically when images are uploaded to the "
557
+ #~ "Media Library."
558
+ #~ msgstr ""
559
+ #~ "Génération automatique des fichiers Retina dès que vous uploadez ou "
560
+ #~ "remplacez des médias."
561
+
562
+ #~ msgid ""
563
+ #~ "<br />\n"
564
+ #~ " The <b>HTML srcset method</b> is the best. The "
565
+ #~ "HTML will be rewritten with <a href=\"http://www.w3.org/html/wg/drafts/"
566
+ #~ "srcset/w3c-srcset/\">the srcset attribute</a> added to the img tags. "
567
+ #~ "Works with caching. Unfortunately, not all the browsers support it yet."
568
+ #~ "<br /><br />\n"
569
+ #~ " \t\tThe <b>HTML Rewrite method</b> is one of the best "
570
+ #~ "methods. It replaces the images by the retina images - if available - in "
571
+ #~ "the HTML directly. It's tricky to use HTML caching with it however.<br /"
572
+ #~ "><br /> \t\t\n"
573
+ #~ " \t\tThe <b>Retina.js method</b> is fail-safe and only "
574
+ #~ "uses one <a href=\"https://github.com/imulus/retinajs/\">JavaScript file</"
575
+ #~ "a>. When a Retina Display is detected, requests for every images on the "
576
+ #~ "page will be sent to the server and the retina images will be retrieved "
577
+ #~ "if available. Requires a lot of bandwidth.<br /><br />\n"
578
+ #~ " The <b>Retina-Images method</b> is efficient. The "
579
+ #~ "images will go through the <a href=\"https://github.com/Retina-Images/"
580
+ #~ "Retina-Images/\">Retina-Images</a> handler. Caching systems might be an "
581
+ #~ "issue.\n"
582
+ #~ " \t"
583
+ #~ msgstr ""
584
+ #~ "<br />\n"
585
+ #~ " The <b>HTML srcset method</b> is the best. The "
586
+ #~ "HTML will be rewritten with <a href=\"http://www.w3.org/html/wg/drafts/"
587
+ #~ "srcset/w3c-srcset/\">the srcset attribute</a> added to the img tags. "
588
+ #~ "Works with caching. Unfortunately, not all the browsers support it yet."
589
+ #~ "<br /><br />\n"
590
+ #~ " \t\tThe <b>HTML Rewrite method</b> is one of the best "
591
+ #~ "methods. It replaces the images by the retina images - if available - in "
592
+ #~ "the HTML directly. It's tricky to use HTML caching with it however.<br /"
593
+ #~ "><br /> \t\t\n"
594
+ #~ " \t\tThe <b>Retina.js method</b> is fail-safe and only "
595
+ #~ "uses one <a href=\"https://github.com/imulus/retinajs/\">JavaScript file</"
596
+ #~ "a>. When a Retina Display is detected, requests for every images on the "
597
+ #~ "page will be sent to the server and the retina images will be retrieved "
598
+ #~ "if available. Requires a lot of bandwidth.<br /><br />\n"
599
+ #~ " The <b>Retina-Images method</b> is efficient. The "
600
+ #~ "images will go through the <a href=\"https://github.com/Retina-Images/"
601
+ #~ "Retina-Images/\">Retina-Images</a> handler. Caching systems might be an "
602
+ #~ "issue.\n"
603
+ #~ " \t"
604
+
605
+ #~ msgid "HTML srcset (W3C Draft)"
606
+ #~ msgstr "HTML srcset (W3C Draft)"
607
+
608
+ #~ msgid "HTML Rewrite"
609
+ #~ msgstr "HTML Rewrite"
610
+
611
+ #~ msgid "Image Compression quality (between 0 and 100)."
612
+ #~ msgstr "Qualité de compression (entre 0 et 100)."
613
+
614
+ #~ msgid ""
615
+ #~ "If checked, the client will be always served Retina images. Convenient "
616
+ #~ "for testing."
617
+ #~ msgstr ""
618
+ #~ "Si sélectionné, les images Retina seront toujours délivrées. Idéal pour "
619
+ #~ "vos tests."
620
+
621
+ #~ msgid "Doesn't deliver Retina images to mobiles."
622
+ #~ msgstr "Pas de retina pour les mobiles."
623
+
624
+ #~ msgid ""
625
+ #~ "<br />\n"
626
+ #~ " \t\tThe <b>HTML Rewrite method</b> is probably the best, "
627
+ #~ "especially when used with Cloudflare or Google PageSpeed Service! You "
628
+ #~ "cannot use a basic HTML caching plugin with it (or you have to hack the "
629
+ #~ "options properly). <br /><br />\n"
630
+ #~ " \t\tThe <b>Server-side method</b> is very fast and "
631
+ #~ "efficient. However, depending on the hosting and cache system you are "
632
+ #~ "using (including services like Cloudflare) you might encounter issues."
633
+ #~ "<br /><br />\n"
634
+ #~ " \t\tThe <b>Client-side method</b> is fail-safe and only "
635
+ #~ "uses a JavaScript file. When a Retina Display is detected, requests for "
636
+ #~ "every images on the page will be sent to the server and a high resolution "
637
+ #~ "image will be retrieved if available. It requires more bandwidth.\n"
638
+ #~ " \t"
639
+ #~ msgstr ""
640
+ #~ "La <b>méthode HTML Rewrite</b> est la meilleure, surtout si utilisée "
641
+ #~ "conjointement à Cloudflare ou encore mieux, du Google PageSpeed Service. "
642
+ #~ "Désactivez vos plugins de cache HTML (ou alors il vous faudra hacker les "
643
+ #~ "options).<br /><br />La <b>méthode côté serveur</b> est rapide et "
644
+ #~ "optimale. Cependant, selon votre système de caching (Cloudflare inclus), "
645
+ #~ "ça ne fonctionnera peut-être pas correctement.<br /><br />La <b>méthode "
646
+ #~ "côté client</b> est fiable, fonctionne dans tous les cas et utilise "
647
+ #~ "seulement un JavaScript. C'est une méthode moins rapide et performante "
648
+ #~ "mais néanmoins la méthode utilisée sur le site d'Apple."
649
+
650
+ #~ msgid "Titre"
651
+ #~ msgstr "Titre"
652
+
653
+ #~ msgid ""
654
+ #~ "Current method: <u>Server-side</u>.</span> Oh, and don't forget to check "
655
+ #~ "the tutorial of this plugin on <a href='http://www.totorotimes.com/news/"
656
+ #~ "retina-display-wordpress-plugin'>Totoro Times</a>."
657
+ #~ msgstr ""
658
+ #~ "Méthode sélectionnée: <u>Server-side</u>.</span> Oh, n'oubliez pas de "
659
+ #~ "lire mon tutoriel sur ce plugin sur <a href='http://www.totorotimes.com/"
660
+ #~ "news/retina-display-wordpress-plugin'>Totoro Times</a>."
661
+
662
+ #~ msgid "Done."
663
+ #~ msgstr "Terminé."
664
+
665
+ #~ msgid "ERROR"
666
+ #~ msgstr "ERREUR"
667
+
668
+ #~ msgid "Not created yet."
669
+ #~ msgstr "Pas encore créé."
670
+
671
+ #~ msgid "Generate for all files"
672
+ #~ msgstr "Générer tous les fichiers"
673
+
674
+ #~ msgid ""
675
+ #~ "By the way, you are also using a <b>WordPress Network installation</b>. "
676
+ #~ "The server-side might not work for you, so <b>please try the client-side "
677
+ #~ "method instead</b>. If you really want to use this method, you will have "
678
+ #~ "to work on your .htaccess manually."
679
+ #~ msgstr ""
680
+ #~ "Vous utilisez une version de WordPress <b>Multisite</b>. Il est possible "
681
+ #~ "que la méthode côté serveur ne fonctionne pas, alors dans ce cas essayé "
682
+ #~ "la méthode <b>côté client</b>. Si vous voulez vraiment utiliser cette "
683
+ #~ "méthode, vous aurez peut-être besoin de bidouiller votre .htaccess "
684
+ #~ "manuellement."
685
+
686
+ #~ msgid ""
687
+ #~ "This plugin supports and uses the <a href='http://wordpress.org/extend/"
688
+ #~ "plugins/enable-media-replace/'>Enable Media Replace</a> plugin if "
689
+ #~ "available. A 'Replace' button will appear in case your images are too "
690
+ #~ "small. It is strongly recommended to install it."
691
+ #~ msgstr ""
692
+ #~ "WP Retina 2x peut automatiquement utiliser le plugin <a href='http://"
693
+ #~ "wordpress.org/extend/plugins/enable-media-replace/'>Enable Media Replace</"
694
+ #~ "a> si il est installé. Un bouton 'Réuploader' apparaîtra alors lorsque "
695
+ #~ "l'image originale est trop petite."
696
+
697
+ #~ msgid ""
698
+ #~ "This plugin is actively developped and maintained by <a href='https://"
699
+ #~ "plus.google.com/106075761239802324012'>Jordy Meow</a>.<br />Please visit "
700
+ #~ "me at <a href='http://www.totorotimes.com'>Totoro Times</a>, a website "
701
+ #~ "about Japan, photography and abandoned places.<br />And thanks for "
702
+ #~ "linking us on <a href='https://www.facebook.com/totorotimes'>Facebook</a> "
703
+ #~ "and <a href='https://plus.google.com/106832157268594698217'>Google+</a> :)"
704
+ #~ msgstr ""
705
+ #~ "Ce plugin est activement développé et maintenu par <a href='https://plus."
706
+ #~ "google.com/106075761239802324012'>Jordy Meow</a>.<br />Merci de me "
707
+ #~ "visiter sur <a href='http://www.totorotimes.fr'>Totoro Times</a>, un site "
708
+ #~ "sur le Japan, la photographie et les endroits abandonnés.<br />Et merci "
709
+ #~ "de nous adorer sur <a href='https://www.facebook.com/"
710
+ #~ "totorotimes'>Facebook</a> et <a href='https://plus.google."
711
+ #~ "com/106832157268594698217'>Google+</a> :)"
trunk/languages/wp-retina-2x-it_IT.mo ADDED
Binary file
trunk/languages/wp-retina-2x-it_IT.po ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: wp-retina-2x\n"
4
+ "POT-Creation-Date: 2013-08-02 11:53+0900\n"
5
+ "PO-Revision-Date: 2013-08-02 11:53+0900\n"
6
+ "Last-Translator: Jordy Meow <work@meow.fr>\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-KeywordsList: _;gettext;gettext_noop;__;_e;_n:1,2;_n_noop:1,2;"
13
+ "_nx:1,2\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-SearchPath-0: ..\n"
18
+ "X-Poedit-SearchPath-1: .\n"
19
+
20
+ #: ../wr2x_ajax.php:39
21
+ msgid "Done. Please <a href='javascript:history.go(0)'>refresh</a> this page."
22
+ msgstr ""
23
+ "Fatto. <a href='javascript:history.go(0)'>Aggiornare</a> questa pagina."
24
+
25
+ #: ../wr2x_ajax.php:42
26
+ msgid ""
27
+ "Done. You might want to <a href='?page=wp-"
28
+ "retina-2x&view=issues&refresh=true'>refresh</a> the issues."
29
+ msgstr ""
30
+ "Fatto. Si consiglia di <a href='?page=wp-"
31
+ "retina-2x&view=issues&refresh=true'>aggiornare</a> i problemi."
32
+
33
+ #: ../wr2x_ajax.php:52 ../wr2x_ajax.php:103
34
+ msgid "Please wait..."
35
+ msgstr "Attendere..."
36
+
37
+ #: ../wr2x_ajax.php:60
38
+ msgid "Nothing to do ;)"
39
+ msgstr "Niente altro da fare ;)"
40
+
41
+ #: ../wr2x_ajax.php:110 ../wr2x_retina-dashboard.php:247
42
+ msgid "GENERATE"
43
+ msgstr "GENERA"
44
+
45
+ #: ../wr2x_ajax.php:258 ../wr2x_ajax.php:287
46
+ msgid "The attachment ID is missing."
47
+ msgstr ""
48
+
49
+ #: ../wr2x_ajax.php:275
50
+ msgid "Retina files deleted."
51
+ msgstr "File Retina cancellati."
52
+
53
+ #: ../wr2x_ajax.php:305
54
+ msgid "Retina files generated."
55
+ msgstr "File Retina generati."
56
+
57
+ #: ../wr2x_ajax.php:316
58
+ msgid "You do not have permission to upload files."
59
+ msgstr "Non si hanno permessi sufficienti per caricare file."
60
+
61
+ #: ../wr2x_ajax.php:332
62
+ #, fuzzy
63
+ msgid "You don't have the rights to use a temporary directory."
64
+ msgstr "Non si hanno permessi sufficienti per caricare file."
65
+
66
+ #: ../wr2x_ajax.php:337
67
+ msgid "The temporary directory could not be created."
68
+ msgstr ""
69
+
70
+ #: ../wr2x_ajax.php:352
71
+ msgid "The file is not an image or the upload went wrong."
72
+ msgstr "Il file non è un'immagine o l'upload è fallito."
73
+
74
+ #: ../wr2x_ajax.php:362
75
+ msgid "You cannot use this file (wrong extension? wrong type?)."
76
+ msgstr "Non si può utilizzare questo file (estensione errata? tipo errato?)."
77
+
78
+ #: ../wr2x_ajax.php:411
79
+ msgid "Replaced successfully."
80
+ msgstr "Sostituzione avvenuta con successo."
81
+
82
+ #: ../wr2x_retina-dashboard.php:19
83
+ msgid "Retina images"
84
+ msgstr "Immagini Retina"
85
+
86
+ #: ../wr2x_retina-dashboard.php:20
87
+ #, php-format
88
+ msgid "Retina %s"
89
+ msgstr "Retina %s"
90
+
91
+ #: ../wr2x_retina-dashboard.php:132
92
+ msgid "Generate"
93
+ msgstr "Genera"
94
+
95
+ #: ../wr2x_retina-dashboard.php:146
96
+ msgid "Delete all @2x"
97
+ msgstr "Cancella tutti i @2x"
98
+
99
+ #: ../wr2x_retina-dashboard.php:149
100
+ msgid "Refresh issues"
101
+ msgstr "Aggiorna i problemi"
102
+
103
+ #: ../wr2x_retina-dashboard.php:159
104
+ msgid "Issues has been refreshed."
105
+ msgstr "Problemi aggiornati con successo."
106
+
107
+ #: ../wr2x_retina-dashboard.php:164
108
+ msgid ""
109
+ "This screen allows you to check the media for which the retina files are "
110
+ "missing. You can then create the files independently for each media or for "
111
+ "all of them. You can also upload and replace the images by drag & drop them "
112
+ "on the grid."
113
+ msgstr ""
114
+ "Questa schermata consente di controllare i media per i quali mancano i file "
115
+ "retina. È possibile creare i file indipendentemente per ciascun media o "
116
+ "insieme per tutti. È anche possibile caricare e sostituire le immagini "
117
+ "trascinandole sulla griglia."
118
+
119
+ #: ../wr2x_retina-dashboard.php:179
120
+ msgid "All"
121
+ msgstr "Tutti"
122
+
123
+ #: ../wr2x_retina-dashboard.php:180
124
+ msgid "Issues"
125
+ msgstr "Problemi"
126
+
127
+ #: ../wr2x_retina-dashboard.php:181
128
+ msgid "Ignored"
129
+ msgstr "Ignorati"
130
+
131
+ #: ../wr2x_retina-dashboard.php:187
132
+ msgid "Title"
133
+ msgstr "Titolo"
134
+
135
+ #: ../wr2x_retina-dashboard.php:195
136
+ msgid "Actions"
137
+ msgstr "Azioni"
138
+
139
+ #: ../wr2x_retina-dashboard.php:250
140
+ msgid "IGNORE"
141
+ msgstr "IGNORA"
142
+
143
+ #: ../wr2x_settings.php:18 ../wr2x_settings.php:21
144
+ msgid "Current method:"
145
+ msgstr "Metodo corrente:"
146
+
147
+ #: ../wr2x_settings.php:18 ../wr2x_settings.php:106
148
+ msgid "Client side"
149
+ msgstr "Lato client"
150
+
151
+ #: ../wr2x_settings.php:21 ../wr2x_settings.php:107
152
+ msgid "Server side"
153
+ msgstr "Lato server"
154
+
155
+ #: ../wr2x_settings.php:26
156
+ msgid ""
157
+ "By the way, you are using a <b>WordPress Multi-Site installation</b>! You "
158
+ "must edit your .htaccess manually and add '<b>RewriteRule ^files/(.+) wp-"
159
+ "content/plugins/wp-retina-2x/wr2x_image.php?ms=true&file=$1 [L]</b>' as the "
160
+ "first RewriteRule if you want the server-side to work."
161
+ msgstr ""
162
+ "A proposito, è in uso un'<b>installazione WordPress Multi-Site</b>! È "
163
+ "necessario modificare manualmente .htaccess e aggiungere '<b>RewriteRule "
164
+ "^files/(.+) wp-content/plugins/wp-retina-2x/wr2x_image.php?ms=true&file=$1 "
165
+ "[L]</b>' come la prima RewriteRule se si vuol far funzionare il metodo lato-"
166
+ "server."
167
+
168
+ #: ../wr2x_settings.php:29
169
+ #, fuzzy
170
+ msgid ""
171
+ "By the way, you are using a <b>WordPress Multi-Site installation</b>! You "
172
+ "must edit your .htaccess manually and add '<b>RewriteRule ^(wp-content/.+\\."
173
+ "(png|gif|jpg|jpeg|bmp|PNG|GIF|JPG|JPEG|BMP)) wp-content/plugins/wp-retina-2x/"
174
+ "wr2x_image.php?ms=true&file=$1 [L]</b>' as the first RewriteRule if you want "
175
+ "the server-side to work."
176
+ msgstr ""
177
+ "A proposito, è in uso un'<b>installazione WordPress Multi-Site</b>! È "
178
+ "necessario modificare manualmente .htaccess e aggiungere '<b>RewriteRule "
179
+ "^files/(.+) wp-content/plugins/wp-retina-2x/wr2x_image.php?ms=true&file=$1 "
180
+ "[L]</b>' come la prima RewriteRule se si vuol far funzionare il metodo lato-"
181
+ "server."
182
+
183
+ #: ../wr2x_settings.php:33
184
+ msgid ""
185
+ "The permalinks are not enabled. They need to be enabled in order to use the "
186
+ "server-side method."
187
+ msgstr ""
188
+ "I permalink non sono abilitati. È necessario abilitarli per poter usare il "
189
+ "metodo lato-server."
190
+
191
+ #: ../wr2x_settings.php:62
192
+ msgid "Basics"
193
+ msgstr "Generale"
194
+
195
+ #: ../wr2x_settings.php:66
196
+ msgid "Advanced"
197
+ msgstr "Avanzate"
198
+
199
+ #: ../wr2x_settings.php:79
200
+ msgid "Disabled Sizes"
201
+ msgstr "Dimensioni Disabilitate"
202
+
203
+ #: ../wr2x_settings.php:80
204
+ msgid "The checked sizes will not be generated for Retina displays."
205
+ msgstr "Le dimensioni selezionate non verranno generate per i display Retina."
206
+
207
+ #: ../wr2x_settings.php:86
208
+ msgid "Auto Generate"
209
+ msgstr "Generazione Automatica"
210
+
211
+ #: ../wr2x_settings.php:87
212
+ msgid ""
213
+ "Generate Retina images automatically when images are uploaded to the Media "
214
+ "Library."
215
+ msgstr ""
216
+ "Genera automaticamente immagini Retina quando sono caricate nella Libreria "
217
+ "Media "
218
+
219
+ #: ../wr2x_settings.php:95
220
+ msgid "Method"
221
+ msgstr "Metodo"
222
+
223
+ #: ../wr2x_settings.php:97
224
+ #, fuzzy
225
+ msgid ""
226
+ "<br />\n"
227
+ " \t\tThe <b>HTML Rewrite method</b> is probably the best, "
228
+ "especially when used with Cloudflare or Google PageSpeed Service! You cannot "
229
+ "use a basic HTML caching plugin with it (or you have to hack the options "
230
+ "properly). <br /><br />\n"
231
+ " \t\tThe <b>Server-side method</b> is very fast and "
232
+ "efficient. However, depending on the hosting and cache system you are using "
233
+ "(including services like Cloudflare) you might encounter issues.<br /><br /"
234
+ ">\n"
235
+ " \t\tThe <b>Client-side method</b> is fail-safe and only uses "
236
+ "a JavaScript file. When a Retina Display is detected, requests for every "
237
+ "images on the page will be sent to the server and a high resolution image "
238
+ "will be retrieved if available. It requires more bandwidth.\n"
239
+ " \t"
240
+ msgstr ""
241
+ "<br />Il <b>metodo lato-server</b> è molto veloce ed efficiente. Comunque, "
242
+ "in base all'hosting e al sistema di cache che si usano (inclusi servizi come "
243
+ "Cloudflare), si potrebbero avere dei problemi.\n"
244
+ " <br /><br />Il <b>metodo lato-client</b> è a prova di errore "
245
+ "e usa soltanto un file JavaScript. Ogni volta che viente rilevato un display "
246
+ "Retina, le richieste per ogni immagine sulla pagina verranno inviate al "
247
+ "server che ricercherà e, se disponibile, invierà un'immagine ad alta "
248
+ "risoluzione. La maggior parte dei siti web (per esempio la Apple) usa questo "
249
+ "metodo."
250
+
251
+ #: ../wr2x_settings.php:105
252
+ msgid "HTML Rewrite"
253
+ msgstr "HTML Rewrite"
254
+
255
+ #: ../wr2x_settings.php:108
256
+ msgid "None"
257
+ msgstr "Nessuno"
258
+
259
+ #: ../wr2x_settings.php:113
260
+ msgid "Quality"
261
+ msgstr ""
262
+
263
+ #: ../wr2x_settings.php:114
264
+ msgid "Image Compression quality (between 0 and 100)."
265
+ msgstr ""
266
+
267
+ #: ../wr2x_settings.php:120
268
+ msgid "Debug Mode"
269
+ msgstr "Modalità debug"
270
+
271
+ #: ../wr2x_settings.php:121
272
+ msgid ""
273
+ "If checked, the client will be always served Retina images. Convenient for "
274
+ "testing."
275
+ msgstr ""
276
+ "Se selezionato, al client saranno sempre servite immagini Retina. Utile per "
277
+ "eseguire test. "
278
+
279
+ #: ../wr2x_settings.php:127
280
+ msgid "Hide 'Retina' column"
281
+ msgstr "Nascondi colonna 'Retina'"
282
+
283
+ #: ../wr2x_settings.php:128
284
+ msgid "Will hide the 'Retina Column' from the Media Library."
285
+ msgstr "Nasconderà la colonna 'Retina' dalla Libreria Media. "
286
+
287
+ #: ../wr2x_settings.php:134
288
+ msgid "Hide Retina Dashboard"
289
+ msgstr "Nascondi Bacheca Retina"
290
+
291
+ #: ../wr2x_settings.php:135
292
+ msgid "Doesn't show the Retina Dashboard menu and tools."
293
+ msgstr "Nasconde i menu e gli strumenti della bacheca Retina."
294
+
295
+ #: ../wr2x_settings.php:141
296
+ #, fuzzy
297
+ msgid "Ignore Mobile"
298
+ msgstr "Ignorati"
299
+
300
+ #: ../wr2x_settings.php:142
301
+ msgid "Doesn't deliver Retina images to mobiles."
302
+ msgstr ""
303
+
304
+ #~ msgid "Titre"
305
+ #~ msgstr "Titolo"
trunk/languages/wp-retina-2x-sv_SE.mo ADDED
Binary file
trunk/languages/wp-retina-2x-sv_SE.po ADDED
@@ -0,0 +1,363 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: WP Retina 2x\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2013-08-12 16:42+0200\n"
6
+ "PO-Revision-Date: 2013-08-12 16:51+0200\n"
7
+ "Last-Translator: Marcus Forsberg <info@marcusforsberg.net>\n"
8
+ "Language-Team: Jordy Meow <work@meow.fr>\n"
9
+ "Language: fr_FR\n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Poedit-KeywordsList: _e;__\n"
14
+ "X-Poedit-Basepath: ../\n"
15
+ "X-Generator: Poedit 1.5.7\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: wr2x_ajax.php:39
20
+ msgid "Done. Please <a href='javascript:history.go(0)'>refresh</a> this page."
21
+ msgstr ""
22
+ "Färdigt. Vänligen <a href='javascript:history.go(0)'>ladda om</a> denna sida."
23
+
24
+ #: wr2x_ajax.php:42
25
+ msgid ""
26
+ "Done. You might want to <a href='?page=wp-"
27
+ "retina-2x&view=issues&refresh=true'>refresh</a> the issues."
28
+ msgstr ""
29
+ "Färdigt. Du kanske vill <a href='?page=wp-"
30
+ "retina-2x&view=issues&refresh=true'>ladda om</a> problemen."
31
+
32
+ #: wr2x_ajax.php:52 wr2x_ajax.php:103
33
+ msgid "Please wait..."
34
+ msgstr "Var god vänta..."
35
+
36
+ #: wr2x_ajax.php:60
37
+ msgid "Nothing to do ;)"
38
+ msgstr "Inget att göra ;)"
39
+
40
+ #: wr2x_ajax.php:110 wr2x_retina-dashboard.php:247
41
+ msgid "GENERATE"
42
+ msgstr "GENERERA"
43
+
44
+ #: wr2x_ajax.php:258 wr2x_ajax.php:287
45
+ msgid "The attachment ID is missing."
46
+ msgstr "ID för den bifogade filen saknas."
47
+
48
+ #: wr2x_ajax.php:275
49
+ msgid "Retina files deleted."
50
+ msgstr "Retinafilder raderade."
51
+
52
+ #: wr2x_ajax.php:305
53
+ msgid "Retina files generated."
54
+ msgstr "Retinafiler genererade."
55
+
56
+ #: wr2x_ajax.php:316
57
+ msgid "You do not have permission to upload files."
58
+ msgstr "Du har inte rätt att ladda upp filer."
59
+
60
+ #: wr2x_ajax.php:332
61
+ msgid "You don't have the rights to use a temporary directory."
62
+ msgstr "Du har inte rättigheterna som krävs för att använda en temporär mapp."
63
+
64
+ #: wr2x_ajax.php:337
65
+ msgid "The temporary directory could not be created."
66
+ msgstr "Den temporära mappen kunde inte skapas."
67
+
68
+ #: wr2x_ajax.php:352
69
+ msgid "The file is not an image or the upload went wrong."
70
+ msgstr "Filen är inte en bild eller så gick uppladdningen fel."
71
+
72
+ #: wr2x_ajax.php:362
73
+ msgid "You cannot use this file (wrong extension? wrong type?)."
74
+ msgstr "Du kan inte använda den här filen (fel filtyp?)."
75
+
76
+ #: wr2x_ajax.php:411
77
+ msgid "Replaced successfully."
78
+ msgstr "Ersattes uttan problem."
79
+
80
+ #: wr2x_retina-dashboard.php:19
81
+ msgid "Retina images"
82
+ msgstr "Retinabilder"
83
+
84
+ #: wr2x_retina-dashboard.php:20
85
+ #, php-format
86
+ msgid "Retina %s"
87
+ msgstr "Retina %s"
88
+
89
+ #: wr2x_retina-dashboard.php:132
90
+ msgid "Generate"
91
+ msgstr "Generera"
92
+
93
+ #: wr2x_retina-dashboard.php:146
94
+ msgid "Delete all @2x"
95
+ msgstr "Radera alla @2x"
96
+
97
+ #: wr2x_retina-dashboard.php:149
98
+ msgid "Refresh issues"
99
+ msgstr "Ladda om problem"
100
+
101
+ #: wr2x_retina-dashboard.php:159
102
+ msgid "Issues has been refreshed."
103
+ msgstr "Problemen har laddats om."
104
+
105
+ #: wr2x_retina-dashboard.php:164
106
+ msgid ""
107
+ "This screen allows you to check the media for which the retina files are "
108
+ "missing. You can then create the files independently for each media or for "
109
+ "all of them. You can also upload and replace the images by drag & drop them "
110
+ "on the grid."
111
+ msgstr ""
112
+ "Den här sidan låter dig undersöka vilka mediafiler som saknar retinaversion. "
113
+ "Du kan sedan skapa retinafiler för individuella objekt eller för alla på en "
114
+ "gång. Du kan också ladda upp och ersätta bilderna genom att dra och släppa "
115
+ "dem på rutnätet."
116
+
117
+ #: wr2x_retina-dashboard.php:179
118
+ msgid "All"
119
+ msgstr "Alla"
120
+
121
+ #: wr2x_retina-dashboard.php:180
122
+ msgid "Issues"
123
+ msgstr "Problem"
124
+
125
+ #: wr2x_retina-dashboard.php:181
126
+ msgid "Ignored"
127
+ msgstr "Ignorerade"
128
+
129
+ #: wr2x_retina-dashboard.php:187
130
+ msgid "Title"
131
+ msgstr "Titel"
132
+
133
+ #: wr2x_retina-dashboard.php:195
134
+ msgid "Actions"
135
+ msgstr "Handlingar"
136
+
137
+ #: wr2x_retina-dashboard.php:250
138
+ msgid "IGNORE"
139
+ msgstr "IGNORERA"
140
+
141
+ #: wr2x_settings.php:18 wr2x_settings.php:21
142
+ msgid "Current method:"
143
+ msgstr "Nuvarande metod:"
144
+
145
+ #: wr2x_settings.php:18 wr2x_settings.php:106
146
+ msgid "Client side"
147
+ msgstr "Klientmetod"
148
+
149
+ #: wr2x_settings.php:21 wr2x_settings.php:107
150
+ msgid "Server side"
151
+ msgstr "Servermetod"
152
+
153
+ #: wr2x_settings.php:26
154
+ msgid ""
155
+ "By the way, you are using a <b>WordPress Multi-Site installation</b>! You "
156
+ "must edit your .htaccess manually and add '<b>RewriteRule ^files/(.+) wp-"
157
+ "content/plugins/wp-retina-2x/wr2x_image.php?ms=true&file=$1 [L]</b>' as the "
158
+ "first RewriteRule if you want the server-side to work."
159
+ msgstr ""
160
+ "Förresten, du använder en <b>WordPress Multi-Site-installation</b! Du måste "
161
+ "manuellt ändra din .htaccess-fil och lägga till '<b>RewriteRule ^files/(.+) "
162
+ "wp-content/plugins/wp-retina-2x/wr2x_image.php?ms=true&file=$1 [L]</b>' som "
163
+ "första RewriteRule om du vill att servermetoden ska fungera."
164
+
165
+ #: wr2x_settings.php:29
166
+ msgid ""
167
+ "By the way, you are using a <b>WordPress Multi-Site installation</b>! You "
168
+ "must edit your .htaccess manually and add '<b>RewriteRule ^(wp-content/.+\\."
169
+ "(png|gif|jpg|jpeg|bmp|PNG|GIF|JPG|JPEG|BMP)) wp-content/plugins/wp-retina-2x/"
170
+ "wr2x_image.php?ms=true&file=$1 [L]</b>' as the first RewriteRule if you want "
171
+ "the server-side to work."
172
+ msgstr ""
173
+ "Förresten, du använder en <b>WordPress Multi-Site-installation</b! Du måste "
174
+ "manuellt ändra din .htaccess-fil och lägga till '<b>RewriteRule ^(wp-"
175
+ "content/.+\\.(png|gif|jpg|jpeg|bmp|PNG|GIF|JPG|JPEG|BMP)) wp-content/plugins/"
176
+ "wp-retina-2x/wr2x_image.php?ms=true&file=$1 [L]</b>' som första RewriteRule "
177
+ "om du vill att servermetoden ska fungera."
178
+
179
+ #: wr2x_settings.php:33
180
+ msgid ""
181
+ "The permalinks are not enabled. They need to be enabled in order to use the "
182
+ "server-side method."
183
+ msgstr ""
184
+ "Permalänkarna är inte aktiverade. De måste vara aktiva för att servermetoden "
185
+ "ska fungera."
186
+
187
+ #: wr2x_settings.php:62
188
+ msgid "Basics"
189
+ msgstr "Grundläggande"
190
+
191
+ #: wr2x_settings.php:66
192
+ msgid "Advanced"
193
+ msgstr "Avancerat"
194
+
195
+ #: wr2x_settings.php:79
196
+ msgid "Disabled Sizes"
197
+ msgstr "Inaktiverade storlekar"
198
+
199
+ #: wr2x_settings.php:80
200
+ msgid "The checked sizes will not be generated for Retina displays."
201
+ msgstr "De markerade storlekarna kommer inte att generera retinabilder."
202
+
203
+ #: wr2x_settings.php:86
204
+ msgid "Auto Generate"
205
+ msgstr "Generera automatiskt"
206
+
207
+ #: wr2x_settings.php:87
208
+ msgid ""
209
+ "Generate Retina images automatically when images are uploaded to the Media "
210
+ "Library."
211
+ msgstr ""
212
+ "Generera retinabilder automatiskt när bilder laddas upp till "
213
+ "mediabiblioteket."
214
+
215
+ #: wr2x_settings.php:95
216
+ msgid "Method"
217
+ msgstr "Metod"
218
+
219
+ #: wr2x_settings.php:97
220
+ msgid ""
221
+ "<br />\n"
222
+ " \t\tThe <b>HTML Rewrite method</b> is probably the best, "
223
+ "especially when used with Cloudflare or Google PageSpeed Service! You cannot "
224
+ "use a basic HTML caching plugin with it (or you have to hack the options "
225
+ "properly). <br /><br />\n"
226
+ " \t\tThe <b>Server-side method</b> is very fast and "
227
+ "efficient. However, depending on the hosting and cache system you are using "
228
+ "(including services like Cloudflare) you might encounter issues.<br /><br /"
229
+ ">\n"
230
+ " \t\tThe <b>Client-side method</b> is fail-safe and only uses "
231
+ "a JavaScript file. When a Retina Display is detected, requests for every "
232
+ "images on the page will be sent to the server and a high resolution image "
233
+ "will be retrieved if available. It requires more bandwidth.\n"
234
+ " \t"
235
+ msgstr ""
236
+ "<br />\n"
237
+ " \t\tMetoden <b>Skriv om HTML</b> är troligen bäst, speciellt "
238
+ "om du använder den tillsammans med Cloudflare eller Google PageSpeed "
239
+ "Service! Du kan inte använda något grundläggande HTML-cache-tillägg med "
240
+ "denna metod (om du inte ändrar inställningarna rätt). <br /><br />\n"
241
+ " \t\t<b>Servermetoden</b> är väldigt snabb och effektiv. Men "
242
+ "beroende på ditt webbhotell och cachesystem (inklusive tjänster som "
243
+ "Cloudflare) kan du komma att råka på problem.<br /><br />\n"
244
+ " \t\t<b>Klientmetoden</b> är felsäker och använder bara en "
245
+ "JavaScript-fil. När en Retinaskärm upptäcks skickas en förfrågan för varje "
246
+ "bild på sidan till servern och en högupplöst bild hämtas om någon finns "
247
+ "tillgänglig. Detta kräver högre bandbredd.\n"
248
+ " \t"
249
+
250
+ #: wr2x_settings.php:105
251
+ msgid "HTML Rewrite"
252
+ msgstr "Skriv om HTML"
253
+
254
+ #: wr2x_settings.php:108
255
+ msgid "None"
256
+ msgstr "Ingen"
257
+
258
+ #: wr2x_settings.php:113
259
+ msgid "Quality"
260
+ msgstr "Kvalitet"
261
+
262
+ #: wr2x_settings.php:114
263
+ msgid "Image Compression quality (between 0 and 100)."
264
+ msgstr "Kvalitet på bildkomprimering (mellan 0 och 100)"
265
+
266
+ #: wr2x_settings.php:120
267
+ msgid "Debug Mode"
268
+ msgstr "Felsökningsläge"
269
+
270
+ #: wr2x_settings.php:121
271
+ msgid ""
272
+ "If checked, the client will be always served Retina images. Convenient for "
273
+ "testing."
274
+ msgstr ""
275
+ "När detta är markerat skickas alltid retinabilder till klienten. Användbart "
276
+ "för att testa."
277
+
278
+ #: wr2x_settings.php:127
279
+ msgid "Hide 'Retina' column"
280
+ msgstr "Dölj \"Retina\"-kolumn"
281
+
282
+ #: wr2x_settings.php:128
283
+ msgid "Will hide the 'Retina Column' from the Media Library."
284
+ msgstr "Döljer 'retinakolumnen' från mediabiblioteket."
285
+
286
+ #: wr2x_settings.php:134
287
+ msgid "Hide Retina Dashboard"
288
+ msgstr "Dölj retinapanel"
289
+
290
+ #: wr2x_settings.php:135
291
+ msgid "Doesn't show the Retina Dashboard menu and tools."
292
+ msgstr "Visar inte retinapanelen eller verktygen."
293
+
294
+ #: wr2x_settings.php:141
295
+ msgid "Ignore Mobile"
296
+ msgstr "Ignorera mobiler"
297
+
298
+ #: wr2x_settings.php:142
299
+ msgid "Doesn't deliver Retina images to mobiles."
300
+ msgstr "Leverar inte retinabilder till mobiler."
301
+
302
+ #~ msgid "Titre"
303
+ #~ msgstr "Titre"
304
+
305
+ #~ msgid ""
306
+ #~ "Current method: <u>Server-side</u>.</span> Oh, and don't forget to check "
307
+ #~ "the tutorial of this plugin on <a href='http://www.totorotimes.com/news/"
308
+ #~ "retina-display-wordpress-plugin'>Totoro Times</a>."
309
+ #~ msgstr ""
310
+ #~ "Méthode sélectionnée: <u>Server-side</u>.</span> Oh, n'oubliez pas de "
311
+ #~ "lire mon tutoriel sur ce plugin sur <a href='http://www.totorotimes.com/"
312
+ #~ "news/retina-display-wordpress-plugin'>Totoro Times</a>."
313
+
314
+ #~ msgid "Done."
315
+ #~ msgstr "Terminé."
316
+
317
+ #~ msgid "ERROR"
318
+ #~ msgstr "ERREUR"
319
+
320
+ #~ msgid "Not created yet."
321
+ #~ msgstr "Pas encore créé."
322
+
323
+ #~ msgid "Generate for all files"
324
+ #~ msgstr "Générer tous les fichiers"
325
+
326
+ #~ msgid ""
327
+ #~ "By the way, you are also using a <b>WordPress Network installation</b>. "
328
+ #~ "The server-side might not work for you, so <b>please try the client-side "
329
+ #~ "method instead</b>. If you really want to use this method, you will have "
330
+ #~ "to work on your .htaccess manually."
331
+ #~ msgstr ""
332
+ #~ "Vous utilisez une version de WordPress <b>Multisite</b>. Il est possible "
333
+ #~ "que la méthode côté serveur ne fonctionne pas, alors dans ce cas essayé "
334
+ #~ "la méthode <b>côté client</b>. Si vous voulez vraiment utiliser cette "
335
+ #~ "méthode, vous aurez peut-être besoin de bidouiller votre .htaccess "
336
+ #~ "manuellement."
337
+
338
+ #~ msgid ""
339
+ #~ "This plugin supports and uses the <a href='http://wordpress.org/extend/"
340
+ #~ "plugins/enable-media-replace/'>Enable Media Replace</a> plugin if "
341
+ #~ "available. A 'Replace' button will appear in case your images are too "
342
+ #~ "small. It is strongly recommended to install it."
343
+ #~ msgstr ""
344
+ #~ "WP Retina 2x peut automatiquement utiliser le plugin <a href='http://"
345
+ #~ "wordpress.org/extend/plugins/enable-media-replace/'>Enable Media Replace</"
346
+ #~ "a> si il est installé. Un bouton 'Réuploader' apparaîtra alors lorsque "
347
+ #~ "l'image originale est trop petite."
348
+
349
+ #~ msgid ""
350
+ #~ "This plugin is actively developped and maintained by <a href='https://"
351
+ #~ "plus.google.com/106075761239802324012'>Jordy Meow</a>.<br />Please visit "
352
+ #~ "me at <a href='http://www.totorotimes.com'>Totoro Times</a>, a website "
353
+ #~ "about Japan, photography and abandoned places.<br />And thanks for "
354
+ #~ "linking us on <a href='https://www.facebook.com/totorotimes'>Facebook</a> "
355
+ #~ "and <a href='https://plus.google.com/106832157268594698217'>Google+</a> :)"
356
+ #~ msgstr ""
357
+ #~ "Ce plugin est activement développé et maintenu par <a href='https://plus."
358
+ #~ "google.com/106075761239802324012'>Jordy Meow</a>.<br />Merci de me "
359
+ #~ "visiter sur <a href='http://www.totorotimes.fr'>Totoro Times</a>, un site "
360
+ #~ "sur le Japan, la photographie et les endroits abandonnés.<br />Et merci "
361
+ #~ "de nous adorer sur <a href='https://www.facebook.com/"
362
+ #~ "totorotimes'>Facebook</a> et <a href='https://plus.google."
363
+ #~ "com/106832157268594698217'>Google+</a> :)"
trunk/loading.gif ADDED
Binary file
trunk/media-library.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Meow_WR2X_MediaLibrary {
4
+
5
+ public $core = null;
6
+
7
+ public function __construct( $core ) {
8
+ $this->core = $core;
9
+ add_filter( 'manage_media_columns', array( $this, 'manage_media_columns' ) );
10
+ add_action( 'manage_media_custom_column', array( $this, 'manage_media_custom_column' ), 10, 2 );
11
+ add_action( 'admin_footer', array( $this, 'admin_footer_library' ) );
12
+ }
13
+
14
+ function manage_media_columns( $cols ) {
15
+ $cols["Retina"] = "Retina";
16
+ return $cols;
17
+ }
18
+
19
+ function manage_media_custom_column( $column_name, $id ) {
20
+ if ( $column_name == 'Retina' ) {
21
+ $info = $this->core->retina_info( $id );
22
+ if ( empty( $info ) )
23
+ return;
24
+ $info = $this->core->html_get_basic_retina_info( $id, $info );
25
+ echo "<a style='' onclick='wr2x_generate(" . $id . ", true)' id='wr2x_generate_button_" .
26
+ $id . "' class='wr2x-button'>" . __( "GENERATE", 'wp-retina-2x' ) . "</a><br />";
27
+ echo '<div class="wr2x-info" postid="' . $id . '" id="wr2x-info-' . $id . '">';
28
+ echo $info;
29
+ echo '</div>';
30
+ }
31
+ else if ( $column_name == 'Retina-Actions' ) {
32
+ }
33
+ }
34
+
35
+ function admin_footer_library() {
36
+ $screen = get_current_screen();
37
+ if ( $screen->base != 'upload' && $screen->base != 'media_page_wp-retina-2x' )
38
+ return;
39
+ ?>
40
+ <div id="meow-modal-info-backdrop" style="display: none;">
41
+ </div>
42
+
43
+ <div id="meow-modal-info" style="display: none;" tabindex="1">
44
+ <div class="close">X</div>
45
+ <h2 style="margin-top: 0px;">Retina Details</h2>
46
+ <div class="loading">
47
+ <img src="<?php echo plugin_dir_url( __FILE__ ); ?>loading.gif" />
48
+ </div>
49
+ <div class="content">
50
+ </div>
51
+ </div>
52
+ <?php
53
+ }
54
+
55
+ }
56
+
57
+
58
+ ?>
trunk/readme.txt ADDED
@@ -0,0 +1,264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === WP Retina 2x ===
2
+ Contributors: TigrouMeow
3
+ Tags: retina, images, image, responsive, lazysizes, lazy, attachment, media, files, iphone, ipad, high-dpi
4
+ Requires at least: 3.5
5
+ Tested up to: 4.9
6
+ Stable tag: 5.2.9
7
+
8
+ Make your website look beautiful and crisp on modern displays by creating and displaying retina images. WP 4.4+ is also supported and enhanced.
9
+
10
+ == Description ==
11
+
12
+ This plugin does two things: it creates the image files required by the High-DPI devices and it displays them to your visitors accordingly. Your website will look beautiful and crisp on every device! The retina images will be generated for you automatically (though you can also do it manually) and served to the retina devices. The concept of retina images for full-size images is also a very unique feature which is only provided by this plugin (which is why it became unique).
13
+
14
+ **Retina Methods**. It supports different methods to serve the images to your visitors. Why? Depending on the theme and plugins you are using (and also the way you use images in your website), not all the methods can work. Ideally, I would recommend using the Responsive Images method, then if it doesn't work, the PictureFill method (which covers normally most cases). Retina.js should be the fallback method. There are more methods than this with their specific options.
15
+
16
+ **Plug & Play**. With a well-made theme and website, this plugin doesn't require normally any specific set-up. All the defaults settings are fine. Works with multi-site and many kinds of installs.
17
+
18
+ **Optimized**. The plugin is very fast and optimized. It doesn't create anything in the database.
19
+
20
+ **Pro**. When activated, the Pro version adds support for Retina for full-size, support for lazy-loading for your responsive images and various options. And it supports my work :)
21
+
22
+ **Responsive Images**. WP has support for Responsive Images and this plugin handles this nicely by adding the retina images in the src-set created by WordPress. The HTML for the images not handled by WP 4.4 (outside posts) will also be handled by the plugin (pick "Picturefill" method for this). The plugin also provides an option to disable the 'Medium Large' created by WordPress which is actually not useful (it's a hack basically), this plugin does it better.
23
+
24
+ **CSS & Background Images**. The plugin cannot inject CSS to handles the images added through CSS, that's both too dangerous and potentially very incorrect. However, in its Pro version and with PictureFill, you get an option to replace the inline CSS background image by their retina equivalent.
25
+
26
+ More information and tutorial available one https://meowapps.com/wp-retina-2x/.
27
+
28
+ = Quickstart =
29
+
30
+ 1. Set your option (for instance, you probably don't need retina images for every sizes set-up in your WP).
31
+ 2. Generate the retina images (required only the first time, then images are generated automatically).
32
+ 3. Check if it works! - if it doesn't, read the FAQ, the tutorial, and check the forums.
33
+
34
+ == Changelog ==
35
+
36
+ = 5.2.9 =
37
+ * Add: New option to Regenerate Thumbnails.
38
+ * Fix: Tiny CSS fix, and update fix.
39
+ * Important: A few options will be removed in the near future. Have a look at this: https://wordpress.org/support/topic/simplifying-wp-retina-2x-by-removing-options/.
40
+
41
+ = 5.2.8 =
42
+ * Fix: Security update.
43
+ * Update: Lazysizes 4.0.3.
44
+
45
+ = 5.2.6 =
46
+ * Fix: Avoid re-generating non-retina thumbnails when Generate is used.
47
+ * Fix: Use ___DIR___ to include plugin's files.
48
+ * Fix: Better explanation.
49
+
50
+ = 5.2.3 =
51
+ * Fix: Sanitization to avoid cross-site scripting.
52
+ * Fix: Additional security fixes.
53
+
54
+ = 5.2.0 =
55
+ * Fix: When metadata is broken, displays a message.
56
+ * Fix: A few icons weren't displayed nicely.
57
+ * Fix: When metadata is broken, displays a message.
58
+ * Update: From Lazysizes 3.0 to 4.0.1.
59
+ * Add: Option for forcing SSL Verify.
60
+
61
+ = 5.1.4 =
62
+ * Add: wr2x_retina_extension, wr2x_delete_attachment, wr2x_get_pathinfo_from_image_src, wr2x_picture_rewrite in the API.
63
+
64
+ = 5.0.5 =
65
+ * Fix: There was a issue with the .htaccess rewriting (Class ‘Meow_Admin’ not found).
66
+ * Update: Core was totally re-organized and cleaned. Ready for nice updates.
67
+ * Update: LazyLoading from version 2.0 to 3.0.
68
+ * Info: There will be an important warning showing up during this update. It is an important annoucement.
69
+
70
+ = 4.8.0 =
71
+ * Add: Retina Image Quality for JPG (between 0 and 100). I know this little setting was really wanted :)
72
+ * Fix: Disabled sizes weren't really disabled in the UI.
73
+ * Fix: Notices about Ignore appearing in other screens.
74
+ * Add: Handles incompatibility with JetPack's Photon.
75
+ * Info: If you are using Lightroom, please have a look at my plugin for synchronizing your Lightroom to WordPress: https://meowapps.com/wplr-sync/. And if youi love my Retina plugin, please write a little review here: https://wordpress.org/support/plugin/wp-retina-2x/reviews/?rate=5#new-post. Thank you :)
76
+
77
+ = 4.7.7 =
78
+ * Add: The Generate button (and the bulk Generate) will now also Re-Generate the thumbnails as well (like the Renerate Thumbnails plugin). If you are interested in a option to disable this behavior, please say so in the WP forums.
79
+
80
+ = 4.7.6 =
81
+ * Fix: Issue with Pro being non-Pro outside of WP Admin.
82
+ * Fix: Retina debugging file was not being created properly.
83
+
84
+ = 4.7.5 =
85
+ * Fix: Don't delete the full-size Retina if we re-generate.
86
+ * Fix: Little issue with Ignore.
87
+ * Update: Additional debugging.
88
+ * Info: Please write a review for the plugin if you are happy with it. I am trying my best to make this plugin to work with every kind of WP install and system :)
89
+
90
+ = 4.7.4 =
91
+ * Update: Retina was moved into a new Meow Apps menu. The whole Meow Apps menu can be then hidden. For a nicer WP admin. The whole admin UI was updated.
92
+ * Add: New PictureFill option: inline CSS background can be now replaced by Retina images (excellent for sliders for example).
93
+ * Add: Over HTTP Check option: check for retina image remotely, for example if you are using images from a different website or server, it will check for the Retina version. Works with the PictureFill method.
94
+ * Change: Mobile detection was completely turned off as I don't think it should be used, but let's see if some of yours still need it. Ideally I would like to remove it from the code.
95
+ * Fix: Check if the CDN is already present before modifying/adding.
96
+
97
+ = 4.6.0 =
98
+ * Fix: Button Details was not working properly.
99
+ * Fix: Removed the beta Retina Uploader which is not working yet (was included by mistake).
100
+ * Update: Added the info screen available in the Retina Dashboard in the Media Library as well and improved the UI a tiny bit (it was a bit messy if you had a lot of image sizes.)
101
+
102
+ = 4.5.8 =
103
+ * Update: LazyLoad 2.0.3
104
+ * Fix: Don't display Retina information for a media that is not an image.
105
+ * Update: Retina.js 2.0.0
106
+ * Fix: Drag & Drop upload was a bit buggy, it now has been improved a lot!
107
+ * Add: Option to hide the ads, flatter and message about the Pro.
108
+ * Update: Options styles.
109
+
110
+ = 4.4.6 =
111
+ * Update: LazyLoad 1.5
112
+ * Update: Retina.js 1.4
113
+ * Update: PictureFill JS 3.0.2
114
+ * Fix: LazyLoad was not playing well when WordPress creates the src-set by itself.
115
+ * Fix: Get the right max-upload size when using HHVM.
116
+ * Fix: Displays an error in the dashboard when the server-side fails to process uploads.
117
+ * Update: During bulk, doesn't stop in case of errors anymore but display an errors counter.
118
+ * Update: Ignore Responsive Images support if the media ID is not existent (in case of broken HTML).
119
+
120
+ = 4.4.0 =
121
+ * Info: Please read my blog post about WP 4.4 + Retina on https://meowapps.com/wordpress-4-4-retina/.
122
+ * Add: New "Responsive Images" method.
123
+ * Add: Lot more information is available in the Retina settings, to help the newbies :)
124
+ * Update: Headers are compliant to WP 4.4.
125
+ * Update: Dashboard has been revamped for Pro users. Standard users can still use Bulk functions.
126
+ * Update: Support for WP 4.4.
127
+
128
+ = 3.5.2 =
129
+ * Fix: Search string not null but empty induces error.
130
+ * Change: User Agent used for Pro authentication.
131
+ * Fix: Issues with class containing trailing spaces. Fixed in in SimpleHTMLDOM.
132
+ * Fix: Used to show weird numbers when using 9999 as width or height.
133
+ * Add: Filter and default filter to avoid certain IMG SRC to be checked/parsed by the plugin while rendering.
134
+
135
+ = 3.4.2 =
136
+ * Fix: Full-Size Retina wasn't removed when the original file was deleted from WP.
137
+ * Fix: Images set up with a 0x0 size must be skipped.
138
+ * Fix: There was an issue if the class starts with a space (broken HTML), plugin automatically fix it on the fly.
139
+ * Fix: Full-Size image had the wrong path in the Details screen.
140
+ * Fix: Option Auto Generate was wrongly show unchecked even though it is active by default.
141
+ * Update: Moved the filters to allow developers to use files hosted on another server.
142
+ * Update: Translation strings. If you want to translate the plugin in your language, please contact me :)
143
+
144
+ = 3.3.6 =
145
+ * Fix: There was an issue with local path for a few installs.
146
+ * Add: Introduced $wr2x_extra_debug for extra developer debug (might be handy).
147
+ * Fix: Issues with retina images outside the uploads directory.
148
+ * Add: Custom CDN Domain support (check the "Custom CDN Domain" option).
149
+ * Fix: Removed a console.log that was forgotten ;)
150
+ * Change: different way of getting the temporary folder to write files (might help in a few cases).
151
+
152
+ = 3.1.0 =
153
+ * Add: Lazy-loading option for PictureFill (Pro).
154
+ * Fix: For the Pro users having the IXR_client error.
155
+ * Fix: Plugin now works even behind a proxy.
156
+ * Fix: Little UI bug while uploading a new image.
157
+ * Add: In the dashboard, added tooltips showing the sizes of the little squares on hover.
158
+ * Fix: The plugin was not compatible with Polylang, now it works.
159
+
160
+ = 3.0.0 =
161
+ * Add: Link to logs from the dashboard (if logs are available), and possibility to clear it directly.
162
+ * Add: Replace the Full-Size directly by drag & drop in the box.
163
+ * Add: Support for WPML Media.
164
+ * Change: Picturefill script to 'v2.2.0 - 2014-02-03'.
165
+ * Change: Enhanced logs (in debug mode), much easier to read.
166
+ * Change: Dashboard enhanced, more clear, possibility of having many image sizes on the screen.
167
+ * Fix: Better handing of non-image media and image detection.
168
+ * Fix: Rounding issues always been present, they are now fixed with an 2px error margin.
169
+ * Fix: Warnings and issues in case of broken metadata and images.
170
+ * Add: (PRO) New pop-up screen with detailed information.
171
+ * Add: (PRO) Added Retina for Full-Size with upload feature. Please note that Full-Size Retina also works with the normal version but you will have to manually resize and upload them.
172
+ * Add: (PRO) Option to avoid removing img's src when using PictureFill.
173
+ * Info: The serial for the Pro version can be bought at https://meowapps.com/wp-retina-2x. Thanks for all your support, the plugin is going to be 3 years old this year! :)
174
+
175
+ = 2.6.0 =
176
+ * Add: Support Manual Image Crop, resize the @2x as the user manually cropped them (that's cool!).
177
+ * Change: Name will change little by little to WP Retina X and menus simplified to simply "Retina".
178
+ * Change: Simplification of the dashboard (more is coming).
179
+ * Change: PictureFill updated to 'v2.2.0 - 2014-12-19'.
180
+ * Fix: Issue with the upload directory on some installs.
181
+ * Info: Way more is coming soon to the dashboard, thanks for your patience :)
182
+ * Info: Manual Image Crop received a Pull Request from me to support the Retina cropping but it is not part of their current version yet (1.07). For a version of Manual Image Crop that includes this change, you can use my forked version: https://github.com/tigroumeow/wp-manual-image-crop.
183
+
184
+ = 1.6.0 =
185
+ * Add: HTML srcset method.
186
+
187
+ = 1.0.0 =
188
+ * Change: enhancement of the Retina Dashboard.
189
+ * Change: better management of the 'issues'.
190
+ * Change: handle images with technical problems.
191
+ * Fix: random little fixes again.
192
+ * Change: upload is now HTML5, by drag and drop in the Retina Dashboard!
193
+
194
+ = 0.9.4 =
195
+ * Fix: esthetical issue related to the icons in the Retina dashboard.
196
+ * Fix: warnings when uploading/replacing an image file.
197
+ * Change: Media Replace is not used anymore, the code has been embedded in the plugin directly.
198
+ * Update: to the new version of Retina.js (client-method).
199
+ * Fix: updated rewrite-rule (server-method) that works with multi-site.
200
+ * Fix: support for Network install (multi-site). Thanks to Jeremy (Retina-Images).
201
+
202
+ = 0.3.0 =
203
+ * Fix: was not generating the images properly on multisite WordPress installs.
204
+ * Add: warning message if using the server-side method without the pretty permalinks.
205
+ * Add: warning message if using the server-side method on a multisite WordPress install.
206
+ * Change: the client-method (retina.js) is now used by default.
207
+ * Fix: simplified version of the .htaccess directive.
208
+ * Fix: new version of the client-side method (Retina.js), works 100x faster.
209
+ * Fix: SQL optimization & memory usage huge improvement.
210
+
211
+ = 0.2.2 =
212
+ * Fix: the recommended resolution shown wasn't the most adequate one.
213
+ * Fix: in a few cases, the .htaccess wasn't properly generated.
214
+ * Fix: files were renamed to avoid conflicts.
215
+ * Add: paging for the Retina Dashboard.
216
+ * Add: 'Generate for all files' handles and shows if there are errors.
217
+ * Add: the Retina Dashboard.
218
+ * Add: can now generate Retina files in bulk.
219
+ * Fix: the cropped images were not 'cropped'.
220
+ * Add: The Retina Dashboard and the Media Library's column can be disabled via the settings.
221
+ * Fix: resolved more PHP warning and notices.
222
+
223
+ = 0.1 =
224
+ * Very first release.
225
+
226
+ == Installation ==
227
+
228
+ Quick and easy installation:
229
+
230
+ 1. Upload the folder `wp-retina-2x` to the `/wp-content/plugins/` directory.
231
+ 2. Activate the plugin through the 'Plugins' menu in WordPress.
232
+ 3. Check the settings of WP Retina 2x in the WordPress administration screen.
233
+ 4. Check the Retina Dashboard.
234
+ 6. Read the tutorial about the plugin: <a href='https://meowapps.com/wp-retina-2x/tutorial/'>WP Retina 2x Tutorial</a>.
235
+
236
+ == Frequently Asked Questions ==
237
+
238
+ Users, you will find the FAQ here: https://meowapps.com/wp-retina-2x/faq/.
239
+
240
+ Developers, WP Retina 2x has a little API. Here are a few filters and actions you might want to use.
241
+
242
+ = Functions =
243
+ * wr2x_get_retina_from_url( $url ): return the URL of the retina image (empty string if not found)
244
+ * wr2x_get_retina( $syspath ): return the system path of the retina image (null if not found)
245
+
246
+ = Actions =
247
+ * wr2x_retina_file_added: called when a new retina file is created, 1st argument is $attachment_id (of the media) and second is the $retina_filepath
248
+ * wr2x_retina_file_removed: called when a new retina file is removed, 1st argument is $attachment_id (of the media) and second is the $retina_filepath
249
+
250
+ = Filters =
251
+ * wr2x_img_url: you can check and potentially override the $wr2x_img_url (normal/original image from the src) that will be used in the srcset for 1x
252
+ * wr2x_img_retina_url: you can check and potentially override the $wr2x_img_retina_url (retina image) that will be used in the srcset for 2x
253
+ * wr2x_img_src: you can check and potentially override the $wr2x_img_src that will be used in the img's src (only used in Pro version)
254
+ * wr2x_validate_src: the img src is passed; return it if it is valid, return null if it should be skipped
255
+
256
+ == Upgrade Notice ==
257
+
258
+ None.
259
+
260
+ == Screenshots ==
261
+
262
+ 1. Retina Dashboard
263
+ 2. Basic Settings
264
+ 3. Advanced Settings
trunk/wp-retina-2x.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: WP Retina 2x
4
+ Plugin URI: https://meowapps.com
5
+ Description: Make your website look beautiful and crisp on modern displays by creating + displaying retina images.
6
+ Version: 5.2.9
7
+ Author: Jordy Meow
8
+ Author URI: https://meowapps.com
9
+ Text Domain: wp-retina-2x
10
+ Domain Path: /languages
11
+
12
+ Dual licensed under the MIT and GPL licenses:
13
+ http://www.opensource.org/licenses/mit-license.php
14
+ http://www.gnu.org/licenses/gpl.html
15
+
16
+ Originally developed for two of my websites:
17
+ - Jordy Meow (https://offbeatjapan.org)
18
+ - Haikyo (https://haikyo.org)
19
+ */
20
+
21
+ if ( class_exists( 'Meow_WR2X_Core' ) ) {
22
+ function mfrh_admin_notices() {
23
+ echo '<div class="error"><p>Thanks for installing the Pro version of WP Retina 2x :) However, the free version is still enabled. Please disable or uninstall it.</p></div>';
24
+ }
25
+ add_action( 'admin_notices', 'mfrh_admin_notices' );
26
+ return;
27
+ }
28
+
29
+ global $wr2x_picturefill, $wr2x_retinajs, $wr2x_lazysizes,
30
+ $wr2x_retina_image, $wr2x_core;
31
+
32
+ $wr2x_version = '5.2.9';
33
+ $wr2x_retinajs = '2.0.0';
34
+ $wr2x_picturefill = '3.0.2';
35
+ $wr2x_lazysizes = '4.0.1';
36
+ $wr2x_retina_image = '1.7.2';
37
+
38
+ // Admin
39
+ require( 'wr2x_admin.php');
40
+ $wr2x_admin = new Meow_WR2X_Admin( 'wr2x', __FILE__, 'wp-retina-2x' );
41
+
42
+ // Core
43
+ require( 'core.php' );
44
+ $wr2x_core = new Meow_WR2X_Core( $wr2x_admin );
45
+ $wr2x_admin->core = $wr2x_core;
46
+
47
+ /*******************************************************************************
48
+ * TODO: OLD PRO, THIS FUNCTION SHOULD BE REMOVED IN THE FUTURE
49
+ ******************************************************************************/
50
+
51
+ add_action( 'admin_notices', 'wr2x_meow_old_version_admin_notices' );
52
+
53
+ function wr2x_meow_old_version_admin_notices() {
54
+ if ( !current_user_can( 'install_plugins' ) )
55
+ return;
56
+ if ( isset( $_POST['wr2x_reset_sub'] ) ) {
57
+ if ( check_admin_referer( 'wr2x_remove_expired_data' ) ) {
58
+ delete_transient( 'wr2x_validated' );
59
+ delete_option( 'wr2x_pro_serial' );
60
+ delete_option( 'wr2x_pro_status' );
61
+ }
62
+ }
63
+ $subscr_id = get_option( 'wr2x_pro_serial', "" );
64
+ if ( empty( $subscr_id ) )
65
+ return;
66
+
67
+ $forever = strpos( $subscr_id, 'F-' ) !== false;
68
+ $yearly = strpos( $subscr_id, 'I-' ) !== false;
69
+ if ( !$forever && !$yearly )
70
+ return;
71
+ ?>
72
+ <div class="error">
73
+ <p>
74
+ <h2>IMPORTANT MESSAGE ABOUT WP RETINA 2X</h2>
75
+ In order to comply with WordPress.org, BIG CHANGES in the code and how the plugin was sold were to be made. The plugin needs requires to be purchased and updated through the new <a target='_blank' href="https://store.meowapps.com">Meow Apps Store</a>. This store is also more robust (keys, websites management, invoices, etc). Now, since WordPress.org only accepts free plugins on its repository, this is the one currently installed. Therefore, you need to take an action. <b>Please click here to know more about your license and to learn what to do: <a target='_blank' href='https://meowapps.com/?mkey=<?php echo $subscr_id ?>'>License <?php echo $subscr_id ?></a></b>.
76
+ </p>
77
+ <p>
78
+ <form method="post" action="">
79
+ <input type="hidden" name="wr2x_reset_sub" value="true">
80
+ <?php wp_nonce_field( 'wr2x_remove_expired_data' ); ?>
81
+ <input type="submit" name="submit" id="submit" class="button" value="Got it. Clear this!">
82
+ <br /><small><b>Make sure you followed the instruction before clicking this button.</b></small>
83
+ </form>
84
+ </p>
85
+ </div>
86
+ <?php
87
+ }
88
+
89
+ ?>
trunk/wr2x_admin.css ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #wr2x-pages {
2
+ float: right;
3
+ position: relative;
4
+ top: 12px;
5
+ }
6
+
7
+ .wr2x-hover-drop {
8
+ background: #FED5FF;
9
+ }
10
+
11
+ .wr2x-hover-drop .wr2x-title {
12
+ background: url('replace.png');
13
+ background-position: 5px 4px;
14
+ background-repeat: no-repeat;
15
+ }
16
+
17
+ .wr2x-loading-file .wr2x-title {
18
+ background: url('loading.gif');
19
+ background-position: 5px 1px;
20
+ background-repeat: no-repeat;
21
+ }
22
+
23
+ .wr2x-loading-file .wr2x-title a, .wr2x-loading-file .wr2x-title span,
24
+ .wr2x-hover-drop .wr2x-title a, .wr2x-hover-drop .wr2x-title span {
25
+ opacity: 0.0;
26
+ }
27
+
28
+ #wr2x-pages a {
29
+ text-decoration: none;
30
+ border: 1px solid black;
31
+ padding: 2px 5px;
32
+ border-radius: 4px;
33
+ background: #E9E9E9;
34
+ color: lightslategrey;
35
+ border-color: #BEBEBE;
36
+ }
37
+
38
+ #wr2x-pages .current {
39
+ font-weight: bold;
40
+ }
41
+
42
+ .widefat td .button {
43
+ margin-right: 2px;
44
+ }
45
+
46
+ .widefat td .button:last-child {
47
+ margin-right: 0px;
48
+ }
49
+
50
+ .wr2x-table th {
51
+ font-size: 11px;
52
+ }
53
+
54
+ #wr2x-pages + .subsubsub #icl_subsubsub, #wr2x-pages + .subsubsub br {
55
+ display: none;
56
+ }
57
+
58
+ .wr2x-image {
59
+ padding: 0px;
60
+ }
61
+
62
+ .wr2x-image img {
63
+ margin-bottom: 0px;
64
+ margin-right: 0px;
65
+ max-width: 64px;
66
+ max-height: 64px;
67
+ }
68
+
69
+ .wr2x-info-full img {
70
+ border: 1px solid white;
71
+ }
72
+
73
+ .wr2x-info-full img:hover {
74
+ cursor: not-allowed;
75
+ border: 1px solid red;
76
+ }
77
+
78
+ .wr2x-title {
79
+ line-height: 16px !important;
80
+ }
81
+
82
+ .wr2x-title .resolution {
83
+ font-size: 11px;
84
+ line-height: 10px;
85
+ }
86
+
87
+ .wr2x-title .resolution .red {
88
+ color: red;
89
+ font-weight: bold;
90
+ }
91
+
92
+ .wr2x-title .actions {
93
+ margin-top: 5px;
94
+ }
95
+
96
+ .wr2x-button {
97
+ font-size: 10px;
98
+ background: #3E79BB;
99
+ color: white;
100
+ display: inline;
101
+ padding: 2px 6px;
102
+ height: 18px;
103
+ box-sizing: border-box;
104
+ text-transform: uppercase;
105
+ }
106
+
107
+ .wr2x-button:hover {
108
+ color: white;
109
+ cursor: pointer;
110
+ background: #5D93CF;
111
+ }
112
+
113
+ .wr2x-button-ignore {
114
+ background: #A8A8A8
115
+ }
116
+
117
+ .wr2x-button-ignore:hover {
118
+ background: #CFCFCF;
119
+ }
120
+
121
+ .wr2x-dragdrop {
122
+ margin: 0px 0px;
123
+ width: 48px;
124
+ height: 48px;
125
+ border: dashed 2px #BBB;
126
+ }
127
+
128
+ .wr2x-loading-file .wr2x-dragdrop {
129
+ background-color: rgb(243, 243, 243);
130
+ background-image: url('loading.gif');
131
+ background-size: 48px 48px;
132
+ background-position-y: 4px;
133
+ background-repeat: no-repeat;
134
+ border: none;
135
+ }
136
+
137
+ .wp-core-ui .button-red {
138
+ background-color: #9B2124;
139
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#C5292E), to(#9B2124));
140
+ background-image: -webkit-linear-gradient(top, #C5292E, #9B2124);
141
+ background-image: -moz-linear-gradient(top, #C5292E, #9B2124);
142
+ background-image: -ms-linear-gradient(top, #C5292E, #9B2124);
143
+ background-image: -o-linear-gradient(top, #C5292E, #9B2124);
144
+ background-image: linear-gradient(to bottom, #C5292E, #9B2124);
145
+ border-color: #9B2124;
146
+ border-bottom-color: #8D1F21;
147
+ -webkit-box-shadow: inset 0 1px 0 rgba(120,200,230,0.5);
148
+ box-shadow: inset 0 1px 0 rgba(120,200,230,0.5);
149
+ color: #fff;
150
+ text-decoration: none;
151
+ text-shadow: 0 1px 0 rgba(0,0,0,0.1);
152
+ float: right;
153
+ }
154
+
155
+ .wp-core-ui .button-red.hover,
156
+ .wp-core-ui .button-red:hover,
157
+ .wp-core-ui .button-red.focus,
158
+ .wp-core-ui .button-red:focus {
159
+ background-color: #B72629;
160
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#D22E30), to(#9B2124));
161
+ background-image: -webkit-linear-gradient(top, #D22E30, #9B2124);
162
+ background-image: -moz-linear-gradient(top, #D22E30, #9B2124);
163
+ background-image: -ms-linear-gradient(top, #D22E30, #9B2124);
164
+ background-image: -o-linear-gradient(top, #D22E30, #9B2124);
165
+ background-image: linear-gradient(to bottom, #D22E30, #9B2124);
166
+ border-color: #7F1C1F;
167
+ -webkit-box-shadow: inset 0 1px 0 rgba(120,200,230,0.6);
168
+ box-shadow: inset 0 1px 0 rgba(120,200,230,0.6);
169
+ color: #fff;
170
+ text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
171
+ }
172
+
173
+ .wp-core-ui .button-red.focus,
174
+ .wp-core-ui .button-red:focus {
175
+ border-color: #500F0E;
176
+ -webkit-box-shadow: inset 0 1px 0 rgba(120,200,230,0.6), 1px 1px 2px rgba(0,0,0,0.4);
177
+ box-shadow: inset 0 1px 0 rgba(120,200,230,0.6), 1px 1px 2px rgba(0,0,0,0.4);
178
+ }
179
+
180
+ .wp-core-ui .button-red.active,
181
+ .wp-core-ui .button-red.active:hover,
182
+ .wp-core-ui .button-red.active:focus,
183
+ .wp-core-ui .button-red:active {
184
+ background: #7F1C1F;
185
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#9B2124), to(#B72629));
186
+ background-image: -webkit-linear-gradient(top, #9B2124, #B72629);
187
+ background-image: -moz-linear-gradient(top, #9B2124, #B72629);
188
+ background-image: -ms-linear-gradient(top, #9B2124, #B72629);
189
+ background-image: -o-linear-gradient(top, #9B2124, #B72629);
190
+ background-image: linear-gradient(to bottom, #9B2124, #B72629);
191
+ border-color: #601312 #AE2426 #AE2426 #AE2426;
192
+ color: rgba(255,255,255,0.95);
193
+ -webkit-box-shadow: inset 0 1px 0 rgba(0,0,0,0.1);
194
+ box-shadow: inset 0 1px 0 rgba(0,0,0,0.1);
195
+ text-shadow: 0 1px 0 rgba(0,0,0,0.1);
196
+ }
197
+
198
+ .wp-core-ui .button-red[disabled],
199
+ .wp-core-ui .button-red:disabled,
200
+ .wp-core-ui .button-red-disabled {
201
+ color: #E79496 !important;
202
+ background: #BA292B !important;
203
+ border-color: #7F1C1F !important;
204
+ -webkit-box-shadow: none !important;
205
+ box-shadow: none !important;
206
+ text-shadow: 0 -1px 0 rgba(0,0,0,0.1) !important;
207
+ cursor: default;
208
+ }
trunk/wr2x_admin.php ADDED
@@ -0,0 +1,459 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ register_deactivation_hook( 'Meow_WR2X_Admin', 'wr2x_deactivate' );
4
+ register_activation_hook( 'Meow_WR2X_Admin', 'wr2x_activate' );
5
+
6
+ include "common/admin.php";
7
+
8
+ class Meow_WR2X_Admin extends MeowApps_Admin {
9
+
10
+ public $core = null;
11
+
12
+ public function __construct( $prefix, $mainfile, $domain ) {
13
+ parent::__construct( $prefix, $mainfile, $domain );
14
+ if ( is_admin() ) {
15
+ add_action( 'admin_menu', array( $this, 'app_menu' ) );
16
+ add_action( 'admin_notices', array( $this, 'admin_notices' ) );
17
+ }
18
+ }
19
+
20
+ function admin_notices() {
21
+ if ( current_user_can( 'activate_plugins' ) ) {
22
+ if ( delete_transient( 'wr2x_flush_rules' ) ) {
23
+ global $wp_rewrite;
24
+ Meow_WR2X_Admin::generate_rewrite_rules( $wp_rewrite, true );
25
+ }
26
+ }
27
+ $method = get_option( 'wr2x_method' );
28
+ $cdn = get_option( 'wr2x_cdn_domain' );
29
+ $disable_responsive = get_option( 'wr2x_disable_responsive', false );
30
+ $keep_src = get_option( 'wr2x_picturefill_keep_src', false );
31
+
32
+ if ( $method == 'HTML Rewrite' || $method == 'Retina-Images' || !empty( $cdn ) || $disable_responsive || $keep_src ) {
33
+ echo '<div class="error"><p>';
34
+ echo __( '<b>WARNING</b>. You are using an option that will be removed in a future release. The plan is to remove two methods (HTML Rewrite and Retina-Images), Disable Responsive, Custom CDN Domain, and Keep IMG SRC. Those options are not necessary, and it is better to keep the plugin clean and focus. This warning message will go away if you avoid using those options (and will disappear in a future release). If you are using one of those options and really would like to keep it, please come here to talk about it: <a target= "_blank" href="https://wordpress.org/support/topic/simplifying-wp-retina-2x-by-removing-options/">Discussions about removing options from WP Retina 2x</a>. Thanks :)', 'wp-retina-2x' );
35
+ echo '</p></div>';
36
+ }
37
+ if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) {
38
+ echo "<div class='error' style='margin-top: 20px;'><p>";
39
+ _e( "JetPack's <b>Photon</b> module breaks features built in WP Retina 2x (as Photos moves the files away). A common and better alternative to Photon is to use <a href='http://tracking.maxcdn.com/c/97349/3982/378'>MaxCDN</a> (very popular), CloudFlare or Fastly.", 'wp-retina-2x' );
40
+ echo "</p></div>";
41
+ }
42
+ }
43
+
44
+ static function activate() {
45
+ global $wp_rewrite;
46
+ $wp_rewrite->flush_rules();
47
+ }
48
+
49
+ static function deactivate() {
50
+ remove_filter( 'generate_rewrite_rules', array( 'Meow_WR2X_Admin', 'generate_rewrite_rules' ) );
51
+ global $wp_rewrite;
52
+ $wp_rewrite->flush_rules();
53
+ }
54
+
55
+ static function generate_rewrite_rules( $wp_rewrite, $flush = false ) {
56
+ global $wp_rewrite;
57
+ $method = get_option( "wr2x_method" );
58
+ if ( $method == "Retina-Images" ) {
59
+
60
+ // MODIFICATION: docwhat
61
+ // get_home_url() -> trailingslashit(site_url())
62
+ // REFERENCE: http://wordpress.org/support/topic/plugin-wp-retina-2x-htaccess-generated-with-incorrect-rewriterule
63
+
64
+ // MODIFICATION BY h4ir9
65
+ // .*\.(jpg|jpeg|gif|png|bmp) -> (.+.(?:jpe?g|gif|png))
66
+ // REFERENCE: http://wordpress.org/support/topic/great-but-needs-a-little-update
67
+
68
+ $handlerurl = str_replace( trailingslashit( site_url()), '', plugins_url( 'wr2x_image.php', __FILE__ ) );
69
+ add_rewrite_rule( '(.+.(?:jpe?g|gif|png))', $handlerurl, 'top' );
70
+ }
71
+ if ( $flush == true ) {
72
+ $wp_rewrite->flush_rules();
73
+ }
74
+ }
75
+
76
+ function common_url( $file ) {
77
+ return trailingslashit( plugin_dir_url( __FILE__ ) ) . 'common/' . $file;
78
+ }
79
+
80
+ function app_menu() {
81
+
82
+ // SUBMENU > Settings
83
+ add_submenu_page( 'meowapps-main-menu', 'Retina', 'Retina', 'manage_options',
84
+ 'wr2x_settings-menu', array( $this, 'admin_settings' ) );
85
+
86
+ // SUBMENU > Settings > Basic Settings
87
+ add_settings_section( 'wr2x_settings', null, null, 'wr2x_settings-menu' );
88
+ add_settings_field( 'wr2x_ignore_sizes', __( "Disabled Sizes", 'wp-retina-2x' ),
89
+ array( $this, 'admin_ignore_sizes_callback' ),
90
+ 'wr2x_settings-menu', 'wr2x_settings' );
91
+ add_settings_field( 'wr2x_method', __( "Method", 'wp-retina-2x' ),
92
+ array( $this, 'admin_method_callback' ),
93
+ 'wr2x_settings-menu', 'wr2x_settings' );
94
+ add_settings_field( 'wr2x_full_size', __( "Full Size Retina", 'wp-retina-2x' ) . "<br />(Pro)",
95
+ array( $this, 'admin_full_size_callback' ),
96
+ 'wr2x_settings-menu', 'wr2x_settings' );
97
+ // add_settings_field( 'wr2x_method', __( "Method", 'wp-retina-2x' ),
98
+ // array( $this, 'admin_method_callback' ),
99
+ // 'wr2x_settings-menu', 'wr2x_settings' );
100
+ add_settings_field( 'wr2x_quality', __( "Retina Quality", 'wp-retina-2x' ),
101
+ array( $this, 'admin_quality_callback' ),
102
+ 'wr2x_settings-menu', 'wr2x_settings' );
103
+
104
+ register_setting( 'wr2x_settings', 'wr2x_ignore_sizes' );
105
+ register_setting( 'wr2x_settings', 'wr2x_full_size' );
106
+ register_setting( 'wr2x_settings', 'wr2x_method' );
107
+ register_setting( 'wr2x_settings', 'wr2x_quality' );
108
+
109
+ // SUBMENU > Settings > Advanced Settings
110
+ add_settings_section( 'wr2x_advanced_settings', null, null, 'wr2x_advanced_settings-menu' );
111
+ add_settings_field( 'wr2x_auto_generate', __( "Auto Generate", 'wp-retina-2x' ),
112
+ array( $this, 'admin_auto_generate_callback' ),
113
+ 'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
114
+ add_settings_field( 'wr2x_regenerate_thumbnails', __( "Regenerate Thumbnails", 'wp-retina-2x' ),
115
+ array( $this, 'admin_regenerate_thumbnails_callback' ),
116
+ 'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
117
+ add_settings_field( 'wr2x_disable_medium_large', __( "Disable Medium Large", 'wp-retina-2x' ),
118
+ array( $this, 'admin_disable_medium_large_callback' ),
119
+ 'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
120
+ add_settings_field( 'wr2x_over_http_check', __( "Over HTTP Check", 'wp-retina-2x' ) . "<br />(Pro)",
121
+ array( $this, 'admin_over_http_check_callback' ),
122
+ 'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
123
+ add_settings_field( 'wr2x_debug', __( "Debug", 'wp-retina-2x' ),
124
+ array( $this, 'admin_debug_callback' ),
125
+ 'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
126
+
127
+ add_settings_field( 'wr2x_disable_responsive', __( "<br /><br />Disable Responsive", 'wp-retina-2x' ),
128
+ array( $this, 'admin_disable_responsive_callback' ),
129
+ 'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
130
+ add_settings_field( 'wr2x_cdn_domain', __( "Custom CDN Domain", 'wp-retina-2x' ) . "<br />(Pro)",
131
+ array( $this, 'admin_cdn_domain_callback' ),
132
+ 'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
133
+
134
+ register_setting( 'wr2x_advanced_settings', 'wr2x_auto_generate' );
135
+ register_setting( 'wr2x_advanced_settings', 'wr2x_regenerate_thumbnails' );
136
+ register_setting( 'wr2x_advanced_settings', 'wr2x_disable_responsive' );
137
+ register_setting( 'wr2x_advanced_settings', 'wr2x_disable_medium_large' );
138
+ register_setting( 'wr2x_advanced_settings', 'wr2x_cdn_domain' );
139
+ register_setting( 'wr2x_advanced_settings', 'wr2x_over_http_check' );
140
+ register_setting( 'wr2x_advanced_settings', 'wr2x_debug' );
141
+
142
+ // SUBMENU > Settings > PictureFill
143
+ add_settings_section( 'wr2x_picturefill_settings', null, null, 'wr2x_picturefill_settings-menu' );
144
+ add_settings_field( 'wr2x_picturefill_keep_src', "Keep IMG SRC",
145
+ array( $this, 'admin_picturefill_keep_src_callback' ),
146
+ 'wr2x_picturefill_settings-menu', 'wr2x_picturefill_settings' );
147
+ add_settings_field( 'wr2x_picturefill_lazysizes', "Lazy Retina<br />(Pro)",
148
+ array( $this, 'admin_picturefill_lazysizes_callback' ),
149
+ 'wr2x_picturefill_settings-menu', 'wr2x_picturefill_settings' );
150
+ add_settings_field( 'wr2x_picturefill_css_background', "CSS Background<br />(Pro)",
151
+ array( $this, 'admin_picturefill_css_background_callback' ),
152
+ 'wr2x_picturefill_settings-menu', 'wr2x_picturefill_settings' );
153
+ add_settings_field( 'wr2x_picturefill_noscript', "Polyfill Script",
154
+ array( $this, 'admin_picturefill_noscript_callback' ),
155
+ 'wr2x_picturefill_settings-menu', 'wr2x_picturefill_settings' );
156
+
157
+ register_setting( 'wr2x_picturefill_settings', 'wr2x_picturefill_keep_src' );
158
+ register_setting( 'wr2x_picturefill_settings', 'wr2x_picturefill_lazysizes' );
159
+ register_setting( 'wr2x_picturefill_settings', 'wr2x_picturefill_css_background' );
160
+ register_setting( 'wr2x_picturefill_settings', 'wr2x_picturefill_noscript' );
161
+
162
+ // SUBMENU > Settings > Admin UI
163
+ add_settings_section( 'wr2x_ui_settings', null, null, 'wr2x_ui_settings-menu' );
164
+ add_settings_field( 'wr2x_hide_retina_column', __( "Retina Column", 'wp-retina-2x' ),
165
+ array( $this, 'admin_hide_retina_column_callback' ),
166
+ 'wr2x_ui_settings-menu', 'wr2x_ui_settings' );
167
+ add_settings_field( 'wr2x_hide_retina_dashboard', __( "Retina Dashboard", 'wp-retina-2x' ),
168
+ array( $this, 'admin_hide_retina_dashboard_callback' ),
169
+ 'wr2x_ui_settings-menu', 'wr2x_ui_settings' );
170
+ add_settings_field( 'wr2x_hide_pro', __( "Pro Information", 'wp-retina-2x' ),
171
+ array( $this, 'admin_hide_pro_callback' ),
172
+ 'wr2x_ui_settings-menu', 'wr2x_ui_settings' );
173
+
174
+ register_setting( 'wr2x_ui_settings', 'wr2x_hide_retina_column' );
175
+ register_setting( 'wr2x_ui_settings', 'wr2x_hide_retina_dashboard' );
176
+ register_setting( 'wr2x_ui_settings', 'wr2x_hide_pro' );
177
+ }
178
+
179
+ function admin_settings() {
180
+ $method = get_option( 'wr2x_method', 'Picturefill' );
181
+ $quality = get_option( 'wr2x_quality', 90 );
182
+ if ( $quality > 100 || $quality < 0 )
183
+ update_option( 'wr2x_quality', 90, false );
184
+
185
+ ?>
186
+ <div class="wrap">
187
+ <?php echo $this->display_title( "WP Retina 2x" ); ?>
188
+
189
+ <div class="meow-row">
190
+ <div class="meow-box meow-col meow-span_2_of_2">
191
+ <div class="inside">
192
+ <?php
193
+ if ( $method == 'none' )
194
+ echo "<p><span>" . __( "Current method:", 'wp-retina-2x' ) . " <u>" . __( "None", 'wp-retina-2x' ) . "</u>.</span>";
195
+ if ( $method == 'HTML Rewrite' )
196
+ echo "<p><span>" . __( "Current method:", 'wp-retina-2x' ) . " <u>" . __( "HTML Rewrite", 'wp-retina-2x' ) . "</u>.</span>";
197
+ if ( $method == 'retina.js' )
198
+ echo "<p><span>" . __( "Current method:", 'wp-retina-2x' ) . " <u>" . __( "Retina.js", 'wp-retina-2x' ) . "</u>.</span>";
199
+ if ( $method == 'Picturefill' )
200
+ echo "<p><span>" . __( "Current method:", 'wp-retina-2x' ) . " <u>" . __( "PictureFill", 'wp-retina-2x' ) . "</u>.</span>";
201
+ if ( $method == 'Responsive' )
202
+ echo "<p><span>" . __( "Current method:", 'wp-retina-2x' ) . " <u>" . __( "Responsive Images", 'wp-retina-2x' ) . "</u>.</span>";
203
+ if ( $method == 'Retina-Images' ) {
204
+ echo "<p><span>" . __( "Current method:", 'wp-retina-2x' ) . " <u>" . __( "HTML Rewrite", 'wp-retina-2x' ) . "</u>.</span>";
205
+ if ( defined( 'MULTISITE' ) && MULTISITE == true ) {
206
+ if ( get_site_option( 'ms_files_rewriting' ) ) {
207
+ // MODIFICATION: Craig Foster
208
+ // 'ms_files_rewriting' support
209
+ echo " <span style='color: red;'>" . __( "By the way, you are using a <b>WordPress Multi-Site installation</b>! You must edit your .htaccess manually and add '<b>RewriteRule ^files/(.+) wp-content/plugins/wp-retina-2x/wr2x_image.php?ms=true&file=$1 [L]</b>' as the first RewriteRule if you want the server-side to work.", 'wp-retina-2x' ) . "</span>";
210
+ }
211
+ else
212
+ echo " <span style='color: red;'>" . __( "By the way, you are using a <b>WordPress Multi-Site installation</b>! You must edit your .htaccess manually and add '<b>RewriteRule ^(wp-content/.+\.(png|gif|jpg|jpeg|bmp|PNG|GIF|JPG|JPEG|BMP)) wp-content/plugins/wp-retina-2x/wr2x_image.php?ms=true&file=$1 [L]</b>' as the first RewriteRule if you want the server-side to work.", 'wp-retina-2x' ) . "</span>";
213
+ }
214
+ echo "</p>";
215
+ if ( !get_option('permalink_structure') )
216
+ echo "<p><span style='color: red;'>" . __( "The permalinks are not enabled. They need to be enabled in order to use the server-side method.", 'wp-retina-2x' ) . "</span>";
217
+ }
218
+ ?>
219
+ </div>
220
+ </div>
221
+ </div>
222
+
223
+ <div class="meow-row">
224
+ <div class="meow-box meow-col meow-span_2_of_2">
225
+ <h3>How to use</h3>
226
+ <div class="inside">
227
+ <?php echo _e( 'This plugin works out of the box, the default settings are the best for most installs. However, you should have a look at the <a target="_blank" href="https://meowapps.com/wp-retina-2x/tutorial/">tutorial</a>.', 'wp-retina-2x' ) ?>
228
+ </div>
229
+ </div>
230
+ </div>
231
+
232
+ <div class="meow-row">
233
+
234
+ <div class="meow-col meow-span_1_of_2">
235
+
236
+ <div class="meow-box">
237
+ <h3>Basic Settings</h3>
238
+ <div class="inside">
239
+ <form method="post" action="options.php">
240
+ <?php settings_fields( 'wr2x_settings' ); ?>
241
+ <?php do_settings_sections( 'wr2x_settings-menu' ); ?>
242
+ <?php submit_button(); ?>
243
+ </form>
244
+ </div>
245
+ </div>
246
+
247
+ <div class="meow-box">
248
+ <h3>Advanced Settings</h3>
249
+ <div class="inside">
250
+ <form method="post" action="options.php">
251
+ <?php settings_fields( 'wr2x_advanced_settings' ); ?>
252
+ <?php do_settings_sections( 'wr2x_advanced_settings-menu' ); ?>
253
+ <?php submit_button(); ?>
254
+ </form>
255
+ </div>
256
+ </div>
257
+
258
+ </div>
259
+
260
+ <div class="meow-col meow-span_1_of_2">
261
+
262
+ <?php $this->display_serialkey_box( "https://meowapps.com/wp-retina-2x/" ); ?>
263
+
264
+ <?php if ( get_option( 'wr2x_method', 'none' ) == 'Picturefill' ): ?>
265
+ <div class="meow-box">
266
+ <h3>PictureFill</h3>
267
+ <div class="inside">
268
+ <form method="post" action="options.php">
269
+ <?php settings_fields( 'wr2x_picturefill_settings' ); ?>
270
+ <?php do_settings_sections( 'wr2x_picturefill_settings-menu' ); ?>
271
+ <?php submit_button(); ?>
272
+ </form>
273
+ </div>
274
+ </div>
275
+ <?php endif; ?>
276
+
277
+ <div class="meow-box">
278
+ <h3>Admin UI</h3>
279
+ <div class="inside">
280
+ <form method="post" action="options.php">
281
+ <?php settings_fields( 'wr2x_ui_settings' ); ?>
282
+ <?php do_settings_sections( 'wr2x_ui_settings-menu' ); ?>
283
+ <?php submit_button(); ?>
284
+ </form>
285
+ </div>
286
+ </div>
287
+
288
+ </div>
289
+
290
+ </div>
291
+
292
+ </div>
293
+ <?php
294
+ }
295
+
296
+ /*
297
+ OPTIONS CALLBACKS
298
+ */
299
+
300
+ function admin_ignore_sizes_callback( $args ) {
301
+ $ignore_sizes = get_option( 'wr2x_ignore_sizes' );
302
+ if ( empty( $ignore_sizes ) )
303
+ $ignore_sizes = array();
304
+ $wpsizes = $this->core->get_image_sizes();
305
+ $sizes = array();
306
+ $html = "";
307
+ foreach ( $wpsizes as $name => $attr ) {
308
+ $html .= '<input type="checkbox" name="wr2x_ignore_sizes[' . $name . ']" value="1" ' .
309
+ ( array_key_exists( $name, $ignore_sizes ) ? 'checked' : '' ) . '/>' . sprintf( "<label><div style='float: left; text-align: right; margin-right: 5px; width: 20px;'>%s</div> <b>%s</b></label> <small>(Normal: %dx%d, Retina: %dx%d)</small>", MeowApps_Admin::size_shortname( $name ), $name, $attr['width'], $attr['height'], $attr['width'] * 2, $attr['height'] * 2 ) . '<br>';
310
+ }
311
+ $html .= '<br /><small class="description">' .
312
+ __( 'The selected sizes will <b>not</b> have their retina equivalent generated. It is recommended to disable the sizes for which <i>Normal</i> superior to 1200.', 'wp-retina-2x' ) . '</small>';
313
+ echo $html;
314
+ }
315
+
316
+ function admin_auto_generate_callback( $args ) {
317
+ $value = get_option( 'wr2x_auto_generate', null );
318
+ $html = '<input type="checkbox" id="wr2x_auto_generate" name="wr2x_auto_generate" value="1" ' .
319
+ checked( 1, get_option( 'wr2x_auto_generate' ), false ) . '/>';
320
+ $html .= '<label>Enabled</label><br /><small>Generate the Retina thumbnails on new upload and thumbnails creation. The <i>Disabled Sizes</i> will be skipped.</small>';
321
+ echo $html;
322
+ }
323
+
324
+ function admin_regenerate_thumbnails_callback( $args ) {
325
+ $value = get_option( 'wr2x_regenerate_thumbnails', false );
326
+ $html = '<input type="checkbox" id="wr2x_regenerate_thumbnails" name="wr2x_regenerate_thumbnails" value="1" ' .
327
+ checked( 1, get_option( 'wr2x_regenerate_thumbnails' ), false ) . '/>';
328
+ $html .= '<label>Enabled</label><br /><small>On each <b>Generate</b> action, all standard thumbnails will be regenerated (exactly the same function as Regenerate Thumbnail), and only then the Retina thumbnails will be created (depending on the Auto Generate option).</small>';
329
+ echo $html;
330
+ }
331
+
332
+ function admin_disable_responsive_callback( $args ) {
333
+ $value = get_option( 'wr2x_disable_responsive', null );
334
+ $html = '<br /><br /><input type="checkbox" id="wr2x_disable_responsive" name="wr2x_disable_responsive" value="1" ' .
335
+ checked( 1, get_option( 'wr2x_disable_responsive' ), false ) . '/>';
336
+ $html .= '<label>Disable the Responsive Images feature.</label><br /><small>Get back control over your HTML if you need.</small>';
337
+ echo $html;
338
+ }
339
+
340
+ function admin_disable_medium_large_callback( $args ) {
341
+ $value = get_option( 'wr2x_disable_medium_large', null );
342
+ $html = '<input type="checkbox" id="wr2x_disable_medium_large" name="wr2x_disable_medium_large" value="1" ' .
343
+ checked( 1, get_option( 'wr2x_disable_medium_large' ), false ) . '/>';
344
+ $html .= '<label>Remove the "Medium Large" image size.</label><br /><small>You probably don\'t need this.</small>';
345
+ echo $html;
346
+ }
347
+
348
+ function admin_method_callback( $args ) {
349
+ $value = get_option( 'wr2x_method', 'none' );
350
+ $html = '<select id="wr2x_method" name="wr2x_method">
351
+ <option ' . selected( 'Picturefill', $value, false ) . 'value="Picturefill">Recommended: Picturefill</option>
352
+ <option ' . selected( 'Responsive', $value, false ) . 'value="Responsive">Responsive-Images (Native WP 4.4+)</option>
353
+ <option ' . selected( 'retina.js', $value, false ) . 'value="retina.js">Retina.js (Client-side)</option>
354
+ <option ' . selected( 'HTML Rewrite', $value, false ) . 'value="HTML Rewrite">HTML Rewrite</option>
355
+ <option ' . selected( 'Retina-Images', $value, false ) . 'value="Retina-Images">Retina-Images</option>
356
+ <option ' . selected( 'none', $value, false ) . 'value="none">None</option>
357
+ </select><small><br />' . __( 'In all cases (including "None"), Retina support will be added to the Responsive Images. Check the <a target="_blank" href="http://meowapps.com/wp-retina-2x/retina-methods/">Retina Methods</a> page if you want to know more about those methods.', 'wp-retina-2x' ) . '</small>';
358
+ echo $html;
359
+ }
360
+
361
+ function admin_full_size_callback( $args ) {
362
+ $value = get_option( 'wr2x_full_size', null );
363
+ $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="wr2x_full_size" name="wr2x_full_size" value="1" ' .
364
+ checked( 1, get_option( 'wr2x_full_size' ), false ) . '/>';
365
+ $html .= '<label>Enable</label><br /><small>Checks for retina for full-size will be enabled and upload features made available in the <i>Retina Dashboard</i>.</small>';
366
+ echo $html;
367
+ }
368
+
369
+ function admin_quality_callback( $args ) {
370
+ $value = get_option( 'wr2x_quality', 90 );
371
+ $html = '<input type="number" id="wr2x_quality" name="wr2x_quality" value="' . $value . '" />';
372
+ $html .= __( '<br /><small>Sets image compression quality on a 1-100% scale as an integer (1-100). Default is 90. Only for JPG.</small>', 'wp-retina-2x' );
373
+ echo $html;
374
+ }
375
+
376
+ function admin_debug_callback( $args ) {
377
+ $value = get_option( 'wr2x_debug', null );
378
+ $html = '<input type="checkbox" id="wr2x_debug" name="wr2x_debug" value="1" ' .
379
+ checked( 1, get_option( 'wr2x_debug' ), false ) . '/>';
380
+ $html .= __( '<label>Force Retina + Logging</label><br /><small>Displays retina and creates a <a href="' . plugins_url( "wp-retina-2x" ) . '/wp-retina-2x.log">log file</a> in the plugin folder.</small>', 'wp-retina-2x' );
381
+ echo $html;
382
+ }
383
+
384
+ function admin_cdn_domain_callback( $args ) {
385
+ $value = get_option( 'wr2x_cdn_domain', null );
386
+ $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="text" id="wr2x_cdn_domain" name="wr2x_cdn_domain" value="' . $value . '" />';
387
+ $html .= __( '<br /><small>If not empty, your site domain will be replaced with this CDN domain (PictureFill and HTML Rewrite only).</small>', 'wp-retina-2x' );
388
+ echo $html;
389
+ }
390
+
391
+ function admin_over_http_check_callback( $args ) {
392
+ $value = get_option( 'wr2x_over_http_check', null );
393
+ $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="wr2x_over_http_check" name="wr2x_over_http_check" value="1" ' .
394
+ checked( 1, get_option( 'wr2x_over_http_check' ), false ) . '/>';
395
+ $html .= __( '<label>Enable</label><br /><small>Normally, the plugin checks if the Retina files exists through your filesystem. With this option, it will check using HTTP requests, that will enable Retina on exotic WordPress installs and also for images hosted on different servers.</small>', 'wp-retina-2x' );
396
+ echo $html;
397
+ }
398
+
399
+ function admin_picturefill_keep_src_callback( $args ) {
400
+ $value = get_option( 'wr2x_picturefill_keep_src', null );
401
+ $html = '<input type="checkbox" id="wr2x_picturefill_keep_src" name="wr2x_picturefill_keep_src" value="1" ' .
402
+ checked( 1, get_option( 'wr2x_picturefill_keep_src' ), false ) . '/>';
403
+ $html .= __( '<label>Enable</label><br /><small>With PictureFill, <b>src</b> tags are replaced by <b>src-set</b> tags and consequently search engines might not be able to find and reference those images. This option is better for SEO, but Retina devices will download both normal and retina. Lazy Retina option is recommended with this.</small>', 'wp-retina-2x' );
404
+ echo $html;
405
+ }
406
+
407
+ function admin_picturefill_lazysizes_callback( $args ) {
408
+ $value = get_option( 'wr2x_picturefill_lazysizes', null );
409
+ $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="wr2x_picturefill_lazysizes"
410
+ name="wr2x_picturefill_lazysizes" value="1" ' .
411
+ checked( 1, get_option( 'wr2x_picturefill_lazysizes' ), false ) . '/>';
412
+ $html .= __( '<label>Enabled</label><br /><small>Retina images will not be loaded until the visitor gets close to them. HTML will be rewritten and the lazysizes script will be also loaded. </small>', 'wp-retina-2x' );
413
+ echo $html;
414
+ }
415
+
416
+ function admin_picturefill_noscript_callback( $args ) {
417
+ $value = get_option( 'wr2x_picturefill_noscript', null );
418
+ $html = '<input type="checkbox" id="wr2x_picturefill_noscript"
419
+ name="wr2x_picturefill_noscript" value="1" ' .
420
+ checked( 1, get_option( 'wr2x_picturefill_noscript' ), false ) . '/>';
421
+ $html .= __( '<label>Disable</label><br /><small>Only <a href="http://caniuse.com/#feat=srcset" target="_blank">the browsers with src-set support</a> will display Retina images. You can also choose this if you want to load the Picturefill Polyfill script manually or if it is already loaded by your theme.</small>', 'wp-retina-2x' );
422
+ echo $html;
423
+ }
424
+
425
+ function admin_picturefill_css_background_callback( $args ) {
426
+ $value = get_option( 'wr2x_picturefill_css_background', null );
427
+ $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="wr2x_picturefill_css_background" name="wr2x_picturefill_css_background" value="1" ' .
428
+ checked( 1, get_option( 'wr2x_picturefill_css_background' ), false ) . '/>';
429
+ $html .= __( '<label>Retina-ize</label><br /><small>In your HTML, inline CSS Background will be replaced by the Retina version of the image.</small>', 'wp-retina-2x' );
430
+ echo $html;
431
+ }
432
+
433
+ function admin_hide_retina_column_callback( $args ) {
434
+ $value = get_option( 'wr2x_hide_retina_column', null );
435
+ $html = '<input type="checkbox" id="wr2x_hide_retina_column" name="wr2x_hide_retina_column" value="1" ' .
436
+ checked( 1, get_option( 'wr2x_hide_retina_column' ), false ) . '/>';
437
+ $html .= __( '<label>Hide</label><br /><small>Hide the <i>Retina Column</i> in the Media Library.</small>', 'wp-retina-2x' );
438
+ echo $html;
439
+ }
440
+
441
+ function admin_hide_retina_dashboard_callback( $args ) {
442
+ $value = get_option( 'wr2x_hide_retina_dashboard', null );
443
+ $html = '<input type="checkbox" id="wr2x_hide_retina_dashboard" name="wr2x_hide_retina_dashboard" value="1" ' .
444
+ checked( 1, get_option( 'wr2x_hide_retina_dashboard' ), false ) . '/>';
445
+ $html .= __( '<label>Hide</label><br /><small>Disable <i>Retina Dashboard</i> menu and tools.</small>', 'wp-retina-2x' );
446
+ echo $html;
447
+ }
448
+
449
+ function admin_hide_pro_callback( $args ) {
450
+ $value = get_option( 'wr2x_hide_pro', null );
451
+ $html = '<input type="checkbox" id="wr2x_hide_pro" name="wr2x_hide_pro" value="1" ' .
452
+ checked( 1, get_option( 'wr2x_hide_pro' ), false ) . '/>';
453
+ $html .= __( '<label>Hide</label><br /><small>Hide information about Pro version.</small>', 'wp-retina-2x' );
454
+ echo $html;
455
+ }
456
+
457
+ }
458
+
459
+ ?>
trunk/wr2x_image.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* Version: 1.7.2 - now with even more pixels */
4
+
5
+ define('DEBUG', false); // Write debugging information to a log file
6
+ define('SEND_ETAG', true); // You will want to disable this if you load balance multiple servers
7
+ define('SEND_EXPIRES', true);
8
+ define('SEND_CACHE_CONTROL', true);
9
+ define('USE_X_SENDFILE', false); // This will reduce memory usage, but isn't enabled on all systems. If you have issues enabling this setting, contact your host
10
+ define('DOWNSIZE_NOT_FOUND', true); // If a regular image is requested and not found, send a retina file instead?
11
+ define('CACHE_TIME', 24*60*60); // 1 day
12
+ define('DISABLE_RI_HEADER', false);
13
+
14
+ $document_root = $_SERVER['DOCUMENT_ROOT'];
15
+ $requested_uri = parse_url(urldecode($_SERVER['REQUEST_URI']), PHP_URL_PATH);
16
+ $requested_file = basename($requested_uri);
17
+ $source_file = $document_root.$requested_uri;
18
+ $source_dirname = pathinfo($source_file, PATHINFO_DIRNAME);
19
+ $source_filename = pathinfo($source_file, PATHINFO_FILENAME);
20
+ $source_ext = pathinfo($source_file, PATHINFO_EXTENSION);
21
+ $at2x_file = $source_dirname.'/'.$source_filename.'@2x.'.$source_ext;
22
+ $at3x_file = $source_dirname.'/'.$source_filename.'@3x.'.$source_ext;
23
+ $at4x_file = $source_dirname.'/'.$source_filename.'@4x.'.$source_ext;
24
+ $cache_directive = 'must-revalidate';
25
+ $status = 'regular image';
26
+
27
+ if (DEBUG) {
28
+ $_debug_fh = fopen('retinaimages.log', 'a');
29
+ fwrite($_debug_fh, "* * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\n");
30
+ fwrite($_debug_fh, print_r($_COOKIE, true)."\n\n");
31
+ fwrite($_debug_fh, "document_root: {$document_root}\n");
32
+ fwrite($_debug_fh, "requested_uri: {$requested_uri}\n");
33
+ fwrite($_debug_fh, "requested_file: {$requested_file}\n");
34
+ fwrite($_debug_fh, "source_file: {$source_file}\n");
35
+ fwrite($_debug_fh, "source_ext: {$source_ext}\n");
36
+ fwrite($_debug_fh, "@2x_file: {$at2x_file}\n");
37
+ fwrite($_debug_fh, "@3x_file: {$at3x_file}\n");
38
+ fwrite($_debug_fh, "@4x_file: {$at4x_file}\n");
39
+ }
40
+
41
+ // Image was requested
42
+ if (in_array($source_ext, array('png', 'gif', 'jpg', 'jpeg', 'bmp'))) {
43
+
44
+ // Check if a cookie is set
45
+ $cookie_value = false;
46
+ if (isset($_COOKIE['devicePixelRatio'])) {
47
+ $cookie_value = intval($_COOKIE['devicePixelRatio']);
48
+ }
49
+ else {
50
+ // Force revalidation of cache on next request
51
+ $cache_directive = 'no-cache';
52
+ $status = 'no cookie';
53
+ }
54
+ if (DEBUG) {
55
+ fwrite($_debug_fh, "devicePixelRatio: {$cookie_value}\n");
56
+ fwrite($_debug_fh, "cache_directive: {$cache_directive}\n");
57
+ }
58
+
59
+ // No need to check for retina images if screen is low DPR
60
+ if ($cookie_value !== false && $cookie_value > 1) {
61
+ // Check over images and match the largest resolution available
62
+ foreach (array($at4x_file => 3, $at3x_file => 2, $at2x_file => 1) as $retina_file => $min_dpr) {
63
+ if ($cookie_value > $min_dpr && file_exists($retina_file)) {
64
+ $source_file = $retina_file;
65
+ $status = 'retina image';
66
+ break;
67
+ }
68
+ }
69
+ }
70
+
71
+ // Check if we can shrink a larger version of the image
72
+ if (!file_exists($source_file) && DOWNSIZE_NOT_FOUND){
73
+ // Check over increasingly larger images and see if one is available
74
+ foreach (array($at2x_file, $at3x_file, $at4x_file) as $retina_file) {
75
+ if (file_exists($retina_file)) {
76
+ $source_file = $retina_file;
77
+ $status = 'downsized image';
78
+ break;
79
+ }
80
+ }
81
+ }
82
+
83
+ // Check if the image to send exists
84
+ if (!file_exists($source_file)) {
85
+ if (DEBUG) { fwrite($_debug_fh, "Image not found. Sending 404\n"); }
86
+ if (!DISABLE_RI_HEADER) {
87
+ header('X-Retina-Images: not found');
88
+ }
89
+ header('HTTP/1.1 404 Not Found', true);
90
+ exit();
91
+ }
92
+
93
+ // Attach a Retina Images header for debugging
94
+ if (!DISABLE_RI_HEADER) {
95
+ header('X-Retina-Images: '.$status);
96
+ }
97
+
98
+ // Send cache headers
99
+ if (SEND_CACHE_CONTROL) {
100
+ header("Cache-Control: private, {$cache_directive}, max-age=".CACHE_TIME, true);
101
+ }
102
+ if (SEND_EXPIRES) {
103
+ date_default_timezone_set('GMT');
104
+ header('Expires: '.gmdate('D, d M Y H:i:s', time()+CACHE_TIME).' GMT', true);
105
+ }
106
+ if (SEND_ETAG) {
107
+ $etag = '"'.filemtime($source_file).fileinode($source_file).'"';
108
+ header("ETag: $etag", true);
109
+
110
+ if (DEBUG) {
111
+ fwrite($_debug_fh, "generated etag: {$etag}\n");
112
+ if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
113
+ fwrite($_debug_fh, "received etag: {$_SERVER['HTTP_IF_NONE_MATCH']}\n\n");
114
+ }
115
+ }
116
+
117
+ if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && ($_SERVER['HTTP_IF_NONE_MATCH']) === $etag) {
118
+ // File in cache hasn't change
119
+ header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($source_file)).' GMT', true, 304);
120
+ exit();
121
+ }
122
+ }
123
+ if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && (strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) === filemtime($source_file))) {
124
+ // File in cache hasn't change
125
+ header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($source_file)).' GMT', true, 304);
126
+ exit();
127
+ }
128
+
129
+ // Send image headers
130
+ if (in_array($source_ext, array('png', 'gif', 'jpeg', 'bmp'))) {
131
+ header("Content-Type: image/".$source_ext, true);
132
+ }
133
+ else {
134
+ header("Content-Type: image/jpeg", true);
135
+ }
136
+ header('Content-Length: '.filesize($source_file), true);
137
+
138
+ // Close debug session if open
139
+ if (DEBUG) {
140
+ fwrite($_debug_fh, "sending file: {$source_file}\n\n");
141
+ fclose($_debug_fh);
142
+ }
143
+
144
+ // Send file
145
+ if (USE_X_SENDFILE) {
146
+ header('X-Sendfile: '.$source_file);
147
+ }
148
+ else {
149
+ readfile($source_file);
150
+ }
151
+ exit();
152
+ }
153
+
154
+ // DPR value was sent
155
+ elseif(isset($_GET['devicePixelRatio'])) {
156
+ $dpr = $_GET['devicePixelRatio'];
157
+
158
+ // Validate value before setting cookie
159
+ if (''.ceil(intval($dpr)) !== $dpr) {
160
+ $dpr = '1';
161
+ }
162
+
163
+ setcookie('devicePixelRatio', $dpr);
164
+ exit();
165
+ }
166
+
167
+ // Respond with an empty content
168
+ header('HTTP/1.1 204 No Content', true);
169
+ ?>
wr2x_admin.php CHANGED
@@ -24,23 +24,33 @@ class Meow_WR2X_Admin extends MeowApps_Admin {
24
  Meow_WR2X_Admin::generate_rewrite_rules( $wp_rewrite, true );
25
  }
26
  }
 
 
 
 
 
 
 
 
 
 
27
  if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) {
28
  echo "<div class='error' style='margin-top: 20px;'><p>";
29
  _e( "JetPack's <b>Photon</b> module breaks features built in WP Retina 2x (as Photos moves the files away). A common and better alternative to Photon is to use <a href='http://tracking.maxcdn.com/c/97349/3982/378'>MaxCDN</a> (very popular), CloudFlare or Fastly.", 'wp-retina-2x' );
30
  echo "</p></div>";
31
- }
32
  }
33
 
34
- static function activate() {
35
- global $wp_rewrite;
36
- $wp_rewrite->flush_rules();
37
- }
38
 
39
- static function deactivate() {
40
- remove_filter( 'generate_rewrite_rules', array( 'Meow_WR2X_Admin', 'generate_rewrite_rules' ) );
41
- global $wp_rewrite;
42
- $wp_rewrite->flush_rules();
43
- }
44
 
45
  static function generate_rewrite_rules( $wp_rewrite, $flush = false ) {
46
  global $wp_rewrite;
@@ -78,9 +88,6 @@ class Meow_WR2X_Admin extends MeowApps_Admin {
78
  add_settings_field( 'wr2x_ignore_sizes', __( "Disabled Sizes", 'wp-retina-2x' ),
79
  array( $this, 'admin_ignore_sizes_callback' ),
80
  'wr2x_settings-menu', 'wr2x_settings' );
81
- add_settings_field( 'wr2x_auto_generate', __( "Auto Generate", 'wp-retina-2x' ),
82
- array( $this, 'admin_auto_generate_callback' ),
83
- 'wr2x_settings-menu', 'wr2x_settings' );
84
  add_settings_field( 'wr2x_method', __( "Method", 'wp-retina-2x' ),
85
  array( $this, 'admin_method_callback' ),
86
  'wr2x_settings-menu', 'wr2x_settings' );
@@ -95,22 +102,21 @@ class Meow_WR2X_Admin extends MeowApps_Admin {
95
  'wr2x_settings-menu', 'wr2x_settings' );
96
 
97
  register_setting( 'wr2x_settings', 'wr2x_ignore_sizes' );
98
- register_setting( 'wr2x_settings', 'wr2x_auto_generate' );
99
  register_setting( 'wr2x_settings', 'wr2x_full_size' );
100
  register_setting( 'wr2x_settings', 'wr2x_method' );
101
  register_setting( 'wr2x_settings', 'wr2x_quality' );
102
 
103
  // SUBMENU > Settings > Advanced Settings
104
  add_settings_section( 'wr2x_advanced_settings', null, null, 'wr2x_advanced_settings-menu' );
105
- add_settings_field( 'wr2x_disable_responsive', __( "Disable Responsive", 'wp-retina-2x' ),
106
- array( $this, 'admin_disable_responsive_callback' ),
 
 
 
107
  'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
108
  add_settings_field( 'wr2x_disable_medium_large', __( "Disable Medium Large", 'wp-retina-2x' ),
109
  array( $this, 'admin_disable_medium_large_callback' ),
110
  'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
111
- add_settings_field( 'wr2x_cdn_domain', __( "Custom CDN Domain", 'wp-retina-2x' ) . "<br />(Pro)",
112
- array( $this, 'admin_cdn_domain_callback' ),
113
- 'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
114
  add_settings_field( 'wr2x_over_http_check', __( "Over HTTP Check", 'wp-retina-2x' ) . "<br />(Pro)",
115
  array( $this, 'admin_over_http_check_callback' ),
116
  'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
@@ -118,6 +124,15 @@ class Meow_WR2X_Admin extends MeowApps_Admin {
118
  array( $this, 'admin_debug_callback' ),
119
  'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
120
 
 
 
 
 
 
 
 
 
 
121
  register_setting( 'wr2x_advanced_settings', 'wr2x_disable_responsive' );
122
  register_setting( 'wr2x_advanced_settings', 'wr2x_disable_medium_large' );
123
  register_setting( 'wr2x_advanced_settings', 'wr2x_cdn_domain' );
@@ -181,21 +196,21 @@ class Meow_WR2X_Admin extends MeowApps_Admin {
181
  echo "<p><span>" . __( "Current method:", 'wp-retina-2x' ) . " <u>" . __( "HTML Rewrite", 'wp-retina-2x' ) . "</u>.</span>";
182
  if ( $method == 'retina.js' )
183
  echo "<p><span>" . __( "Current method:", 'wp-retina-2x' ) . " <u>" . __( "Retina.js", 'wp-retina-2x' ) . "</u>.</span>";
184
- if ( $method == 'Picturefill' )
185
- echo "<p><span>" . __( "Current method:", 'wp-retina-2x' ) . " <u>" . __( "PictureFill", 'wp-retina-2x' ) . "</u>.</span>";
186
- if ( $method == 'Responsive' )
187
- echo "<p><span>" . __( "Current method:", 'wp-retina-2x' ) . " <u>" . __( "Responsive Images", 'wp-retina-2x' ) . "</u>.</span>";
188
  if ( $method == 'Retina-Images' ) {
189
- echo "<p><span>" . __( "Current method:", 'wp-retina-2x' ) . " <u>" . __( "HTML Rewrite", 'wp-retina-2x' ) . "</u>.</span>";
190
- if ( defined( 'MULTISITE' ) && MULTISITE == true ) {
191
- if ( get_site_option( 'ms_files_rewriting' ) ) {
192
- // MODIFICATION: Craig Foster
193
- // 'ms_files_rewriting' support
194
- echo " <span style='color: red;'>" . __( "By the way, you are using a <b>WordPress Multi-Site installation</b>! You must edit your .htaccess manually and add '<b>RewriteRule ^files/(.+) wp-content/plugins/wp-retina-2x/wr2x_image.php?ms=true&file=$1 [L]</b>' as the first RewriteRule if you want the server-side to work.", 'wp-retina-2x' ) . "</span>";
195
- }
196
- else
197
- echo " <span style='color: red;'>" . __( "By the way, you are using a <b>WordPress Multi-Site installation</b>! You must edit your .htaccess manually and add '<b>RewriteRule ^(wp-content/.+\.(png|gif|jpg|jpeg|bmp|PNG|GIF|JPG|JPEG|BMP)) wp-content/plugins/wp-retina-2x/wr2x_image.php?ms=true&file=$1 [L]</b>' as the first RewriteRule if you want the server-side to work.", 'wp-retina-2x' ) . "</span>";
198
- }
199
  echo "</p>";
200
  if ( !get_option('permalink_structure') )
201
  echo "<p><span style='color: red;'>" . __( "The permalinks are not enabled. They need to be enabled in order to use the server-side method.", 'wp-retina-2x' ) . "</span>";
@@ -223,8 +238,8 @@ class Meow_WR2X_Admin extends MeowApps_Admin {
223
  <div class="inside">
224
  <form method="post" action="options.php">
225
  <?php settings_fields( 'wr2x_settings' ); ?>
226
- <?php do_settings_sections( 'wr2x_settings-menu' ); ?>
227
- <?php submit_button(); ?>
228
  </form>
229
  </div>
230
  </div>
@@ -234,8 +249,8 @@ class Meow_WR2X_Admin extends MeowApps_Admin {
234
  <div class="inside">
235
  <form method="post" action="options.php">
236
  <?php settings_fields( 'wr2x_advanced_settings' ); ?>
237
- <?php do_settings_sections( 'wr2x_advanced_settings-menu' ); ?>
238
- <?php submit_button(); ?>
239
  </form>
240
  </div>
241
  </div>
@@ -294,142 +309,150 @@ class Meow_WR2X_Admin extends MeowApps_Admin {
294
  ( array_key_exists( $name, $ignore_sizes ) ? 'checked' : '' ) . '/>' . sprintf( "<label><div style='float: left; text-align: right; margin-right: 5px; width: 20px;'>%s</div> <b>%s</b></label> <small>(Normal: %dx%d, Retina: %dx%d)</small>", MeowApps_Admin::size_shortname( $name ), $name, $attr['width'], $attr['height'], $attr['width'] * 2, $attr['height'] * 2 ) . '<br>';
295
  }
296
  $html .= '<br /><small class="description">' .
297
- __( 'The selected sizes will <b>not</b> have their retina equivalent generated.', 'wp-retina-2x' ) . '</small>';
298
  echo $html;
299
  }
300
 
301
  function admin_auto_generate_callback( $args ) {
302
- $value = get_option( 'wr2x_auto_generate', null );
303
  $html = '<input type="checkbox" id="wr2x_auto_generate" name="wr2x_auto_generate" value="1" ' .
304
  checked( 1, get_option( 'wr2x_auto_generate' ), false ) . '/>';
305
- $html .= '<label>Generate on new upload and regenerate</label><br /><small>The <i>Disabled Sizes</i> will be skipped.</small>';
306
- echo $html;
307
- }
308
 
 
 
 
 
 
 
 
 
309
  function admin_disable_responsive_callback( $args ) {
310
- $value = get_option( 'wr2x_disable_responsive', null );
311
- $html = '<input type="checkbox" id="wr2x_disable_responsive" name="wr2x_disable_responsive" value="1" ' .
312
  checked( 1, get_option( 'wr2x_disable_responsive' ), false ) . '/>';
313
- $html .= '<label>Disable the Responsive Images feature.</label><br /><small>Get back control over your HTML if you need.</small>';
314
- echo $html;
315
- }
316
 
317
  function admin_disable_medium_large_callback( $args ) {
318
- $value = get_option( 'wr2x_disable_medium_large', null );
319
  $html = '<input type="checkbox" id="wr2x_disable_medium_large" name="wr2x_disable_medium_large" value="1" ' .
320
  checked( 1, get_option( 'wr2x_disable_medium_large' ), false ) . '/>';
321
- $html .= '<label>Remove the "Medium Large" image size.</label><br /><small>You probably don\'t need this.</small>';
322
- echo $html;
323
- }
324
 
325
  function admin_method_callback( $args ) {
326
- $value = get_option( 'wr2x_method', 'none' );
327
  $html = '<select id="wr2x_method" name="wr2x_method">
328
- <option ' . selected( 'Picturefill', $value, false ) . 'value="Picturefill">Recommended: Picturefill</option>
329
- <option ' . selected( 'Responsive', $value, false ) . 'value="Responsive">Responsive-Images (Native WP 4.4+)</option>
330
- <option ' . selected( 'retina.js', $value, false ) . 'value="retina.js">Retina.js (Client-side)</option>
331
- <option ' . selected( 'HTML Rewrite', $value, false ) . 'value="HTML Rewrite">HTML Rewrite</option>
332
  <option ' . selected( 'Retina-Images', $value, false ) . 'value="Retina-Images">Retina-Images</option>
333
  <option ' . selected( 'none', $value, false ) . 'value="none">None</option>
334
  </select><small><br />' . __( 'In all cases (including "None"), Retina support will be added to the Responsive Images. Check the <a target="_blank" href="http://meowapps.com/wp-retina-2x/retina-methods/">Retina Methods</a> page if you want to know more about those methods.', 'wp-retina-2x' ) . '</small>';
335
- echo $html;
336
- }
337
 
338
  function admin_full_size_callback( $args ) {
339
- $value = get_option( 'wr2x_full_size', null );
340
  $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="wr2x_full_size" name="wr2x_full_size" value="1" ' .
341
  checked( 1, get_option( 'wr2x_full_size' ), false ) . '/>';
342
- $html .= '<label>Enable</label><br /><small>Checks for retina for full-size will be enabled and upload features made available in the <i>Retina Dashboard</i>.</small>';
343
- echo $html;
344
- }
345
 
346
  function admin_quality_callback( $args ) {
347
- $value = get_option( 'wr2x_quality', 90 );
348
  $html = '<input type="number" id="wr2x_quality" name="wr2x_quality" value="' . $value . '" />';
349
- $html .= __( '<br /><small>Sets image compression quality on a 1-100% scale as an integer (1-100). Default is 90. Only for JPG.</small>', 'wp-retina-2x' );
350
- echo $html;
351
- }
352
 
353
  function admin_debug_callback( $args ) {
354
- $value = get_option( 'wr2x_debug', null );
355
  $html = '<input type="checkbox" id="wr2x_debug" name="wr2x_debug" value="1" ' .
356
  checked( 1, get_option( 'wr2x_debug' ), false ) . '/>';
357
- $html .= __( '<label>Force Retina + Logging</label><br /><small>Displays retina and creates a <a href="' . plugins_url( "wp-retina-2x" ) . '/wp-retina-2x.log">log file</a> in the plugin folder.</small>', 'wp-retina-2x' );
358
- echo $html;
359
- }
360
 
361
  function admin_cdn_domain_callback( $args ) {
362
- $value = get_option( 'wr2x_cdn_domain', null );
363
  $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="text" id="wr2x_cdn_domain" name="wr2x_cdn_domain" value="' . $value . '" />';
364
- $html .= __( '<br /><small>If not empty, your site domain will be replaced with this CDN domain (PictureFill and HTML Rewrite only).</small>', 'wp-retina-2x' );
365
- echo $html;
366
- }
367
 
368
  function admin_over_http_check_callback( $args ) {
369
- $value = get_option( 'wr2x_over_http_check', null );
370
  $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="wr2x_over_http_check" name="wr2x_over_http_check" value="1" ' .
371
  checked( 1, get_option( 'wr2x_over_http_check' ), false ) . '/>';
372
- $html .= __( '<label>Enable</label><br /><small>Normally, the plugin checks if the Retina files exists through your filesystem. With this option, it will check using HTTP requests, that will enable Retina on exotic WordPress installs and also for images hosted on different servers.</small>', 'wp-retina-2x' );
373
- echo $html;
374
- }
375
 
376
  function admin_picturefill_keep_src_callback( $args ) {
377
- $value = get_option( 'wr2x_picturefill_keep_src', null );
378
  $html = '<input type="checkbox" id="wr2x_picturefill_keep_src" name="wr2x_picturefill_keep_src" value="1" ' .
379
  checked( 1, get_option( 'wr2x_picturefill_keep_src' ), false ) . '/>';
380
- $html .= __( '<label>Enable</label><br /><small>With PictureFill, <b>src</b> tags are replaced by <b>src-set</b> tags and consequently search engines might not be able to find and reference those images. This option is better for SEO, but Retina devices will download both normal and retina. Lazy Retina option is recommended with this.</small>', 'wp-retina-2x' );
381
- echo $html;
382
- }
383
 
384
  function admin_picturefill_lazysizes_callback( $args ) {
385
- $value = get_option( 'wr2x_picturefill_lazysizes', null );
386
  $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="wr2x_picturefill_lazysizes"
387
  name="wr2x_picturefill_lazysizes" value="1" ' .
388
  checked( 1, get_option( 'wr2x_picturefill_lazysizes' ), false ) . '/>';
389
- $html .= __( '<label>Enabled</label><br /><small>Retina images will not be loaded until the visitor gets close to them. HTML will be rewritten and the lazysizes script will be also loaded. </small>', 'wp-retina-2x' );
390
- echo $html;
391
- }
392
 
393
  function admin_picturefill_noscript_callback( $args ) {
394
- $value = get_option( 'wr2x_picturefill_noscript', null );
395
  $html = '<input type="checkbox" id="wr2x_picturefill_noscript"
396
  name="wr2x_picturefill_noscript" value="1" ' .
397
  checked( 1, get_option( 'wr2x_picturefill_noscript' ), false ) . '/>';
398
- $html .= __( '<label>Disable</label><br /><small>Only <a href="http://caniuse.com/#feat=srcset" target="_blank">the browsers with src-set support</a> will display Retina images. You can also choose this if you want to load the Picturefill Polyfill script manually or if it is already loaded by your theme.</small>', 'wp-retina-2x' );
399
- echo $html;
400
- }
401
 
402
  function admin_picturefill_css_background_callback( $args ) {
403
- $value = get_option( 'wr2x_picturefill_css_background', null );
404
  $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="wr2x_picturefill_css_background" name="wr2x_picturefill_css_background" value="1" ' .
405
  checked( 1, get_option( 'wr2x_picturefill_css_background' ), false ) . '/>';
406
- $html .= __( '<label>Retina-ize</label><br /><small>In your HTML, inline CSS Background will be replaced by the Retina version of the image.</small>', 'wp-retina-2x' );
407
- echo $html;
408
  }
409
 
410
  function admin_hide_retina_column_callback( $args ) {
411
- $value = get_option( 'wr2x_hide_retina_column', null );
412
  $html = '<input type="checkbox" id="wr2x_hide_retina_column" name="wr2x_hide_retina_column" value="1" ' .
413
  checked( 1, get_option( 'wr2x_hide_retina_column' ), false ) . '/>';
414
- $html .= __( '<label>Hide</label><br /><small>Hide the <i>Retina Column</i> in the Media Library.</small>', 'wp-retina-2x' );
415
- echo $html;
416
- }
417
 
418
  function admin_hide_retina_dashboard_callback( $args ) {
419
- $value = get_option( 'wr2x_hide_retina_dashboard', null );
420
  $html = '<input type="checkbox" id="wr2x_hide_retina_dashboard" name="wr2x_hide_retina_dashboard" value="1" ' .
421
  checked( 1, get_option( 'wr2x_hide_retina_dashboard' ), false ) . '/>';
422
- $html .= __( '<label>Hide</label><br /><small>Disable <i>Retina Dashboard</i> menu and tools.</small>', 'wp-retina-2x' );
423
- echo $html;
424
- }
425
 
426
  function admin_hide_pro_callback( $args ) {
427
- $value = get_option( 'wr2x_hide_pro', null );
428
  $html = '<input type="checkbox" id="wr2x_hide_pro" name="wr2x_hide_pro" value="1" ' .
429
  checked( 1, get_option( 'wr2x_hide_pro' ), false ) . '/>';
430
- $html .= __( '<label>Hide</label><br /><small>Hide information about Pro version.</small>', 'wp-retina-2x' );
431
- echo $html;
432
- }
433
 
434
  }
435
 
24
  Meow_WR2X_Admin::generate_rewrite_rules( $wp_rewrite, true );
25
  }
26
  }
27
+ $method = get_option( 'wr2x_method' );
28
+ $cdn = get_option( 'wr2x_cdn_domain' );
29
+ $disable_responsive = get_option( 'wr2x_disable_responsive', false );
30
+ $keep_src = get_option( 'wr2x_picturefill_keep_src', false );
31
+
32
+ if ( $method == 'HTML Rewrite' || $method == 'Retina-Images' || !empty( $cdn ) || $disable_responsive || $keep_src ) {
33
+ echo '<div class="error"><p>';
34
+ echo __( '<b>WARNING</b>. You are using an option that will be removed in a future release. The plan is to remove two methods (HTML Rewrite and Retina-Images), Disable Responsive, Custom CDN Domain, and Keep IMG SRC. Those options are not necessary, and it is better to keep the plugin clean and focus. This warning message will go away if you avoid using those options (and will disappear in a future release). If you are using one of those options and really would like to keep it, please come here to talk about it: <a target= "_blank" href="https://wordpress.org/support/topic/simplifying-wp-retina-2x-by-removing-options/">Discussions about removing options from WP Retina 2x</a>. Thanks :)', 'wp-retina-2x' );
35
+ echo '</p></div>';
36
+ }
37
  if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) {
38
  echo "<div class='error' style='margin-top: 20px;'><p>";
39
  _e( "JetPack's <b>Photon</b> module breaks features built in WP Retina 2x (as Photos moves the files away). A common and better alternative to Photon is to use <a href='http://tracking.maxcdn.com/c/97349/3982/378'>MaxCDN</a> (very popular), CloudFlare or Fastly.", 'wp-retina-2x' );
40
  echo "</p></div>";
41
+ }
42
  }
43
 
44
+ static function activate() {
45
+ global $wp_rewrite;
46
+ $wp_rewrite->flush_rules();
47
+ }
48
 
49
+ static function deactivate() {
50
+ remove_filter( 'generate_rewrite_rules', array( 'Meow_WR2X_Admin', 'generate_rewrite_rules' ) );
51
+ global $wp_rewrite;
52
+ $wp_rewrite->flush_rules();
53
+ }
54
 
55
  static function generate_rewrite_rules( $wp_rewrite, $flush = false ) {
56
  global $wp_rewrite;
88
  add_settings_field( 'wr2x_ignore_sizes', __( "Disabled Sizes", 'wp-retina-2x' ),
89
  array( $this, 'admin_ignore_sizes_callback' ),
90
  'wr2x_settings-menu', 'wr2x_settings' );
 
 
 
91
  add_settings_field( 'wr2x_method', __( "Method", 'wp-retina-2x' ),
92
  array( $this, 'admin_method_callback' ),
93
  'wr2x_settings-menu', 'wr2x_settings' );
102
  'wr2x_settings-menu', 'wr2x_settings' );
103
 
104
  register_setting( 'wr2x_settings', 'wr2x_ignore_sizes' );
 
105
  register_setting( 'wr2x_settings', 'wr2x_full_size' );
106
  register_setting( 'wr2x_settings', 'wr2x_method' );
107
  register_setting( 'wr2x_settings', 'wr2x_quality' );
108
 
109
  // SUBMENU > Settings > Advanced Settings
110
  add_settings_section( 'wr2x_advanced_settings', null, null, 'wr2x_advanced_settings-menu' );
111
+ add_settings_field( 'wr2x_auto_generate', __( "Auto Generate", 'wp-retina-2x' ),
112
+ array( $this, 'admin_auto_generate_callback' ),
113
+ 'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
114
+ add_settings_field( 'wr2x_regenerate_thumbnails', __( "Regenerate Thumbnails", 'wp-retina-2x' ),
115
+ array( $this, 'admin_regenerate_thumbnails_callback' ),
116
  'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
117
  add_settings_field( 'wr2x_disable_medium_large', __( "Disable Medium Large", 'wp-retina-2x' ),
118
  array( $this, 'admin_disable_medium_large_callback' ),
119
  'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
 
 
 
120
  add_settings_field( 'wr2x_over_http_check', __( "Over HTTP Check", 'wp-retina-2x' ) . "<br />(Pro)",
121
  array( $this, 'admin_over_http_check_callback' ),
122
  'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
124
  array( $this, 'admin_debug_callback' ),
125
  'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
126
 
127
+ add_settings_field( 'wr2x_disable_responsive', __( "<br /><br />Disable Responsive", 'wp-retina-2x' ),
128
+ array( $this, 'admin_disable_responsive_callback' ),
129
+ 'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
130
+ add_settings_field( 'wr2x_cdn_domain', __( "Custom CDN Domain", 'wp-retina-2x' ) . "<br />(Pro)",
131
+ array( $this, 'admin_cdn_domain_callback' ),
132
+ 'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
133
+
134
+ register_setting( 'wr2x_advanced_settings', 'wr2x_auto_generate' );
135
+ register_setting( 'wr2x_advanced_settings', 'wr2x_regenerate_thumbnails' );
136
  register_setting( 'wr2x_advanced_settings', 'wr2x_disable_responsive' );
137
  register_setting( 'wr2x_advanced_settings', 'wr2x_disable_medium_large' );
138
  register_setting( 'wr2x_advanced_settings', 'wr2x_cdn_domain' );
196
  echo "<p><span>" . __( "Current method:", 'wp-retina-2x' ) . " <u>" . __( "HTML Rewrite", 'wp-retina-2x' ) . "</u>.</span>";
197
  if ( $method == 'retina.js' )
198
  echo "<p><span>" . __( "Current method:", 'wp-retina-2x' ) . " <u>" . __( "Retina.js", 'wp-retina-2x' ) . "</u>.</span>";
199
+ if ( $method == 'Picturefill' )
200
+ echo "<p><span>" . __( "Current method:", 'wp-retina-2x' ) . " <u>" . __( "PictureFill", 'wp-retina-2x' ) . "</u>.</span>";
201
+ if ( $method == 'Responsive' )
202
+ echo "<p><span>" . __( "Current method:", 'wp-retina-2x' ) . " <u>" . __( "Responsive Images", 'wp-retina-2x' ) . "</u>.</span>";
203
  if ( $method == 'Retina-Images' ) {
204
+ echo "<p><span>" . __( "Current method:", 'wp-retina-2x' ) . " <u>" . __( "HTML Rewrite", 'wp-retina-2x' ) . "</u>.</span>";
205
+ if ( defined( 'MULTISITE' ) && MULTISITE == true ) {
206
+ if ( get_site_option( 'ms_files_rewriting' ) ) {
207
+ // MODIFICATION: Craig Foster
208
+ // 'ms_files_rewriting' support
209
+ echo " <span style='color: red;'>" . __( "By the way, you are using a <b>WordPress Multi-Site installation</b>! You must edit your .htaccess manually and add '<b>RewriteRule ^files/(.+) wp-content/plugins/wp-retina-2x/wr2x_image.php?ms=true&file=$1 [L]</b>' as the first RewriteRule if you want the server-side to work.", 'wp-retina-2x' ) . "</span>";
210
+ }
211
+ else
212
+ echo " <span style='color: red;'>" . __( "By the way, you are using a <b>WordPress Multi-Site installation</b>! You must edit your .htaccess manually and add '<b>RewriteRule ^(wp-content/.+\.(png|gif|jpg|jpeg|bmp|PNG|GIF|JPG|JPEG|BMP)) wp-content/plugins/wp-retina-2x/wr2x_image.php?ms=true&file=$1 [L]</b>' as the first RewriteRule if you want the server-side to work.", 'wp-retina-2x' ) . "</span>";
213
+ }
214
  echo "</p>";
215
  if ( !get_option('permalink_structure') )
216
  echo "<p><span style='color: red;'>" . __( "The permalinks are not enabled. They need to be enabled in order to use the server-side method.", 'wp-retina-2x' ) . "</span>";
238
  <div class="inside">
239
  <form method="post" action="options.php">
240
  <?php settings_fields( 'wr2x_settings' ); ?>
241
+ <?php do_settings_sections( 'wr2x_settings-menu' ); ?>
242
+ <?php submit_button(); ?>
243
  </form>
244
  </div>
245
  </div>
249
  <div class="inside">
250
  <form method="post" action="options.php">
251
  <?php settings_fields( 'wr2x_advanced_settings' ); ?>
252
+ <?php do_settings_sections( 'wr2x_advanced_settings-menu' ); ?>
253
+ <?php submit_button(); ?>
254
  </form>
255
  </div>
256
  </div>
309
  ( array_key_exists( $name, $ignore_sizes ) ? 'checked' : '' ) . '/>' . sprintf( "<label><div style='float: left; text-align: right; margin-right: 5px; width: 20px;'>%s</div> <b>%s</b></label> <small>(Normal: %dx%d, Retina: %dx%d)</small>", MeowApps_Admin::size_shortname( $name ), $name, $attr['width'], $attr['height'], $attr['width'] * 2, $attr['height'] * 2 ) . '<br>';
310
  }
311
  $html .= '<br /><small class="description">' .
312
+ __( 'The selected sizes will <b>not</b> have their retina equivalent generated. It is recommended to disable the sizes for which <i>Normal</i> superior to 1200.', 'wp-retina-2x' ) . '</small>';
313
  echo $html;
314
  }
315
 
316
  function admin_auto_generate_callback( $args ) {
317
+ $value = get_option( 'wr2x_auto_generate', null );
318
  $html = '<input type="checkbox" id="wr2x_auto_generate" name="wr2x_auto_generate" value="1" ' .
319
  checked( 1, get_option( 'wr2x_auto_generate' ), false ) . '/>';
320
+ $html .= '<label>Enabled</label><br /><small>Generate the Retina thumbnails on new upload and thumbnails creation. The <i>Disabled Sizes</i> will be skipped.</small>';
321
+ echo $html;
322
+ }
323
 
324
+ function admin_regenerate_thumbnails_callback( $args ) {
325
+ $value = get_option( 'wr2x_regenerate_thumbnails', false );
326
+ $html = '<input type="checkbox" id="wr2x_regenerate_thumbnails" name="wr2x_regenerate_thumbnails" value="1" ' .
327
+ checked( 1, get_option( 'wr2x_regenerate_thumbnails' ), false ) . '/>';
328
+ $html .= '<label>Enabled</label><br /><small>On each <b>Generate</b> action, all standard thumbnails will be regenerated (exactly the same function as Regenerate Thumbnail), and only then the Retina thumbnails will be created (depending on the Auto Generate option).</small>';
329
+ echo $html;
330
+ }
331
+
332
  function admin_disable_responsive_callback( $args ) {
333
+ $value = get_option( 'wr2x_disable_responsive', null );
334
+ $html = '<br /><br /><input type="checkbox" id="wr2x_disable_responsive" name="wr2x_disable_responsive" value="1" ' .
335
  checked( 1, get_option( 'wr2x_disable_responsive' ), false ) . '/>';
336
+ $html .= '<label>Disable the Responsive Images feature.</label><br /><small>Get back control over your HTML if you need.</small>';
337
+ echo $html;
338
+ }
339
 
340
  function admin_disable_medium_large_callback( $args ) {
341
+ $value = get_option( 'wr2x_disable_medium_large', null );
342
  $html = '<input type="checkbox" id="wr2x_disable_medium_large" name="wr2x_disable_medium_large" value="1" ' .
343
  checked( 1, get_option( 'wr2x_disable_medium_large' ), false ) . '/>';
344
+ $html .= '<label>Remove the "Medium Large" image size.</label><br /><small>You probably don\'t need this.</small>';
345
+ echo $html;
346
+ }
347
 
348
  function admin_method_callback( $args ) {
349
+ $value = get_option( 'wr2x_method', 'none' );
350
  $html = '<select id="wr2x_method" name="wr2x_method">
351
+ <option ' . selected( 'Picturefill', $value, false ) . 'value="Picturefill">Recommended: Picturefill</option>
352
+ <option ' . selected( 'Responsive', $value, false ) . 'value="Responsive">Responsive-Images (Native WP 4.4+)</option>
353
+ <option ' . selected( 'retina.js', $value, false ) . 'value="retina.js">Retina.js (Client-side)</option>
354
+ <option ' . selected( 'HTML Rewrite', $value, false ) . 'value="HTML Rewrite">HTML Rewrite</option>
355
  <option ' . selected( 'Retina-Images', $value, false ) . 'value="Retina-Images">Retina-Images</option>
356
  <option ' . selected( 'none', $value, false ) . 'value="none">None</option>
357
  </select><small><br />' . __( 'In all cases (including "None"), Retina support will be added to the Responsive Images. Check the <a target="_blank" href="http://meowapps.com/wp-retina-2x/retina-methods/">Retina Methods</a> page if you want to know more about those methods.', 'wp-retina-2x' ) . '</small>';
358
+ echo $html;
359
+ }
360
 
361
  function admin_full_size_callback( $args ) {
362
+ $value = get_option( 'wr2x_full_size', null );
363
  $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="wr2x_full_size" name="wr2x_full_size" value="1" ' .
364
  checked( 1, get_option( 'wr2x_full_size' ), false ) . '/>';
365
+ $html .= '<label>Enable</label><br /><small>Checks for retina for full-size will be enabled and upload features made available in the <i>Retina Dashboard</i>.</small>';
366
+ echo $html;
367
+ }
368
 
369
  function admin_quality_callback( $args ) {
370
+ $value = get_option( 'wr2x_quality', 90 );
371
  $html = '<input type="number" id="wr2x_quality" name="wr2x_quality" value="' . $value . '" />';
372
+ $html .= __( '<br /><small>Sets image compression quality on a 1-100% scale as an integer (1-100). Default is 90. Only for JPG.</small>', 'wp-retina-2x' );
373
+ echo $html;
374
+ }
375
 
376
  function admin_debug_callback( $args ) {
377
+ $value = get_option( 'wr2x_debug', null );
378
  $html = '<input type="checkbox" id="wr2x_debug" name="wr2x_debug" value="1" ' .
379
  checked( 1, get_option( 'wr2x_debug' ), false ) . '/>';
380
+ $html .= __( '<label>Force Retina + Logging</label><br /><small>Displays retina and creates a <a href="' . plugins_url( "wp-retina-2x" ) . '/wp-retina-2x.log">log file</a> in the plugin folder.</small>', 'wp-retina-2x' );
381
+ echo $html;
382
+ }
383
 
384
  function admin_cdn_domain_callback( $args ) {
385
+ $value = get_option( 'wr2x_cdn_domain', null );
386
  $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="text" id="wr2x_cdn_domain" name="wr2x_cdn_domain" value="' . $value . '" />';
387
+ $html .= __( '<br /><small>If not empty, your site domain will be replaced with this CDN domain (PictureFill and HTML Rewrite only).</small>', 'wp-retina-2x' );
388
+ echo $html;
389
+ }
390
 
391
  function admin_over_http_check_callback( $args ) {
392
+ $value = get_option( 'wr2x_over_http_check', null );
393
  $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="wr2x_over_http_check" name="wr2x_over_http_check" value="1" ' .
394
  checked( 1, get_option( 'wr2x_over_http_check' ), false ) . '/>';
395
+ $html .= __( '<label>Enable</label><br /><small>Normally, the plugin checks if the Retina files exists through your filesystem. With this option, it will check using HTTP requests, that will enable Retina on exotic WordPress installs and also for images hosted on different servers.</small>', 'wp-retina-2x' );
396
+ echo $html;
397
+ }
398
 
399
  function admin_picturefill_keep_src_callback( $args ) {
400
+ $value = get_option( 'wr2x_picturefill_keep_src', null );
401
  $html = '<input type="checkbox" id="wr2x_picturefill_keep_src" name="wr2x_picturefill_keep_src" value="1" ' .
402
  checked( 1, get_option( 'wr2x_picturefill_keep_src' ), false ) . '/>';
403
+ $html .= __( '<label>Enable</label><br /><small>With PictureFill, <b>src</b> tags are replaced by <b>src-set</b> tags and consequently search engines might not be able to find and reference those images. This option is better for SEO, but Retina devices will download both normal and retina. Lazy Retina option is recommended with this.</small>', 'wp-retina-2x' );
404
+ echo $html;
405
+ }
406
 
407
  function admin_picturefill_lazysizes_callback( $args ) {
408
+ $value = get_option( 'wr2x_picturefill_lazysizes', null );
409
  $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="wr2x_picturefill_lazysizes"
410
  name="wr2x_picturefill_lazysizes" value="1" ' .
411
  checked( 1, get_option( 'wr2x_picturefill_lazysizes' ), false ) . '/>';
412
+ $html .= __( '<label>Enabled</label><br /><small>Retina images will not be loaded until the visitor gets close to them. HTML will be rewritten and the lazysizes script will be also loaded. </small>', 'wp-retina-2x' );
413
+ echo $html;
414
+ }
415
 
416
  function admin_picturefill_noscript_callback( $args ) {
417
+ $value = get_option( 'wr2x_picturefill_noscript', null );
418
  $html = '<input type="checkbox" id="wr2x_picturefill_noscript"
419
  name="wr2x_picturefill_noscript" value="1" ' .
420
  checked( 1, get_option( 'wr2x_picturefill_noscript' ), false ) . '/>';
421
+ $html .= __( '<label>Disable</label><br /><small>Only <a href="http://caniuse.com/#feat=srcset" target="_blank">the browsers with src-set support</a> will display Retina images. You can also choose this if you want to load the Picturefill Polyfill script manually or if it is already loaded by your theme.</small>', 'wp-retina-2x' );
422
+ echo $html;
423
+ }
424
 
425
  function admin_picturefill_css_background_callback( $args ) {
426
+ $value = get_option( 'wr2x_picturefill_css_background', null );
427
  $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="wr2x_picturefill_css_background" name="wr2x_picturefill_css_background" value="1" ' .
428
  checked( 1, get_option( 'wr2x_picturefill_css_background' ), false ) . '/>';
429
+ $html .= __( '<label>Retina-ize</label><br /><small>In your HTML, inline CSS Background will be replaced by the Retina version of the image.</small>', 'wp-retina-2x' );
430
+ echo $html;
431
  }
432
 
433
  function admin_hide_retina_column_callback( $args ) {
434
+ $value = get_option( 'wr2x_hide_retina_column', null );
435
  $html = '<input type="checkbox" id="wr2x_hide_retina_column" name="wr2x_hide_retina_column" value="1" ' .
436
  checked( 1, get_option( 'wr2x_hide_retina_column' ), false ) . '/>';
437
+ $html .= __( '<label>Hide</label><br /><small>Hide the <i>Retina Column</i> in the Media Library.</small>', 'wp-retina-2x' );
438
+ echo $html;
439
+ }
440
 
441
  function admin_hide_retina_dashboard_callback( $args ) {
442
+ $value = get_option( 'wr2x_hide_retina_dashboard', null );
443
  $html = '<input type="checkbox" id="wr2x_hide_retina_dashboard" name="wr2x_hide_retina_dashboard" value="1" ' .
444
  checked( 1, get_option( 'wr2x_hide_retina_dashboard' ), false ) . '/>';
445
+ $html .= __( '<label>Hide</label><br /><small>Disable <i>Retina Dashboard</i> menu and tools.</small>', 'wp-retina-2x' );
446
+ echo $html;
447
+ }
448
 
449
  function admin_hide_pro_callback( $args ) {
450
+ $value = get_option( 'wr2x_hide_pro', null );
451
  $html = '<input type="checkbox" id="wr2x_hide_pro" name="wr2x_hide_pro" value="1" ' .
452
  checked( 1, get_option( 'wr2x_hide_pro' ), false ) . '/>';
453
+ $html .= __( '<label>Hide</label><br /><small>Hide information about Pro version.</small>', 'wp-retina-2x' );
454
+ echo $html;
455
+ }
456
 
457
  }
458