WP Retina 2x - Version 4.8.0

Version Description

  • Add: Retina Image Quality for JPG (between 0 and 100). I know this little setting was really wanted :)
  • Fix: Disabled sizes weren't really disabled in the UI.
  • Add: Handles incompatibility with JetPack's Photon.
  • Info: If you are using Lightroom, please have a look at my plugin for synchronizing your Lightroom to WordPress: http://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 :)
Download this release

Release Info

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

Version 4.8.0

common/img/meowapps.png ADDED
Binary file
common/img/wpengine.png ADDED
Binary file
common/meow-admin.css ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* MEOW BOX (SETTINGS BOX) */
2
+
3
+ .meow-box {
4
+ box-sizing: border-box;
5
+ border: 1px solid #e5e5e5;
6
+ box-shadow: 2px 2px 1px rgba(0,0,0,.02);
7
+ background: #fff;
8
+ color: #444;
9
+ margin-bottom: 15px;
10
+ font-size: 13px !important;
11
+ border-top-right-radius: 8px;
12
+ }
13
+
14
+ .meow-box input, .meow-box th, .meow-box label, .meow-box select {
15
+ font-size: 13px !important;
16
+ }
17
+
18
+ .meow-box small {
19
+ font-size: 11px !important;
20
+ }
21
+
22
+ .meow-box h3 {
23
+ font-size: 13px;
24
+ padding: 4px 12px;
25
+ margin: 0;
26
+ background: #3c3c3c;
27
+ color: #ffffff;
28
+ text-transform: uppercase;
29
+ border-top-right-radius: 8px;
30
+ /*border-bottom: 1px solid #eee;*/
31
+ }
32
+
33
+ .meow-box h3 .dashicons {
34
+ position: relative;
35
+ top: 0px;
36
+ margin-right: 5px;
37
+ }
38
+
39
+ .meow-box .pro_info {
40
+ padding: 5px;
41
+ margin: 10px -10px 5px -10px;
42
+ font-size: 11px;
43
+ line-height: 13px;
44
+ }
45
+
46
+ .meow-box .pro_info.enabled {
47
+ background: #4482d2;
48
+ border-left: 5px solid #4482d2;
49
+ color: white;
50
+ }
51
+
52
+ .meow-box .pro_info.disabled {
53
+ background: #96555b;
54
+ border-left: 5px solid #632329;
55
+ color: white;
56
+ }
57
+
58
+ .meow-box .pro_info.disabled a {
59
+ background: #96555b;
60
+ color: red;
61
+ text-decoration: none;
62
+ }
63
+
64
+ .meow-box .inside {
65
+ margin: 10px;
66
+ }
67
+
68
+ .meow-box th {
69
+ padding: 10px 10px 10px 0px;
70
+ width: 22%;
71
+ }
72
+
73
+ .meow-box td {
74
+ padding: 10px 10px;
75
+ }
76
+
77
+ .meow-box p.submit {
78
+ text-align: right;
79
+ margin: 10px -10px -10px -10px;
80
+ padding: 7px 10px 10px 0px !important;
81
+ border-top: 1px solid #eee !important;
82
+ max-width: inherit;
83
+ background: rgba(125, 125, 125, 0.04);
84
+ border-radius: 0px;
85
+ }
86
+
87
+ .meow-box [type="text"], .meow-box select {
88
+ width: 100%;
89
+ }
90
+
91
+ /* CONTROLS INSIDE A COLUMN (LABEL ON THE LEFT, VALUE ON THE RIGHT) */
92
+ .meow-box td [type="text"], .meow-box td [type="checkbox"], .meow-box td select {
93
+ margin-top: -3px;
94
+ }
95
+
96
+ .meow-header-ad {
97
+ float: right;
98
+ }
99
+
100
+ /* BUTTONS */
101
+
102
+ .meow-button-xs {
103
+ font-size: 10px !important;
104
+ height: 20px !important;
105
+ line-height: 18px !important;
106
+ position: relative !important;
107
+ top: 1px !important;
108
+ text-align: center !important
109
+ }
110
+
111
+ /* MODAL */
112
+
113
+ #meow-modal-info-backdrop {
114
+ background: rgba(0, 0, 0, 0.75);
115
+ position: fixed;
116
+ top: 0px;
117
+ bottom: 0px;
118
+ right: 0px;
119
+ left: 0px;
120
+ z-index: 10000;
121
+ }
122
+
123
+ #meow-modal-info {
124
+ background: white;
125
+ box-shadow: 0px 0px 5px black;
126
+ padding: 15px;
127
+ overflow-y: scroll;
128
+ position: fixed;
129
+ z-index: 10000;
130
+ left: 100px;
131
+ right: 100px;
132
+ top: 50px;
133
+ bottom: 50px;
134
+ }
135
+
136
+ #meow-modal-info h3 {
137
+ height: 25px;
138
+ border-bottom: 2px solid #808080;
139
+ }
140
+
141
+ #meow-modal-info td {
142
+ text-align: center;
143
+ font-size: 11px;
144
+ border: 1px solid #D3DCFF;
145
+ padding: 10px 15px;
146
+ background: #EFF8FF;
147
+ }
148
+
149
+ #meow-modal-info .close {
150
+ float: right;
151
+ font-size: 18px;
152
+ font-weight: bold;
153
+ font-family: Verdana;
154
+ cursor: pointer;
155
+ }
156
+
157
+ #meow-modal-info .loading {
158
+ background-color: #F2F2F2;
159
+ text-align: center;
160
+ padding-top: 10px;
161
+ background-size: 32px 32px;
162
+ }
163
+
164
+ #meow-modal-info .meow-sized-image {
165
+ width: 19px;
166
+ height: 19px;
167
+ margin-right: 10px;
168
+ }
169
+
170
+ /* IMAGE SIZES RELATED INFO */
171
+
172
+ .meow-sized-images {
173
+ margin-top: 0px;
174
+ cursor: pointer;
175
+ }
176
+
177
+ .meow-sized-images li, #meow-modal-info .meow-sized-image {
178
+ display: block;
179
+ color: white;
180
+ padding: 5px 0px;
181
+ font-size: 10px;
182
+ text-align: center;
183
+ width: 18px;
184
+ height: 18px;
185
+ line-height: 8px;
186
+ background: black;
187
+ float: left;
188
+ margin-right: 1px;
189
+ box-sizing: border-box;
190
+ margin-bottom: 2px;
191
+ }
192
+
193
+ .meow-sized-images:after {
194
+ clear: both;
195
+ content:""; display:table;
196
+ }
197
+
198
+ .meow-sized-images + span {
199
+ position: relative;
200
+ top: -12px;
201
+ }
202
+
203
+ /* MEOW COLORS */
204
+
205
+ .meow-bk-blue {
206
+ background: #3C82C7 !important;
207
+ color: white;
208
+ }
209
+
210
+ .meow-bk-orange {
211
+ background: #f1900e !important;
212
+ color: white;
213
+ }
214
+
215
+ .meow-bk-red {
216
+ background: #c53a47 !important;
217
+ color: white;
218
+ }
219
+
220
+ .meow-bk-gray {
221
+ background: gray !important;
222
+ color: white;
223
+ }
224
+
225
+ .meow-bk-green {
226
+ background: #2b9463 !important;
227
+ color: white;
228
+ }
229
+
230
+ .meow-bk-black {
231
+ background: #3c3c3c !important;
232
+ color: white;
233
+ }
234
+
235
+ .meow-bk-purple {
236
+ background: #984c96 !important;
237
+ color: white;
238
+ }
239
+
240
+ /* DASHBOARD */
241
+
242
+ .meow-dashboard .meow-box li {
243
+ border-bottom: 1px solid #eee;
244
+ padding: 0px 10px 10px 10px;
245
+ }
246
+
247
+ .meow-dashboard .meow-box li:last-child {
248
+ border: none;
249
+ padding-bottom: 0px;
250
+ }
251
+
252
+ .meow-button-xs .dashicons {
253
+ font-size: 18px !important;
254
+ }
255
+
256
+ .meow-button-xs.updating-message:before {
257
+ margin-top: 0px !important;
258
+ }
259
+
260
+ .meow-button-xs.updating-message * {
261
+ display: none;
262
+ }
263
+
264
+ #phpinfo {
265
+ font-size: 11px;
266
+ }
267
+
268
+ #phpinfo .e {
269
+ padding: 5px;
270
+ background: lightgray;
271
+ }
272
+
273
+ #phpinfo .h th {
274
+ padding: 5px;
275
+ color: white;
276
+ background: gray;
277
+ text-align: left;
278
+ font-size: 14px !important;
279
+ }
280
+
281
+ #phpinfo h1 {
282
+ padding: 10px 0px;
283
+ font-weight: bold;
284
+ }
285
+
286
+ #phpinfo h2 {
287
+ padding: 10px 0px;
288
+ font-weight: bold;
289
+ font-size: 20px;
290
+ }
291
+
292
+ #error_log {
293
+ font-size: 12px;
294
+ }
295
+
296
+ /* ROWS AND COLUMNS */
297
+ .meow-col { display: block; float:left; margin: 1% 0 1% 1.6%; }
298
+ .meow-col:first-child { margin-left: 0; }
299
+
300
+ /* GROUPING */
301
+ .meow-row { clear: both; padding: 0px; margin: 0px; }
302
+ .meow-row:before,
303
+ .meow-row:after { content:""; display:table; }
304
+ .meow-row:after { clear:both; }
305
+ .meow-row { zoom:1; /* For IE 6/7 */ }
306
+
307
+ /* GRID OF THREE */
308
+ .meow-span_3_of_3 { width: 100%; }
309
+ .meow-span_2_of_3 { width: 66.1%; }
310
+ .meow-span_1_of_3 { width: 32.2%; }
311
+
312
+ /* GRID OF TWO */
313
+ .meow-span_2_of_2 { width: 100%; }
314
+ .meow-span_1_of_2 { width: 49.2%; }
315
+
316
+ @media only screen and (max-width: 480px) {
317
+ .meow-col { margin: 0 0 0px 0;}
318
+ .meow-span_3_of_3, .meow-span_2_of_3, .meow-span_1_of_3 { width: 100%; }
319
+ .meow-span_2_of_2, .meow-span_1_of_2 { width: 100%; }
320
+ .meow-header-ad { display: none !important; }
321
+ .meow-box [type="text"] { width: 100% !important; }
322
+ }
common/meow_admin.php ADDED
@@ -0,0 +1,375 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists( 'Meow_Admin' ) ) {
4
+
5
+ class Meow_Admin {
6
+
7
+ public static $loaded = false;
8
+ public static $version = "0.3";
9
+ public $prefix = null;
10
+ public $item = null;
11
+
12
+ public function __construct( $prefix = null, $item = null, $domain = '' ) {
13
+ $this->domain = $domain;
14
+ if ( !Meow_Admin::$loaded ) {
15
+ if ( is_admin() ) {
16
+ add_action( 'admin_menu', array( $this, 'admin_menu_start' ) );
17
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
18
+ add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
19
+ }
20
+ }
21
+ if ( !empty( $prefix ) && !empty( $item ) ) {
22
+ $this->prefix = $prefix;
23
+ $this->item = $item;
24
+ if ( is_admin() ) {
25
+ add_action( 'update_option_' . $prefix . '_pro_serial', array( $this, 'serial_updated' ), 10, 2 );
26
+ add_action( 'admin_menu', array( $this, 'admin_menu_for_serialkey' ) );
27
+ }
28
+ }
29
+ Meow_Admin::$loaded = true;
30
+ }
31
+
32
+ function display_ads() {
33
+ return !get_option( 'meowapps_hide_ads', false );
34
+ }
35
+
36
+ function display_title( $title = "Meow Apps",
37
+ $author = "By <a style='text-decoration: none;' href='http://meowapps.com' target='_blank'>Jordy Meow</a>" ) {
38
+ if ( $this->display_ads() ) {
39
+ echo '<a class="meow-header-ad" target="_blank" href="http://www.shareasale.com/r.cfm?b=906810&u=767054&m=41388&urllink=&afftrack="">
40
+ <img src="' . $this->common_url( 'img/wpengine.png' ) . '" height="60" border="0" /></a>';
41
+ }
42
+ ?>
43
+ <h1 style="line-height: 16px;">
44
+ <img width="36" style="margin-right: 10px; float: left; position: relative; top: -5px;"
45
+ src="<?php echo $this->meowapps_logo_url(); ?>"><?php echo $title; ?><br />
46
+ <span style="font-size: 12px"><?php echo $author; ?></span>
47
+ </h1>
48
+ <div style="clear: both;"></div>
49
+ <?php
50
+ }
51
+
52
+ function admin_enqueue_scripts() {
53
+ wp_register_style( 'meowapps-admin-css', $this->common_url( 'meow-admin.css' ) );
54
+ wp_enqueue_style( 'meowapps-admin-css' );
55
+ }
56
+
57
+ function admin_menu_start() {
58
+ if ( get_option( 'meowapps_hide_meowapps', false ) ) {
59
+ register_setting( 'general', 'meowapps_hide_meowapps' );
60
+ add_settings_field( 'meowapps_hide_ads', 'Meow Apps Menu', array( $this, 'meowapps_hide_dashboard_callback' ), 'general' );
61
+ return;
62
+ }
63
+
64
+ // Creates standard menu if it does NOT exist
65
+ global $submenu;
66
+ if ( !isset( $submenu[ 'meowapps-main-menu' ] ) ) {
67
+ add_menu_page( 'Meow Apps', 'Meow Apps', 'manage_options', 'meowapps-main-menu',
68
+ array( $this, 'admin_meow_apps' ), 'dashicons-camera', 82 );
69
+ add_submenu_page( 'meowapps-main-menu', __( 'Dashboard', $this->domain ),
70
+ __( 'Dashboard', $this->domain ), 'manage_options',
71
+ 'meowapps-main-menu', array( $this, 'admin_meow_apps' ) );
72
+ }
73
+
74
+ add_settings_section( 'meowapps_common_settings', null, null, 'meowapps_common_settings-menu' );
75
+ add_settings_field( 'meowapps_hide_meowapps', "Main Menu",
76
+ array( $this, 'meowapps_hide_dashboard_callback' ),
77
+ 'meowapps_common_settings-menu', 'meowapps_common_settings' );
78
+ add_settings_field( 'meowapps_hide_ads', "Ads",
79
+ array( $this, 'meowapps_hide_ads_callback' ),
80
+ 'meowapps_common_settings-menu', 'meowapps_common_settings' );
81
+ register_setting( 'meowapps_common_settings', 'meowapps_hide_meowapps' );
82
+ register_setting( 'meowapps_common_settings', 'meowapps_hide_ads' );
83
+ }
84
+
85
+ function meowapps_hide_ads_callback() {
86
+ $value = get_option( 'meowapps_hide_ads', null );
87
+ $html = '<input type="checkbox" id="meowapps_hide_ads" name="meowapps_hide_ads" value="1" ' .
88
+ checked( 1, get_option( 'meowapps_hide_ads' ), false ) . '/>';
89
+ $html .= '<label>Hide</label><br /><small>' . __( 'Doesn\'t display the ads.', $this->domain ) . '</small>';
90
+ echo $html;
91
+ }
92
+
93
+ function meowapps_hide_dashboard_callback() {
94
+ $value = get_option( 'meowapps_hide_meowapps', null );
95
+ $html = '<input type="checkbox" id="meowapps_hide_meowapps" name="meowapps_hide_meowapps" value="1" ' .
96
+ checked( 1, get_option( 'meowapps_hide_meowapps' ), false ) . '/>';
97
+ $html .= __( '<label>Hide <b>Meow Apps</b> Menu</label><br /><small>Hide Meow Apps menu and all its components, for a nicer an faster WordPress admin UI. An option will be added in Settings > General to display it again.</small>', $this->domain );
98
+ echo $html;
99
+ }
100
+
101
+ function admin_menu_for_serialkey() {
102
+ // SUBMENU > Settings > Pro Serial
103
+ add_settings_section( $this->prefix . '_settings_serialkey', null, null, $this->prefix . '_settings_serialkey-menu' );
104
+ add_settings_field( $this->prefix . '_pro_serial', __( "Serial Key", $this->domain ),
105
+ array( $this, 'admin_serialkey_callback' ),
106
+ $this->prefix . '_settings_serialkey-menu', $this->prefix . '_settings_serialkey' );
107
+ register_setting( $this->prefix . '_settings_serialkey', $this->prefix . '_pro_serial' );
108
+ }
109
+
110
+ function admin_serialkey_callback( $args ) {
111
+ $value = get_option( $this->prefix . '_pro_serial', null );
112
+ $html = '<input type="text" id="' . $this->prefix . '_pro_serial" name="' . $this->prefix . '_pro_serial" value="' . $value . '" />';
113
+ echo $html;
114
+ }
115
+
116
+ function display_serialkey_box( $url = "https://meowapps.com/" ) {
117
+ $status = get_option( $this->prefix . '_pro_status' );
118
+ ?>
119
+ <div class="meow-box">
120
+ <h3 class="<?php echo $this->is_pro() ? 'meow-bk-blue' : 'meow-bk-red'; ?>">Pro Version <?php echo $this->is_pro() ? '(enabled)' : '(disabled)'; ?></h3>
121
+ <div class="inside">
122
+ <form method="post" action="options.php">
123
+ <?php if ( !empty( $status ) ): ?>
124
+ <div class="pro_info <?php echo $this->is_pro() ? 'enabled' : 'disabled'; ?>">
125
+ <?php echo get_option( $this->prefix . '_pro_status' ); ?>
126
+ </div>
127
+ <?php endif; ?>
128
+ <?php settings_fields( $this->prefix . '_settings_serialkey' ); ?>
129
+ <?php do_settings_sections( $this->prefix . '_settings_serialkey-menu' ); ?>
130
+ <?php if ( !$this->is_pro() ): ?>
131
+ <small class="description">
132
+ <?php echo sprintf(
133
+ __( 'Insert your serial key above. If you don\'t have one yet, you can get one <a target="_blank" href="%s">here.</a>',
134
+ $this->domain ),
135
+ $url );
136
+ ?>
137
+ </small>
138
+ <?php endif; ?>
139
+ <?php submit_button(); ?>
140
+ </form>
141
+ </div>
142
+ </div>
143
+ <?php
144
+ }
145
+
146
+ function serial_updated( $old_value, $new_value ) {
147
+ if ( $old_value != $new_value ) {
148
+ $this->validate_pro( $new_value );
149
+ }
150
+ }
151
+
152
+ function is_pro() {
153
+ $prefix = $this->prefix;
154
+ $validated = get_transient( $prefix . '_validated' );
155
+ $subscr_id = get_option( $prefix . '_pro_serial', "" );
156
+ if ( $validated )
157
+ return !empty( $subscr_id );
158
+ if ( !empty( $subscr_id ) )
159
+ return $this->validate_pro( $subscr_id );
160
+ return false;
161
+ }
162
+
163
+ function validate_pro( $subscr_id ) {
164
+ $prefix = $this->prefix;
165
+ $item = $this->item;
166
+ delete_option( $prefix . '_pro_serial', "" );
167
+ update_option( $prefix . '_pro_status', "" );
168
+ set_transient( $prefix . '_validated', false, 0 );
169
+ if ( empty( $subscr_id ) )
170
+ return false;
171
+ $bodyreq = array( 'subscr_id' => $subscr_id, 'item' => $item, 'url' => get_site_url() );
172
+ $response = wp_remote_post( 'https://meowapps.com/wp-json/meow/v1/auth', array(
173
+ 'body' => $bodyreq,
174
+ 'user-agent' => "MeowApps",
175
+ 'sslverify' => false,
176
+ 'timeout' => 45,
177
+ 'method' => 'POST'
178
+ ));
179
+ $body = is_array( $response ) ? $response['body'] : null;
180
+ $post = @json_decode( $body );
181
+ if ( !$post || ( property_exists( $post, 'code' ) ) ) {
182
+ $status = __( "There was an error while validating the serial.<br />Please contact <a target='_blank' href='https://meowapps.com/contact/'>Meow Apps</a> and mention the following log: <br /><ul>", $this->domain );
183
+ $status .= "<li>Server IP: <b>" . gethostbyname( $_SERVER['SERVER_NAME'] ) . "</b></li>";
184
+ $status .= "<li>Google GET: ";
185
+ $r = wp_remote_get( 'http://google.com' );
186
+ $status .= is_wp_error( $r ) ? print_r( $r, true ) : 'OK';
187
+ $status .= "</li><li>MeowApps GET: ";
188
+ $r = wp_remote_get( 'http://google.com' );
189
+ $status .= is_wp_error( $r ) ? print_r( $r, true ) : 'OK';
190
+ $status .= "</li><li>MeowApps POST: ";
191
+ $status .= print_r( $response, true );
192
+ $status .= "</li></ul>";
193
+ error_log( print_r( $response, true ) );
194
+ update_option( $prefix . '_pro_status', $status );
195
+ return false;
196
+ }
197
+ if ( !$post->success ) {
198
+ if ( $post->message_code == "NO_SUBSCRIPTION" )
199
+ $status = __( "Your serial ('$subscr_id') does not seem right." );
200
+ else if ( $post->message_code == "NOT_ACTIVE" )
201
+ $status = __( "Your subscription is not active." );
202
+ else if ( $post->message_code == "TOO_MANY_URLS" )
203
+ $status = __( "Too many URLs are linked to your subscription." );
204
+ else
205
+ $status = "There is a problem with your subscription.";
206
+ update_option( $prefix . '_pro_status', $status );
207
+ return false;
208
+ }
209
+ set_transient( $prefix . '_validated', $subscr_id, 3600 * 24 * 100 );
210
+ update_option( $prefix . '_pro_serial', $subscr_id );
211
+ update_option( $prefix . '_pro_status', '' );
212
+ return true;
213
+ }
214
+
215
+ function check_install( $plugin ) {
216
+ $pluginpath = get_home_path() . 'wp-content/plugins/' . $plugin;
217
+ if ( !file_exists( $pluginpath ) ) {
218
+ $url = wp_nonce_url( "update.php?action=install-plugin&plugin=$plugin", "install-plugin_$plugin" );
219
+ return "<a href='$url'><small><span class='' style='float: right;'>install</span></small></a>";
220
+ }
221
+ $plugin_file = $plugin . '/' . $plugin . '.php';
222
+ if ( is_plugin_active( $plugin_file ) )
223
+ return "<small><span style='float: right; color: green;'><span class='dashicons dashicons-yes'></span></span></small>";
224
+ else {
225
+ $url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=' . $plugin_file ),
226
+ 'activate-plugin_' . $plugin_file );
227
+ return '<small><span style="color: orange; float: right;">off
228
+ (<a style="color: rgba(30,140,190,.8); text-decoration: none;" href="' .
229
+ $url . '">enable</a>)</span></small>';
230
+ }
231
+ }
232
+
233
+ function common_url( $file ) {
234
+ die( "Meow Apps: The function common_url( \$file ) needs to be overriden." );
235
+ // Normally, this should be used:
236
+ // return plugin_dir_url( __FILE__ ) . ( '\/common\/' . $file );
237
+ }
238
+
239
+ function meowapps_logo_url() {
240
+ return $this->common_url( 'img/meowapps.png' );
241
+ }
242
+
243
+ function plugins_loaded() {
244
+ if ( isset( $_GET[ 'tool' ] ) && $_GET[ 'tool' ] == 'error_log' ) {
245
+ $sec = "5";
246
+ header("Refresh: $sec;");
247
+ }
248
+ }
249
+
250
+ function admin_meow_apps() {
251
+
252
+ echo '<div class="wrap meow-dashboard">';
253
+ if ( isset( $_GET['tool'] ) && $_GET['tool'] == 'phpinfo' ) {
254
+ echo "<a href=\"javascript:history.go(-1)\">< Go back</a><br /><br />";
255
+ echo '<div id="phpinfo">';
256
+ ob_start();
257
+ phpinfo();
258
+ $pinfo = ob_get_contents();
259
+ ob_end_clean();
260
+ $pinfo = preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', $pinfo );
261
+ echo $pinfo;
262
+ echo "</div>";
263
+ }
264
+ else if ( isset( $_GET['tool'] ) && $_GET['tool'] == 'error_log' ) {
265
+ $errorpath = ini_get( 'error_log' );
266
+ echo "<a href=\"javascript:history.go(-1)\">< Go back</a><br /><br />";
267
+ echo '<div id="error_log">';
268
+ if ( file_exists( $errorpath ) ) {
269
+ echo "Now (auto-reload every 5 seconds):<br />[" . date( "d-M-Y H:i:s", time() ) . " UTC]<br /<br /><br />Errors (order by latest):";
270
+ $errors = file_get_contents( $errorpath );
271
+ $errors = explode( "\n", $errors );
272
+ $errors = array_reverse( $errors );
273
+ $errors = implode( "<br />", $errors );
274
+ echo $errors;
275
+ }
276
+ else {
277
+ echo "The PHP Error Logs cannot be found. Please ask your hosting service for it.";
278
+ }
279
+ echo "</div>";
280
+
281
+ }
282
+ else {
283
+
284
+ ?>
285
+ <?php $this->display_title(); ?>
286
+ <p>
287
+ <?php _e( 'Meow Apps is run by <a href="http://jordymeow.com">Jordy Meow</a>, a photographer and software developer based in Japan. When he realized that WordPress was an environment not so friendly to photographers, Meow Apps was born. It is a suite of plugins dedicate to make the blogging life of image lovers easy and pretty. Meow Apps also teams up with the best players in the community (other themes or plugins developers). For more information, please check <a href="http://meowapps.com" target="_blank">Meow Apps</a>.', $this->domain )
288
+ ?>
289
+ </p>
290
+ <div class="meow-row">
291
+ <div class="meow-box meow-col meow-span_1_of_2 ">
292
+ <h3 class=""><span class="dashicons dashicons-camera"></span> UI Plugins </h3>
293
+ <ul class="">
294
+ <li><b>WP/LR Sync</b> <?php echo $this->check_install( 'wplr-sync' ) ?><br />
295
+ <?php _e( 'Bring synchronization from Lightroom to WordPress.', $this->domain ); ?>
296
+ </li>
297
+ <li><b>Meow Lightbox</b> <?php echo $this->check_install( 'meow-lightbox' ) ?><br />
298
+ <?php _e( 'Lightbox with EXIF information nicely displayed.', $this->domain ); ?>
299
+ </li>
300
+ <li><b>Meow Gallery</b> <?php echo $this->check_install( 'meow-gallery' ) ?><br />
301
+ <?php _e( 'Simple gallery to make your photos look better (Masonry and others).', $this->domain ); ?>
302
+ </li>
303
+ <li><b>Audio Story for Images</b> <?php echo $this->check_install( 'audio-story-images' ) ?><br />
304
+ <?php _e( 'Add audio to your images.', $this->domain ); ?>
305
+ </li>
306
+ </ul>
307
+ </div>
308
+ <div class="meow-box meow-col meow-span_1_of_2">
309
+ <h3 class=""><span class="dashicons dashicons-admin-tools"></span> System Plugins</h3>
310
+ <ul class="">
311
+ <li><b>Media File Renamer</b> <?php echo $this->check_install( 'media-file-renamer' ) ?><br />
312
+ <?php _e( 'Nicer filenames and better SEO, automatically.', $this->domain ); ?>
313
+ </li>
314
+ <li><b>Media Cleaner</b> <?php echo $this->check_install( 'media-cleaner' ) ?><br />
315
+ <?php _e( 'Detect the files you are not using to clean your system.', $this->domain ); ?>
316
+ </li>
317
+ <li><b>WP Retina 2x</b> <?php echo $this->check_install( 'wp-retina-2x' ) ?><br />
318
+ <?php _e( 'Make your website perfect for retina devices.', $this->domain ); ?>
319
+ </li>
320
+ <li><b>WP Category Permalink</b> <?php echo $this->check_install( 'wp-category-permalink' ) ?><br />
321
+ <?php _e( 'Allows you to select a main category (or taxonomy) for nicer permalinks.', $this->domain ); ?>
322
+ </li>
323
+ </ul>
324
+ </div>
325
+ </div>
326
+
327
+ <div class="meow-row">
328
+ <div class="meow-box meow-col meow-span_2_of_3">
329
+ <h3><span class="dashicons dashicons-admin-tools"></span> Common</h3>
330
+ <div class="inside">
331
+ <form method="post" action="options.php">
332
+ <?php settings_fields( 'meowapps_common_settings' ); ?>
333
+ <?php do_settings_sections( 'meowapps_common_settings-menu' ); ?>
334
+ <?php submit_button(); ?>
335
+ </form>
336
+ </div>
337
+ </div>
338
+
339
+ <div class="meow-box meow-col meow-span_1_of_3">
340
+ <h3><span class="dashicons dashicons-admin-tools"></span> Debug</h3>
341
+ <div class="inside">
342
+ <ul>
343
+ <li><a href="?page=meowapps-main-menu&amp;tool=error_log">
344
+ <?php _e( 'Display Error Log', $this->domain ); ?>
345
+ </a></li>
346
+ <li><a href="?page=meowapps-main-menu&amp;tool=phpinfo">
347
+ <?php _e( 'Display PHP Info', $this->domain ); ?>
348
+ </a></li>
349
+ </ul>
350
+ </div>
351
+ </div>
352
+ </div>
353
+
354
+ <?php
355
+
356
+ }
357
+
358
+ echo "<br /><small style='color: lightgray;'>Meow Admin " . Meow_Admin::$version . "</small></div>";
359
+ }
360
+
361
+ // HELPERS
362
+
363
+ static function size_shortname( $name ) {
364
+ $name = preg_split( '[_-]', $name );
365
+ $short = strtoupper( substr( $name[0], 0, 1 ) );
366
+ if ( count( $name ) > 1 )
367
+ $short .= strtoupper( substr( $name[1], 0, 1 ) );
368
+ return $short;
369
+ }
370
+
371
+ }
372
+
373
+ }
374
+
375
+ ?>
img/burn.png ADDED
Binary file
img/clock.png ADDED
Binary file
img/cross-small.png ADDED
Binary file
img/exclamation.png ADDED
Binary file
img/loading.gif ADDED
Binary file
img/photo-album--plus.png ADDED
Binary file
img/prohibition-small.png ADDED
Binary file
img/refresh.png ADDED
Binary file
img/replace.png ADDED
Binary file
img/tick-circle.png ADDED
Binary file
img/wpengine.png ADDED
Binary file
inc/Mobile_Detect.php ADDED
@@ -0,0 +1,1231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Mobile Detect Library
4
+ * =====================
5
+ *
6
+ * Motto: "Every business should have a mobile detection script to detect mobile readers"
7
+ *
8
+ * Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets).
9
+ * It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
10
+ *
11
+ * @author Current authors: Serban Ghita <serbanghita@gmail.com>, Nick Ilyin <nick.ilyin@gmail.com>
12
+ * Original author: Victor Stanciu <vic.stanciu@gmail.com>
13
+ *
14
+ * @license Code and contributions have 'MIT License'
15
+ * More details: https://github.com/serbanghita/Mobile-Detect/blob/master/LICENSE.txt
16
+ *
17
+ * @link Homepage: http://mobiledetect.net
18
+ * GitHub Repo: https://github.com/serbanghita/Mobile-Detect
19
+ * Google Code: http://code.google.com/p/php-mobile-detect/
20
+ * README: https://github.com/serbanghita/Mobile-Detect/blob/master/README.md
21
+ * HOWTO: https://github.com/serbanghita/Mobile-Detect/wiki/Code-examples
22
+ *
23
+ * @version 2.8.0
24
+ */
25
+
26
+ class Mobile_Detect
27
+ {
28
+ /**
29
+ * Mobile detection type.
30
+ *
31
+ * @deprecated since version 2.6.9
32
+ */
33
+ const DETECTION_TYPE_MOBILE = 'mobile';
34
+
35
+ /**
36
+ * Extended detection type.
37
+ *
38
+ * @deprecated since version 2.6.9
39
+ */
40
+ const DETECTION_TYPE_EXTENDED = 'extended';
41
+
42
+ /**
43
+ * A frequently used regular expression to extract version #s.
44
+ *
45
+ * @deprecated since version 2.6.9
46
+ */
47
+ const VER = '([\w._\+]+)';
48
+
49
+ /**
50
+ * Top-level device.
51
+ */
52
+ const MOBILE_GRADE_A = 'A';
53
+
54
+ /**
55
+ * Mid-level device.
56
+ */
57
+ const MOBILE_GRADE_B = 'B';
58
+
59
+ /**
60
+ * Low-level device.
61
+ */
62
+ const MOBILE_GRADE_C = 'C';
63
+
64
+ /**
65
+ * Stores the version number of the current release.
66
+ */
67
+ const VERSION = '2.8.0';
68
+
69
+ /**
70
+ * A type for the version() method indicating a string return value.
71
+ */
72
+ const VERSION_TYPE_STRING = 'text';
73
+
74
+ /**
75
+ * A type for the version() method indicating a float return value.
76
+ */
77
+ const VERSION_TYPE_FLOAT = 'float';
78
+
79
+ /**
80
+ * The User-Agent HTTP header is stored in here.
81
+ * @var string
82
+ */
83
+ protected $userAgent = null;
84
+
85
+ /**
86
+ * HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE.
87
+ * @var array
88
+ */
89
+ protected $httpHeaders = array();
90
+
91
+ /**
92
+ * The detection type, using self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED.
93
+ *
94
+ * @deprecated since version 2.6.9
95
+ *
96
+ * @var string
97
+ */
98
+ protected $detectionType = self::DETECTION_TYPE_MOBILE;
99
+
100
+ /**
101
+ * HTTP headers that trigger the 'isMobile' detection
102
+ * to be true.
103
+ *
104
+ * @var array
105
+ */
106
+ protected static $mobileHeaders = array(
107
+
108
+ 'HTTP_ACCEPT' => array('matches' => array(
109
+ // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/
110
+ 'application/x-obml2d',
111
+ // BlackBerry devices.
112
+ 'application/vnd.rim.html',
113
+ 'text/vnd.wap.wml',
114
+ 'application/vnd.wap.xhtml+xml'
115
+ )),
116
+ 'HTTP_X_WAP_PROFILE' => null,
117
+ 'HTTP_X_WAP_CLIENTID' => null,
118
+ 'HTTP_WAP_CONNECTION' => null,
119
+ 'HTTP_PROFILE' => null,
120
+ // Reported by Opera on Nokia devices (eg. C3).
121
+ 'HTTP_X_OPERAMINI_PHONE_UA' => null,
122
+ 'HTTP_X_NOKIA_IPADDRESS' => null,
123
+ 'HTTP_X_NOKIA_GATEWAY_ID' => null,
124
+ 'HTTP_X_ORANGE_ID' => null,
125
+ 'HTTP_X_VODAFONE_3GPDPCONTEXT' => null,
126
+ 'HTTP_X_HUAWEI_USERID' => null,
127
+ // Reported by Windows Smartphones.
128
+ 'HTTP_UA_OS' => null,
129
+ // Reported by Verizon, Vodafone proxy system.
130
+ 'HTTP_X_MOBILE_GATEWAY' => null,
131
+ // Seend this on HTC Sensation. @ref: SensationXE_Beats_Z715e.
132
+ 'HTTP_X_ATT_DEVICEID' => null,
133
+ // Seen this on a HTC.
134
+ 'HTTP_UA_CPU' => array('matches' => array('ARM')),
135
+ );
136
+
137
+ /**
138
+ * List of mobile devices (phones).
139
+ *
140
+ * @var array
141
+ */
142
+ protected static $phoneDevices = array(
143
+ 'iPhone' => '\biPhone.*Mobile|\biPod', // |\biTunes
144
+ 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+',
145
+ 'HTC' => 'HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\bEVO\b|T-Mobile G1|Z520m',
146
+ 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile',
147
+ // @todo: Is 'Dell Streak' a tablet or a phone? ;)
148
+ 'Dell' => 'Dell.*Streak|Dell.*Aero|Dell.*Venue|DELL.*Venue Pro|Dell Flash|Dell Smoke|Dell Mini 3iX|XCD28|XCD35|\b001DL\b|\b101DL\b|\bGS01\b',
149
+ 'Motorola' => 'Motorola|DROIDX|DROID BIONIC|\bDroid\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925',
150
+ 'Samsung' => 'Samsung|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E',
151
+ 'LG' => '\bLG\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802)',
152
+ 'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i',
153
+ 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile',
154
+ // @ref: http://www.micromaxinfo.com/mobiles/smartphones
155
+ // Added because the codes might conflict with Acer Tablets.
156
+ 'Micromax' => 'Micromax.*\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\b',
157
+ 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ; @todo - complete the regex.
158
+ 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;)
159
+ // @ref: http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH)
160
+ // Most of the VEGA devices are legacy. PANTECH seem to be newer devices based on Android.
161
+ 'Pantech' => 'PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790',
162
+ // @ref: http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones.
163
+ 'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
164
+ 'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)',
165
+ // Added simvalley mobile just for fun. They have some interesting devices.
166
+ // @ref: http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html
167
+ 'SimValley' => '\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\b',
168
+ // @Tapatalk is a mobile app; @ref: http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039
169
+ 'GenericPhone' => 'Tapatalk|PDA;|SAGEM|\bmmp\b|pocket|\bpsp\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\bwap\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser'
170
+ );
171
+
172
+ /**
173
+ * List of tablet devices.
174
+ *
175
+ * @var array
176
+ */
177
+ protected static $tabletDevices = array(
178
+ 'iPad' => 'iPad|iPad.*Mobile', // @todo: check for mobile friendly emails topic.
179
+ 'NexusTablet' => '^.*Android.*Nexus(((?:(?!Mobile))|(?:(\s(7|10).+))).)*$',
180
+ 'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-I9205|GT-P5200|GT-P5210|SM-T311|SM-T310|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T520|SM-T525',
181
+ // @reference: http://www.labnol.org/software/kindle-user-agent-string/20378/
182
+ 'Kindle' => 'Kindle|Silk.*Accelerated|Android.*\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE)\b',
183
+ // Only the Surface tablets with Windows RT are considered mobile.
184
+ // @ref: http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
185
+ 'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;',
186
+ // @ref: http://shopping1.hp.com/is-bin/INTERSHOP.enfinity/WFS/WW-USSMBPublicStore-Site/en_US/-/USD/ViewStandardCatalog-Browse?CatalogCategoryID=JfIQ7EN5lqMAAAEyDcJUDwMT
187
+ 'HPTablet' => 'HP Slate 7|HP ElitePad 900|hp-tablet|EliteBook.*Touch',
188
+ // @note: watch out for PadFone, see #132
189
+ 'AsusTablet' => '^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\bK00F\b|TX201LA',
190
+ 'BlackBerryTablet' => 'PlayBook|RIM Tablet',
191
+ 'HTCtablet' => 'HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200',
192
+ 'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
193
+ 'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2',
194
+ // @ref: http://www.acer.ro/ac/ro/RO/content/drivers
195
+ // @ref: http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell is part of Acer)
196
+ // @ref: http://us.acer.com/ac/en/US/content/group/tablets
197
+ // @note: Can conflict with Micromax and Motorola phones codes.
198
+ 'AcerTablet' => 'Android.*; \b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810)\b|W3-810|\bA3-A10\b',
199
+ // @ref: http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/
200
+ // @ref: http://us.toshiba.com/tablets/tablet-finder
201
+ // @ref: http://www.toshiba.co.jp/regza/tablet/
202
+ 'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO',
203
+ // @ref: http://www.nttdocomo.co.jp/english/service/developer/smart_phone/technical_info/spec/index.html
204
+ 'LGTablet' => '\bL-06C|LG-V900|LG-V500|LG-V909\b',
205
+ 'FujitsuTablet' => 'Android.*\b(F-01D|F-05E|F-10D|M532|Q572)\b',
206
+ // Prestigio Tablets http://www.prestigio.com/support
207
+ 'PrestigioTablet' => 'PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD',
208
+ // @ref: http://support.lenovo.com/en_GB/downloads/default.page?#
209
+ 'LenovoTablet' => 'IdeaTab|S2110|S6000|K3011|A3000|A1000|A2107|A2109|A1107|ThinkPad([ ]+)?Tablet',
210
+ // @ref: http://www.yarvik.com/en/matrix/tablets/
211
+ 'YarvikTablet' => 'Android.*\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\b',
212
+ 'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
213
+ 'ArnovaTablet' => 'AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT',
214
+ // http://www.intenso.de/kategorie_en.php?kategorie=33
215
+ // @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html - investigate
216
+ 'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab',
217
+ // IRU.ru Tablets http://www.iru.ru/catalog/soho/planetable/
218
+ 'IRUTablet' => 'M702pro',
219
+ 'MegafonTablet' => 'MegaFon V9|\bZTE V9\b|Android.*\bMT7A\b',
220
+ // @ref: http://www.e-boda.ro/tablete-pc.html
221
+ 'EbodaTablet' => 'E-Boda (Supreme|Impresspeed|Izzycomm|Essential)',
222
+ // @ref: http://www.allview.ro/produse/droseries/lista-tablete-pc/
223
+ 'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)',
224
+ // @reference: http://wiki.archosfans.com/index.php?title=Main_Page
225
+ 'ArchosTablet' => '\b(101G9|80G9|A101IT)\b|Qilive 97R|ARCHOS 101G10',
226
+ // @ref: http://www.ainol.com/plugin.php?identifier=ainol&module=product
227
+ 'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark',
228
+ // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER
229
+ // @ref: Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser
230
+ // @ref: http://www.sony.jp/support/tablet/
231
+ 'SonyTablet' => 'Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201',
232
+ // @ref: db + http://www.cube-tablet.com/buy-products.html
233
+ 'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT',
234
+ // @ref: http://www.cobyusa.com/?p=pcat&pcat_id=3001
235
+ 'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
236
+ // @ref: http://www.match.net.cn/products.asp
237
+ 'MIDTablet' => 'M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733',
238
+ // @ref: http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese Tablets)
239
+ // @ref: http://www.imp3.net/14/show.php?itemid=20454
240
+ 'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)',
241
+ // @ref: http://www.rock-chips.com/index.php?do=prod&pid=2
242
+ 'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A',
243
+ // @ref: http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/
244
+ 'FlyTablet' => 'IQ310|Fly Vision',
245
+ // @ref: http://www.bqreaders.com/gb/tablets-prices-sale.html
246
+ 'bqTablet' => 'bq.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant)|Maxwell.*Lite|Maxwell.*Plus',
247
+ // @ref: http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290
248
+ // @ref: http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets)
249
+ 'HuaweiTablet' => 'MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim',
250
+ // Nec or Medias Tab
251
+ 'NecTablet' => '\bN-06D|\bN-08D',
252
+ // Pantech Tablets: http://www.pantechusa.com/phones/
253
+ 'PantechTablet' => 'Pantech.*P4100',
254
+ // Broncho Tablets: http://www.broncho.cn/ (hard to find)
255
+ 'BronchoTablet' => 'Broncho.*(N701|N708|N802|a710)',
256
+ // @ref: http://versusuk.com/support.html
257
+ 'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b',
258
+ // @ref: http://www.zync.in/index.php/our-products/tablet-phablets
259
+ 'ZyncTablet' => 'z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900',
260
+ // @ref: http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/
261
+ 'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA',
262
+ // @ref: https://www.nabitablet.com/
263
+ 'NabiTablet' => 'Android.*\bNabi',
264
+ 'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b Build|\bArc\b Build',
265
+ // French Danew Tablets http://www.danew.com/produits-tablette.php
266
+ 'DanewTablet' => 'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b',
267
+ // Texet Tablets and Readers http://www.texet.ru/tablet/
268
+ 'TexetTablet' => 'NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE',
269
+ // @note: Avoid detecting 'PLAYSTATION 3' as mobile.
270
+ 'PlaystationTablet' => 'Playstation.*(Portable|Vita)',
271
+ // @ref: http://www.trekstor.de/surftabs.html
272
+ 'TrekstorTablet' => 'ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2',
273
+ // @ref: http://www.pyleaudio.com/Products.aspx?%2fproducts%2fPersonal-Electronics%2fTablets
274
+ 'PyleAudioTablet' => '\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\b',
275
+ // @ref: http://www.advandigital.com/index.php?link=content-product&jns=JP001
276
+ // @Note: because of the short codenames we have to include whitespaces to reduce the possible conflicts.
277
+ 'AdvanTablet' => 'Android.* \b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\b ',
278
+ // @ref: http://www.danytech.com/category/tablet-pc
279
+ 'DanyTechTablet' => 'Genius Tab G3|Genius Tab S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|Genius TAB GII|Genius TAB GIII|Genius Tab S1',
280
+ // @ref: http://www.galapad.net/product.html
281
+ 'GalapadTablet' => 'Android.*\bG1\b',
282
+ // @ref: http://www.micromaxinfo.com/tablet/funbook
283
+ 'MicromaxTablet' => 'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b',
284
+ // http://www.karbonnmobiles.com/products_tablet.php
285
+ 'KarbonnTablet' => 'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b',
286
+ // @ref: http://www.myallfine.com/Products.asp
287
+ 'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide',
288
+ // @ref: http://www.proscanvideo.com/products-search.asp?itemClass=TABLET&itemnmbr=
289
+ 'PROSCANTablet' => '\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\b',
290
+ // @ref: http://www.yonesnav.com/products/products.php
291
+ 'YONESTablet' => 'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026',
292
+ // @ref: http://www.cjshowroom.com/eproducts.aspx?classcode=004001001
293
+ // China manufacturer makes tablets for different small brands (eg. http://www.zeepad.net/index.html)
294
+ 'ChangJiaTablet' => 'TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503',
295
+ // @ref: http://www.gloryunion.cn/products.asp
296
+ // @ref: http://www.allwinnertech.com/en/apply/mobile.html
297
+ // @ref: http://www.ptcl.com.pk/pd_content.php?pd_id=284 (EVOTAB)
298
+ // @todo: Softwiner tablets?
299
+ // aka. Cute or Cool tablets. Not sure yet, must research to avoid collisions.
300
+ 'GUTablet' => 'TX-A1301|TX-M9002|Q702|kf026', // A12R|D75A|D77|D79|R83|A95|A106C|R15|A75|A76|D71|D72|R71|R73|R77|D82|R85|D92|A97|D92|R91|A10F|A77F|W71F|A78F|W78F|W81F|A97F|W91F|W97F|R16G|C72|C73E|K72|K73|R96G
301
+ // @ref: http://www.pointofview-online.com/showroom.php?shop_mode=product_listing&category_id=118
302
+ 'PointOfViewTablet' => 'TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10',
303
+ // @ref: http://www.overmax.pl/pl/katalog-produktow,p8/tablety,c14/
304
+ // @todo: add more tests.
305
+ 'OvermaxTablet' => 'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)',
306
+ // @ref: http://hclmetablet.com/India/index.php
307
+ 'HCLTablet' => 'HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync',
308
+ // @ref: http://www.edigital.hu/Tablet_es_e-book_olvaso/Tablet-c18385.html
309
+ 'DPSTablet' => 'DPS Dream 9|DPS Dual 7',
310
+ // @ref: http://www.visture.com/index.asp
311
+ 'VistureTablet' => 'V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10',
312
+ // @ref: http://www.mijncresta.nl/tablet
313
+ 'CrestaTablet' => 'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989',
314
+ // MediaTek - http://www.mediatek.com/_en/01_products/02_proSys.php?cata_sn=1&cata1_sn=1&cata2_sn=309
315
+ 'MediatekTablet' => '\bMT8125|MT8389|MT8135|MT8377\b',
316
+ // Concorde tab
317
+ 'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde ReadMan',
318
+ // GoClever Tablets - http://www.goclever.com/uk/products,c1/tablet,c5/
319
+ 'GoCleverTablet' => 'GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042',
320
+ // Modecom Tablets - http://www.modecom.eu/tablets/portal/
321
+ 'ModecomTablet' => 'FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003',
322
+ // Vonino Tablets - http://www.vonino.eu/tablets
323
+ 'VoninoTablet' => '\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\bQ8\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\b',
324
+ // ECS Tablets - http://www.ecs.com.tw/ECSWebSite/Product/Product_Tablet_List.aspx?CategoryID=14&MenuID=107&childid=M_107&LanID=0
325
+ 'ECSTablet' => 'V07OT2|TM105A|S10OT1|TR10CS1',
326
+ // Storex Tablets - http://storex.fr/espace_client/support.html
327
+ // @note: no need to add all the tablet codes since they are guided by the first regex.
328
+ 'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab',
329
+ // Generic Vodafone tablets.
330
+ 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10',
331
+ // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb
332
+ // Aka: http://www.essentielb.fr/
333
+ 'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2',
334
+ // Ross & Moor - http://ross-moor.ru/
335
+ 'RossMoorTablet' => 'RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711',
336
+ // i-mobile http://product.i-mobilephone.com/Mobile_Device
337
+ 'iMobileTablet' => 'i-mobile i-note',
338
+ // @ref: http://www.tolino.de/de/vergleichen/
339
+ 'TolinoTablet' => 'tolino tab [0-9.]+|tolino shine',
340
+ // AudioSonic - a Kmart brand
341
+ // http://www.kmart.com.au/webapp/wcs/stores/servlet/Search?langId=-1&storeId=10701&catalogId=10001&categoryId=193001&pageSize=72&currentPage=1&searchCategory=193001%2b4294965664&sortBy=p_MaxPrice%7c1
342
+ 'AudioSonicTablet' => '\bC-22Q|T7-QC|T-17B|T-17P\b',
343
+ // AMPE Tablets - http://www.ampe.com.my/product-category/tablets/
344
+ // @todo: add them gradually to avoid conflicts.
345
+ 'AMPETablet' => 'Android.* A78 ',
346
+ // Skk Mobile - http://skkmobile.com.ph/product_tablets.php
347
+ 'SkkTablet' => 'Android.* (SKYPAD|PHOENIX|CYCLOPS)',
348
+ // Tecno Mobile (only tablet) - http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1
349
+ 'TecnoTablet' => 'TECNO P9',
350
+ // JXD (consoles & tablets) - http://jxd.hk/products.asp?selectclassid=009008&clsid=3
351
+ 'JXDTablet' => 'Android.*\b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\b',
352
+ // i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/
353
+ 'iJoyTablet' => 'Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)',
354
+ // @ref: http://www.tesco.com/direct/hudl/
355
+ 'Hudl' => 'Hudl HT7S3',
356
+ // @ref: http://www.telstra.com.au/home-phone/thub-2/
357
+ 'TelstraTablet' => 'T-Hub2',
358
+ 'GenericTablet' => 'Android.*\b97D\b|Tablet(?!.*PC)|ViewPad7|BNTV250A|MID-WCDMA|LogicPD Zoom2|\bA7EB\b|CatNova8|A1_07|CT704|CT1002|\bM721\b|rk30sdk|\bEVOTAB\b|M758A|ET904|ALUMIUM10|Smartfren Tab',
359
+ );
360
+
361
+ /**
362
+ * List of mobile Operating Systems.
363
+ *
364
+ * @var array
365
+ */
366
+ protected static $operatingSystems = array(
367
+ 'AndroidOS' => 'Android',
368
+ 'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os',
369
+ 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
370
+ 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b',
371
+ // @reference: http://en.wikipedia.org/wiki/Windows_Mobile
372
+ 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;',
373
+ // @reference: http://en.wikipedia.org/wiki/Windows_Phone
374
+ // http://wifeng.cn/?r=blog&a=view&id=106
375
+ // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx
376
+ 'WindowsPhoneOS' => 'Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7',
377
+ 'iOS' => '\biPhone.*Mobile|\biPod|\biPad',
378
+ // http://en.wikipedia.org/wiki/MeeGo
379
+ // @todo: research MeeGo in UAs
380
+ 'MeeGoOS' => 'MeeGo',
381
+ // http://en.wikipedia.org/wiki/Maemo
382
+ // @todo: research Maemo in UAs
383
+ 'MaemoOS' => 'Maemo',
384
+ 'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b', // '|Java/' produces bug #135
385
+ 'webOS' => 'webOS|hpwOS',
386
+ 'badaOS' => '\bBada\b',
387
+ 'BREWOS' => 'BREW',
388
+ );
389
+
390
+ /**
391
+ * List of mobile User Agents.
392
+ *
393
+ * @var array
394
+ */
395
+ protected static $browsers = array(
396
+ // @reference: https://developers.google.com/chrome/mobile/docs/user-agent
397
+ 'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
398
+ 'Dolfin' => '\bDolfin\b',
399
+ 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+',
400
+ 'Skyfire' => 'Skyfire',
401
+ 'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+
402
+ 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile',
403
+ 'Bolt' => 'bolt',
404
+ 'TeaShark' => 'teashark',
405
+ 'Blazer' => 'Blazer',
406
+ // @reference: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3
407
+ 'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile',
408
+ // @ref: http://en.wikipedia.org/wiki/Midori_(web_browser)
409
+ //'Midori' => 'midori',
410
+ 'Tizen' => 'Tizen',
411
+ 'UCBrowser' => 'UC.*Browser|UCWEB',
412
+ // @ref: https://github.com/serbanghita/Mobile-Detect/issues/7
413
+ 'DiigoBrowser' => 'DiigoBrowser',
414
+ // http://www.puffinbrowser.com/index.php
415
+ 'Puffin' => 'Puffin',
416
+ // @ref: http://mercury-browser.com/index.html
417
+ 'Mercury' => '\bMercury\b',
418
+ // @reference: http://en.wikipedia.org/wiki/Minimo
419
+ // http://en.wikipedia.org/wiki/Vision_Mobile_Browser
420
+ 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger'
421
+ );
422
+
423
+ /**
424
+ * Utilities.
425
+ *
426
+ * @var array
427
+ */
428
+ protected static $utilities = array(
429
+ // Experimental. When a mobile device wants to switch to 'Desktop Mode'.
430
+ // @ref: http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
431
+ // @ref: https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
432
+ 'DesktopMode' => 'WPDesktop',
433
+ 'TV' => 'SonyDTV|HbbTV', // experimental
434
+ 'WebKit' => '(webkit)[ /]([\w.]+)',
435
+ 'Bot' => 'Googlebot|DoCoMo|YandexBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|facebookexternalhit',
436
+ 'MobileBot' => 'Googlebot-Mobile|DoCoMo|YahooSeeker/M1A1-R2D2',
437
+ // @todo: Include JXD consoles.
438
+ 'Console' => '\b(Nintendo|Nintendo WiiU|PLAYSTATION|Xbox)\b',
439
+ 'Watch' => 'SM-V700',
440
+ );
441
+
442
+ /**
443
+ * All possible HTTP headers that represent the
444
+ * User-Agent string.
445
+ *
446
+ * @var array
447
+ */
448
+ protected static $uaHttpHeaders = array(
449
+ // The default User-Agent string.
450
+ 'HTTP_USER_AGENT',
451
+ // Header can occur on devices using Opera Mini.
452
+ 'HTTP_X_OPERAMINI_PHONE_UA',
453
+ // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
454
+ 'HTTP_X_DEVICE_USER_AGENT',
455
+ 'HTTP_X_ORIGINAL_USER_AGENT',
456
+ 'HTTP_X_SKYFIRE_PHONE',
457
+ 'HTTP_X_BOLT_PHONE_UA',
458
+ 'HTTP_DEVICE_STOCK_UA',
459
+ 'HTTP_X_UCBROWSER_DEVICE_UA'
460
+ );
461
+
462
+ /**
463
+ * The individual segments that could exist in a User-Agent string. VER refers to the regular
464
+ * expression defined in the constant self::VER.
465
+ *
466
+ * @var array
467
+ */
468
+ protected static $properties = array(
469
+
470
+ // Build
471
+ 'Mobile' => 'Mobile/[VER]',
472
+ 'Build' => 'Build/[VER]',
473
+ 'Version' => 'Version/[VER]',
474
+ 'VendorID' => 'VendorID/[VER]',
475
+
476
+ // Devices
477
+ 'iPad' => 'iPad.*CPU[a-z ]+[VER]',
478
+ 'iPhone' => 'iPhone.*CPU[a-z ]+[VER]',
479
+ 'iPod' => 'iPod.*CPU[a-z ]+[VER]',
480
+ //'BlackBerry' => array('BlackBerry[VER]', 'BlackBerry [VER];'),
481
+ 'Kindle' => 'Kindle/[VER]',
482
+
483
+ // Browser
484
+ 'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'),
485
+ 'Coast' => array('Coast/[VER]'),
486
+ 'Dolfin' => 'Dolfin/[VER]',
487
+ // @reference: https://developer.mozilla.org/en-US/docs/User_Agent_Strings_Reference
488
+ 'Firefox' => 'Firefox/[VER]',
489
+ 'Fennec' => 'Fennec/[VER]',
490
+ // @reference: http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
491
+ 'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];'),
492
+ // http://en.wikipedia.org/wiki/NetFront
493
+ 'NetFront' => 'NetFront/[VER]',
494
+ 'NokiaBrowser' => 'NokiaBrowser/[VER]',
495
+ 'Opera' => array( ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ),
496
+ 'Opera Mini' => 'Opera Mini/[VER]',
497
+ 'Opera Mobi' => 'Version/[VER]',
498
+ 'UC Browser' => 'UC Browser[VER]',
499
+ 'MQQBrowser' => 'MQQBrowser/[VER]',
500
+ 'MicroMessenger' => 'MicroMessenger/[VER]',
501
+ // @note: Safari 7534.48.3 is actually Version 5.1.
502
+ // @note: On BlackBerry the Version is overwriten by the OS.
503
+ 'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ),
504
+ 'Skyfire' => 'Skyfire/[VER]',
505
+ 'Tizen' => 'Tizen/[VER]',
506
+ 'Webkit' => 'webkit[ /][VER]',
507
+
508
+ // Engine
509
+ 'Gecko' => 'Gecko/[VER]',
510
+ 'Trident' => 'Trident/[VER]',
511
+ 'Presto' => 'Presto/[VER]',
512
+
513
+ // OS
514
+ 'iOS' => ' \bOS\b [VER] ',
515
+ 'Android' => 'Android [VER]',
516
+ 'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'),
517
+ 'BREW' => 'BREW [VER]',
518
+ 'Java' => 'Java/[VER]',
519
+ // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx
520
+ // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases
521
+ 'Windows Phone OS' => array( 'Windows Phone OS [VER]', 'Windows Phone [VER]'),
522
+ 'Windows Phone' => 'Windows Phone [VER]',
523
+ 'Windows CE' => 'Windows CE/[VER]',
524
+ // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd
525
+ 'Windows NT' => 'Windows NT [VER]',
526
+ 'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'),
527
+ 'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'),
528
+ );
529
+
530
+ /**
531
+ * Construct an instance of this class.
532
+ *
533
+ * @param array $headers Specify the headers as injection. Should be PHP _SERVER flavored.
534
+ * If left empty, will use the global _SERVER['HTTP_*'] vars instead.
535
+ * @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT
536
+ * from the $headers array instead.
537
+ */
538
+ public function __construct(
539
+ array $headers = null,
540
+ $userAgent = null
541
+ ){
542
+ $this->setHttpHeaders($headers);
543
+ $this->setUserAgent($userAgent);
544
+ }
545
+
546
+ /**
547
+ * Get the current script version.
548
+ * This is useful for the demo.php file,
549
+ * so people can check on what version they are testing
550
+ * for mobile devices.
551
+ *
552
+ * @return string The version number in semantic version format.
553
+ */
554
+ public static function getScriptVersion()
555
+ {
556
+ return self::VERSION;
557
+ }
558
+
559
+ /**
560
+ * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
561
+ *
562
+ * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
563
+ * the headers. The default null is left for backwards compatibilty.
564
+ */
565
+ public function setHttpHeaders($httpHeaders = null)
566
+ {
567
+ //use global _SERVER if $httpHeaders aren't defined
568
+ if (!is_array($httpHeaders) || !count($httpHeaders)) {
569
+ $httpHeaders = $_SERVER;
570
+ }
571
+
572
+ //clear existing headers
573
+ $this->httpHeaders = array();
574
+
575
+ //Only save HTTP headers. In PHP land, that means only _SERVER vars that
576
+ //start with HTTP_.
577
+ foreach ($httpHeaders as $key => $value) {
578
+ if (substr($key,0,5) == 'HTTP_') {
579
+ $this->httpHeaders[$key] = $value;
580
+ }
581
+ }
582
+ }
583
+
584
+ /**
585
+ * Retrieves the HTTP headers.
586
+ *
587
+ * @return array
588
+ */
589
+ public function getHttpHeaders()
590
+ {
591
+ return $this->httpHeaders;
592
+ }
593
+
594
+ /**
595
+ * Retrieves a particular header. If it doesn't exist, no exception/error is caused.
596
+ * Simply null is returned.
597
+ *
598
+ * @param string $header The name of the header to retrieve. Can be HTTP compliant such as
599
+ * "User-Agent" or "X-Device-User-Agent" or can be php-esque with the
600
+ * all-caps, HTTP_ prefixed, underscore seperated awesomeness.
601
+ *
602
+ * @return string|null The value of the header.
603
+ */
604
+ public function getHttpHeader($header)
605
+ {
606
+ //are we using PHP-flavored headers?
607
+ if (strpos($header, '_') === false) {
608
+ $header = str_replace('-', '_', $header);
609
+ $header = strtoupper($header);
610
+ }
611
+
612
+ //test the alternate, too
613
+ $altHeader = 'HTTP_' . $header;
614
+
615
+ //Test both the regular and the HTTP_ prefix
616
+ if (isset($this->httpHeaders[$header])) {
617
+ return $this->httpHeaders[$header];
618
+ } elseif (isset($this->httpHeaders[$altHeader])) {
619
+ return $this->httpHeaders[$altHeader];
620
+ }
621
+ }
622
+
623
+ public function getMobileHeaders()
624
+ {
625
+ return self::$mobileHeaders;
626
+ }
627
+
628
+ /**
629
+ * Get all possible HTTP headers that
630
+ * can contain the User-Agent string.
631
+ *
632
+ * @return array List of HTTP headers.
633
+ */
634
+ public function getUaHttpHeaders()
635
+ {
636
+ return self::$uaHttpHeaders;
637
+ }
638
+
639
+ /**
640
+ * Set the User-Agent to be used.
641
+ *
642
+ * @param string $userAgent The user agent string to set.
643
+ */
644
+ public function setUserAgent($userAgent = null)
645
+ {
646
+ if (!empty($userAgent)) {
647
+ return $this->userAgent = $userAgent;
648
+ } else {
649
+
650
+ $this->userAgent = null;
651
+
652
+ foreach($this->getUaHttpHeaders() as $altHeader){
653
+ if(!empty($this->httpHeaders[$altHeader])){ // @todo: should use getHttpHeader(), but it would be slow. (Serban)
654
+ $this->userAgent .= $this->httpHeaders[$altHeader] . " ";
655
+ }
656
+ }
657
+
658
+ return $this->userAgent = (!empty($this->userAgent) ? trim($this->userAgent) : null);
659
+
660
+ }
661
+ }
662
+
663
+ /**
664
+ * Retrieve the User-Agent.
665
+ *
666
+ * @return string|null The user agent if it's set.
667
+ */
668
+ public function getUserAgent()
669
+ {
670
+ return $this->userAgent;
671
+ }
672
+
673
+ /**
674
+ * Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or
675
+ * self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set.
676
+ *
677
+ * @deprecated since version 2.6.9
678
+ *
679
+ * @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default
680
+ * parameter is null which will default to self::DETECTION_TYPE_MOBILE.
681
+ */
682
+ public function setDetectionType($type = null)
683
+ {
684
+ if ($type === null) {
685
+ $type = self::DETECTION_TYPE_MOBILE;
686
+ }
687
+
688
+ if ($type != self::DETECTION_TYPE_MOBILE && $type != self::DETECTION_TYPE_EXTENDED) {
689
+ return;
690
+ }
691
+
692
+ $this->detectionType = $type;
693
+ }
694
+
695
+ /**
696
+ * Retrieve the list of known phone devices.
697
+ *
698
+ * @return array List of phone devices.
699
+ */
700
+ public static function getPhoneDevices()
701
+ {
702
+ return self::$phoneDevices;
703
+ }
704
+
705
+ /**
706
+ * Retrieve the list of known tablet devices.
707
+ *
708
+ * @return array List of tablet devices.
709
+ */
710
+ public static function getTabletDevices()
711
+ {
712
+ return self::$tabletDevices;
713
+ }
714
+
715
+ /**
716
+ * Alias for getBrowsers() method.
717
+ *
718
+ * @return array List of user agents.
719
+ */
720
+ public static function getUserAgents()
721
+ {
722
+ return self::getBrowsers();
723
+ }
724
+
725
+ /**
726
+ * Retrieve the list of known browsers. Specifically, the user agents.
727
+ *
728
+ * @return array List of browsers / user agents.
729
+ */
730
+ public static function getBrowsers()
731
+ {
732
+ return self::$browsers;
733
+ }
734
+
735
+ /**
736
+ * Retrieve the list of known utilities.
737
+ *
738
+ * @return array List of utilities.
739
+ */
740
+ public static function getUtilities()
741
+ {
742
+ return self::$utilities;
743
+ }
744
+
745
+ /**
746
+ * Method gets the mobile detection rules. This method is used for the magic methods $detect->is*().
747
+ *
748
+ * @deprecated since version 2.6.9
749
+ *
750
+ * @return array All the rules (but not extended).
751
+ */
752
+ public static function getMobileDetectionRules()
753
+ {
754
+ static $rules;
755
+
756
+ if (!$rules) {
757
+ $rules = array_merge(
758
+ self::$phoneDevices,
759
+ self::$tabletDevices,
760
+ self::$operatingSystems,
761
+ self::$browsers
762
+ );
763
+ }
764
+
765
+ return $rules;
766
+
767
+ }
768
+
769
+ /**
770
+ * Method gets the mobile detection rules + utilities.
771
+ * The reason this is separate is because utilities rules
772
+ * don't necessary imply mobile. This method is used inside
773
+ * the new $detect->is('stuff') method.
774
+ *
775
+ * @deprecated since version 2.6.9
776
+ *
777
+ * @return array All the rules + extended.
778
+ */
779
+ public function getMobileDetectionRulesExtended()
780
+ {
781
+ static $rules;
782
+
783
+ if (!$rules) {
784
+ // Merge all rules together.
785
+ $rules = array_merge(
786
+ self::$phoneDevices,
787
+ self::$tabletDevices,
788
+ self::$operatingSystems,
789
+ self::$browsers,
790
+ self::$utilities
791
+ );
792
+ }
793
+
794
+ return $rules;
795
+ }
796
+
797
+ /**
798
+ * Retrieve the current set of rules.
799
+ *
800
+ * @deprecated since version 2.6.9
801
+ *
802
+ * @return array
803
+ */
804
+ public function getRules()
805
+ {
806
+ if ($this->detectionType == self::DETECTION_TYPE_EXTENDED) {
807
+ return self::getMobileDetectionRulesExtended();
808
+ } else {
809
+ return self::getMobileDetectionRules();
810
+ }
811
+ }
812
+
813
+ /**
814
+ * Retrieve the list of mobile operating systems.
815
+ *
816
+ * @return array The list of mobile operating systems.
817
+ */
818
+ public static function getOperatingSystems()
819
+ {
820
+ return self::$operatingSystems;
821
+ }
822
+
823
+ /**
824
+ * Check the HTTP headers for signs of mobile.
825
+ * This is the fastest mobile check possible; it's used
826
+ * inside isMobile() method.
827
+ *
828
+ * @return bool
829
+ */
830
+ public function checkHttpHeadersForMobile()
831
+ {
832
+
833
+ foreach($this->getMobileHeaders() as $mobileHeader => $matchType){
834
+ if( isset($this->httpHeaders[$mobileHeader]) ){
835
+ if( is_array($matchType['matches']) ){
836
+ foreach($matchType['matches'] as $_match){
837
+ if( strpos($this->httpHeaders[$mobileHeader], $_match) !== false ){
838
+ return true;
839
+ }
840
+ }
841
+ return false;
842
+ } else {
843
+ return true;
844
+ }
845
+ }
846
+ }
847
+
848
+ return false;
849
+
850
+ }
851
+
852
+ /**
853
+ * Magic overloading method.
854
+ *
855
+ * @method boolean is[...]()
856
+ * @param string $name
857
+ * @param array $arguments
858
+ * @return mixed
859
+ * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is'
860
+ */
861
+ public function __call($name, $arguments)
862
+ {
863
+ //make sure the name starts with 'is', otherwise
864
+ if (substr($name, 0, 2) != 'is') {
865
+ throw new BadMethodCallException("No such method exists: $name");
866
+ }
867
+
868
+ $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
869
+
870
+ $key = substr($name, 2);
871
+
872
+ return $this->matchUAAgainstKey($key);
873
+ }
874
+
875
+ /**
876
+ * Find a detection rule that matches the current User-agent.
877
+ *
878
+ * @param null $userAgent deprecated
879
+ * @return boolean
880
+ */
881
+ protected function matchDetectionRulesAgainstUA($userAgent = null)
882
+ {
883
+ // Begin general search.
884
+ foreach ($this->getRules() as $_regex) {
885
+ if (empty($_regex)) {
886
+ continue;
887
+ }
888
+ if ($this->match($_regex, $userAgent)) {
889
+ return true;
890
+ }
891
+ }
892
+
893
+ return false;
894
+ }
895
+
896
+ /**
897
+ * Search for a certain key in the rules array.
898
+ * If the key is found the try to match the corresponding
899
+ * regex agains the User-Agent.
900
+ *
901
+ * @param string $key
902
+ * @param null $userAgent deprecated
903
+ * @return mixed
904
+ */
905
+ protected function matchUAAgainstKey($key, $userAgent = null)
906
+ {
907
+ // Make the keys lowercase so we can match: isIphone(), isiPhone(), isiphone(), etc.
908
+ $key = strtolower($key);
909
+
910
+ //change the keys to lower case
911
+ $_rules = array_change_key_case($this->getRules());
912
+
913
+ if (array_key_exists($key, $_rules)) {
914
+ if (empty($_rules[$key])) {
915
+ return null;
916
+ }
917
+
918
+ return $this->match($_rules[$key], $userAgent);
919
+ }
920
+
921
+ return false;
922
+ }
923
+
924
+ /**
925
+ * Check if the device is mobile.
926
+ * Returns true if any type of mobile device detected, including special ones
927
+ * @param null $userAgent deprecated
928
+ * @param null $httpHeaders deprecated
929
+ * @return bool
930
+ */
931
+ public function isMobile($userAgent = null, $httpHeaders = null)
932
+ {
933
+
934
+ if ($httpHeaders) {
935
+ $this->setHttpHeaders($httpHeaders);
936
+ }
937
+
938
+ if ($userAgent) {
939
+ $this->setUserAgent($userAgent);
940
+ }
941
+
942
+ $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
943
+
944
+ if ($this->checkHttpHeadersForMobile()) {
945
+ return true;
946
+ } else {
947
+ return $this->matchDetectionRulesAgainstUA();
948
+ }
949
+
950
+ }
951
+
952
+ /**
953
+ * Check if the device is a tablet.
954
+ * Return true if any type of tablet device is detected.
955
+ *
956
+ * @param string $userAgent deprecated
957
+ * @param array $httpHeaders deprecated
958
+ * @return bool
959
+ */
960
+ public function isTablet($userAgent = null, $httpHeaders = null)
961
+ {
962
+ $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
963
+
964
+ foreach (self::$tabletDevices as $_regex) {
965
+ if ($this->match($_regex, $userAgent)) {
966
+ return true;
967
+ }
968
+ }
969
+
970
+ return false;
971
+ }
972
+
973
+ /**
974
+ * This method checks for a certain property in the
975
+ * userAgent.
976
+ * @todo: The httpHeaders part is not yet used.
977
+ *
978
+ * @param $key
979
+ * @param string $userAgent deprecated
980
+ * @param string $httpHeaders deprecated
981
+ * @return bool|int|null
982
+ */
983
+ public function is($key, $userAgent = null, $httpHeaders = null)
984
+ {
985
+ // Set the UA and HTTP headers only if needed (eg. batch mode).
986
+ if ($httpHeaders) {
987
+ $this->setHttpHeaders($httpHeaders);
988
+ }
989
+
990
+ if ($userAgent) {
991
+ $this->setUserAgent($userAgent);
992
+ }
993
+
994
+ $this->setDetectionType(self::DETECTION_TYPE_EXTENDED);
995
+
996
+ return $this->matchUAAgainstKey($key);
997
+ }
998
+
999
+ /**
1000
+ * Some detection rules are relative (not standard),
1001
+ * because of the diversity of devices, vendors and
1002
+ * their conventions in representing the User-Agent or
1003
+ * the HTTP headers.
1004
+ *
1005
+ * This method will be used to check custom regexes against
1006
+ * the User-Agent string.
1007
+ *
1008
+ * @param $regex
1009
+ * @param string $userAgent
1010
+ * @return bool
1011
+ *
1012
+ * @todo: search in the HTTP headers too.
1013
+ */
1014
+ public function match($regex, $userAgent = null)
1015
+ {
1016
+ // Escape the special character which is the delimiter.
1017
+ $regex = str_replace('/', '\/', $regex);
1018
+
1019
+ return (bool) preg_match('/'.$regex.'/is', (!empty($userAgent) ? $userAgent : $this->userAgent));
1020
+ }
1021
+
1022
+ /**
1023
+ * Get the properties array.
1024
+ *
1025
+ * @return array
1026
+ */
1027
+ public static function getProperties()
1028
+ {
1029
+ return self::$properties;
1030
+ }
1031
+
1032
+ /**
1033
+ * Prepare the version number.
1034
+ *
1035
+ * @todo Remove the error supression from str_replace() call.
1036
+ *
1037
+ * @param string $ver The string version, like "2.6.21.2152";
1038
+ *
1039
+ * @return float
1040
+ */
1041
+ public function prepareVersionNo($ver)
1042
+ {
1043
+ $ver = str_replace(array('_', ' ', '/'), '.', $ver);
1044
+ $arrVer = explode('.', $ver, 2);
1045
+
1046
+ if (isset($arrVer[1])) {
1047
+ $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions.
1048
+ }
1049
+
1050
+ return (float) implode('.', $arrVer);
1051
+ }
1052
+
1053
+ /**
1054
+ * Check the version of the given property in the User-Agent.
1055
+ * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
1056
+ *
1057
+ * @param string $propertyName The name of the property. See self::getProperties() array
1058
+ * keys for all possible properties.
1059
+ * @param string $type Either self::VERSION_TYPE_STRING to get a string value or
1060
+ * self::VERSION_TYPE_FLOAT indicating a float value. This parameter
1061
+ * is optional and defaults to self::VERSION_TYPE_STRING. Passing an
1062
+ * invalid parameter will default to the this type as well.
1063
+ *
1064
+ * @return string|float The version of the property we are trying to extract.
1065
+ */
1066
+ public function version($propertyName, $type = self::VERSION_TYPE_STRING)
1067
+ {
1068
+ if (empty($propertyName)) {
1069
+ return false;
1070
+ }
1071
+
1072
+ //set the $type to the default if we don't recognize the type
1073
+ if ($type != self::VERSION_TYPE_STRING && $type != self::VERSION_TYPE_FLOAT) {
1074
+ $type = self::VERSION_TYPE_STRING;
1075
+ }
1076
+
1077
+ $properties = self::getProperties();
1078
+
1079
+ // Check if the property exists in the properties array.
1080
+ if (array_key_exists($propertyName, $properties)) {
1081
+
1082
+ // Prepare the pattern to be matched.
1083
+ // Make sure we always deal with an array (string is converted).
1084
+ $properties[$propertyName] = (array) $properties[$propertyName];
1085
+
1086
+ foreach ($properties[$propertyName] as $propertyMatchString) {
1087
+
1088
+ $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
1089
+
1090
+ // Escape the special character which is the delimiter.
1091
+ $propertyPattern = str_replace('/', '\/', $propertyPattern);
1092
+
1093
+ // Identify and extract the version.
1094
+ preg_match('/'.$propertyPattern.'/is', $this->userAgent, $match);
1095
+
1096
+ if (!empty($match[1])) {
1097
+ $version = ( $type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1] );
1098
+
1099
+ return $version;
1100
+ }
1101
+
1102
+ }
1103
+
1104
+ }
1105
+
1106
+ return false;
1107
+ }
1108
+
1109
+ /**
1110
+ * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
1111
+ *
1112
+ * @return string One of the self::MOBILE_GRADE_* constants.
1113
+ */
1114
+ public function mobileGrade()
1115
+ {
1116
+ $isMobile = $this->isMobile();
1117
+
1118
+ if (
1119
+ // Apple iOS 3.2-5.1 - Tested on the original iPad (4.3 / 5.0), iPad 2 (4.3), iPad 3 (5.1), original iPhone (3.1), iPhone 3 (3.2), 3GS (4.3), 4 (4.3 / 5.0), and 4S (5.1)
1120
+ $this->version('iPad', self::VERSION_TYPE_FLOAT)>=4.3 ||
1121
+ $this->version('iPhone', self::VERSION_TYPE_FLOAT)>=3.1 ||
1122
+ $this->version('iPod', self::VERSION_TYPE_FLOAT)>=3.1 ||
1123
+
1124
+ // Android 2.1-2.3 - Tested on the HTC Incredible (2.2), original Droid (2.2), HTC Aria (2.1), Google Nexus S (2.3). Functional on 1.5 & 1.6 but performance may be sluggish, tested on Google G1 (1.5)
1125
+ // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM
1126
+ // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices
1127
+ // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7
1128
+ ( $this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit') ) ||
1129
+
1130
+ // Windows Phone 7-7.5 - Tested on the HTC Surround (7.0) HTC Trophy (7.5), LG-E900 (7.5), Nokia Lumia 800
1131
+ $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT)>=7.0 ||
1132
+
1133
+ // Blackberry 7 - Tested on BlackBerry® Torch 9810
1134
+ // Blackberry 6.0 - Tested on the Torch 9800 and Style 9670
1135
+ $this->is('BlackBerry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)>=6.0 ||
1136
+ // Blackberry Playbook (1.0-2.0) - Tested on PlayBook
1137
+ $this->match('Playbook.*Tablet') ||
1138
+
1139
+ // Palm WebOS (1.4-2.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0)
1140
+ ( $this->version('webOS', self::VERSION_TYPE_FLOAT)>=1.4 && $this->match('Palm|Pre|Pixi') ) ||
1141
+ // Palm WebOS 3.0 - Tested on HP TouchPad
1142
+ $this->match('hp.*TouchPad') ||
1143
+
1144
+ // Firefox Mobile (12 Beta) - Tested on Android 2.3 device
1145
+ ( $this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT)>=12 ) ||
1146
+
1147
+ // Chrome for Android - Tested on Android 4.0, 4.1 device
1148
+ ( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT)>=4.0 ) ||
1149
+
1150
+ // Skyfire 4.1 - Tested on Android 2.3 device
1151
+ ( $this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT)>=4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT)>=2.3 ) ||
1152
+
1153
+ // Opera Mobile 11.5-12: Tested on Android 2.3
1154
+ ( $this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT)>11 && $this->is('AndroidOS') ) ||
1155
+
1156
+ // Meego 1.2 - Tested on Nokia 950 and N9
1157
+ $this->is('MeeGoOS') ||
1158
+
1159
+ // Tizen (pre-release) - Tested on early hardware
1160
+ $this->is('Tizen') ||
1161
+
1162
+ // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser
1163
+ // @todo: more tests here!
1164
+ $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT)>=2.0 ||
1165
+
1166
+ // UC Browser - Tested on Android 2.3 device
1167
+ ( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT)>=2.3 ) ||
1168
+
1169
+ // Kindle 3 and Fire - Tested on the built-in WebKit browser for each
1170
+ ( $this->match('Kindle Fire') ||
1171
+ $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT)>=3.0 ) ||
1172
+
1173
+ // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
1174
+ $this->is('AndroidOS') && $this->is('NookTablet') ||
1175
+
1176
+ // Chrome Desktop 11-21 - Tested on OS X 10.7 and Windows 7
1177
+ $this->version('Chrome', self::VERSION_TYPE_FLOAT)>=11 && !$isMobile ||
1178
+
1179
+ // Safari Desktop 4-5 - Tested on OS X 10.7 and Windows 7
1180
+ $this->version('Safari', self::VERSION_TYPE_FLOAT)>=5.0 && !$isMobile ||
1181
+
1182
+ // Firefox Desktop 4-13 - Tested on OS X 10.7 and Windows 7
1183
+ $this->version('Firefox', self::VERSION_TYPE_FLOAT)>=4.0 && !$isMobile ||
1184
+
1185
+ // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7
1186
+ $this->version('MSIE', self::VERSION_TYPE_FLOAT)>=7.0 && !$isMobile ||
1187
+
1188
+ // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7
1189
+ // @reference: http://my.opera.com/community/openweb/idopera/
1190
+ $this->version('Opera', self::VERSION_TYPE_FLOAT)>=10 && !$isMobile
1191
+
1192
+ ){
1193
+ return self::MOBILE_GRADE_A;
1194
+ }
1195
+
1196
+ if (
1197
+ $this->version('iPad', self::VERSION_TYPE_FLOAT)<4.3 ||
1198
+ $this->version('iPhone', self::VERSION_TYPE_FLOAT)<3.1 ||
1199
+ $this->version('iPod', self::VERSION_TYPE_FLOAT)<3.1 ||
1200
+
1201
+ // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770
1202
+ $this->is('Blackberry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)>=5 && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<6 ||
1203
+
1204
+ //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
1205
+ ( $this->version('Opera Mini', self::VERSION_TYPE_FLOAT)>=5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT)<=6.5 &&
1206
+ ($this->version('Android', self::VERSION_TYPE_FLOAT)>=2.3 || $this->is('iOS')) ) ||
1207
+
1208
+ // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)
1209
+ $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
1210
+
1211
+ // @todo: report this (tested on Nokia N71)
1212
+ $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT)>=11 && $this->is('SymbianOS')
1213
+ ){
1214
+ return self::MOBILE_GRADE_B;
1215
+ }
1216
+
1217
+ if (
1218
+ // Blackberry 4.x - Tested on the Curve 8330
1219
+ $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<5.0 ||
1220
+ // Windows Mobile - Tested on the HTC Leo (WinMo 5.2)
1221
+ $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT)<=5.2
1222
+
1223
+ ){
1224
+ return self::MOBILE_GRADE_C;
1225
+ }
1226
+
1227
+ //All older smartphone platforms and featurephones - Any device that doesn't support media queries
1228
+ //will receive the basic, C grade experience.
1229
+ return self::MOBILE_GRADE_C;
1230
+ }
1231
+ }
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
+ ?>
js/debug.js ADDED
@@ -0,0 +1 @@
 
1
+ window.devicePixelRatio = 2;
js/lazysizes.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ /*! lazysizes - v2.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=b.documentElement,e=a.Date,f=a.HTMLPictureElement,g="addEventListener",h="getAttribute",i=a[g],j=a.setTimeout,k=a.requestAnimationFrame||j,l=a.requestIdleCallback,m=/^picture$/i,n=["load","error","lazyincluded","_lazyloaded"],o={},p=Array.prototype.forEach,q=function(a,b){return o[b]||(o[b]=new RegExp("(\\s|^)"+b+"(\\s|$)")),o[b].test(a[h]("class")||"")&&o[b]},r=function(a,b){q(a,b)||a.setAttribute("class",(a[h]("class")||"").trim()+" "+b)},s=function(a,b){var c;(c=q(a,b))&&a.setAttribute("class",(a[h]("class")||"").replace(c," "))},t=function(a,b,c){var d=c?g:"removeEventListener";c&&t(a,b),n.forEach(function(c){a[d](c,b)})},u=function(a,c,d,e,f){var g=b.createEvent("CustomEvent");return g.initCustomEvent(c,!e,!f,d||{}),a.dispatchEvent(g),g},v=function(b,d){var e;!f&&(e=a.picturefill||c.pf)?e({reevaluate:!0,elements:[b]}):d&&d.src&&(b.src=d.src)},w=function(a,b){return(getComputedStyle(a,null)||{})[b]},x=function(a,b,d){for(d=d||a.offsetWidth;d<c.minSize&&b&&!a._lazysizesWidth;)d=b.offsetWidth,b=b.parentNode;return d},y=function(){var a,c,d=[],e=function(){var b;for(a=!0,c=!1;d.length;)b=d.shift(),b[0].apply(b[1],b[2]);a=!1};return function(f){a?f.apply(this,arguments):(d.push([f,this,arguments]),c||(c=!0,(b.hidden?j:k)(e)))}}(),z=function(a,b){return b?function(){y(a)}:function(){var b=this,c=arguments;y(function(){a.apply(b,c)})}},A=function(a){var b,c=0,d=125,f=999,g=f,h=function(){b=!1,c=e.now(),a()},i=l?function(){l(h,{timeout:g}),g!==f&&(g=f)}:z(function(){j(h)},!0);return function(a){var f;(a=a===!0)&&(g=66),b||(b=!0,f=d-(e.now()-c),0>f&&(f=0),a||9>f&&l?i():j(i,f))}},B=function(a){var b,c,d=99,f=function(){b=null,a()},g=function(){var a=e.now()-c;d>a?j(g,d-a):(l||f)(f)};return function(){c=e.now(),b||(b=j(g,d))}},C=function(){var f,k,l,n,o,x,C,E,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&&t(a.target,T),(!a||0>R||!a.target)&&(R=0)},U=function(a,c){var e,f=a,g="hidden"==w(b.body,"visibility")||"hidden"!=w(a,"visibility");for(F-=c,I+=c,G-=c,H+=c;g&&(f=f.offsetParent)&&f!=b.body&&f!=d;)g=(w(f,"opacity")||1)>0,g&&"visible"!=w(f,"overflow")&&(e=f.getBoundingClientRect(),g=H>e.left&&G<e.right&&I>e.top-1&&F<e.bottom+1);return g},V=function(){var a,e,g,i,j,m,n,p,q;if((o=c.loadMode)&&8>R&&(a=f.length)){e=0,S++,null==K&&("expand"in c||(c.expand=d.clientHeight>500&&d.clientWidth>500?500:370),J=c.expand,K=J*c.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>e;e++)if(f[e]&&!f[e]._lazyRace)if(O)if((p=f[e][h]("data-expand"))&&(m=1*p)||(m=Q),q!==m&&(C=innerWidth+m*L,E=innerHeight+m,n=-1*m,q=m),g=f[e].getBoundingClientRect(),(I=g.bottom)>=n&&(F=g.top)<=E&&(H=g.right)>=n*L&&(G=g.left)<=C&&(I||H||G||F)&&(l&&3>R&&!p&&(3>o||4>S)||U(f[e],m))){if(ba(f[e]),j=!0,R>9)break}else!j&&l&&!i&&4>R&&4>S&&o>2&&(k[0]||c.preloadAfterLoad)&&(k[0]||!p&&(I||H||G||F||"auto"!=f[e][h](c.sizesAttr)))&&(i=k[0]||f[e]);else ba(f[e]);i&&!j&&ba(i)}},W=A(V),X=function(a){r(a.target,c.loadedClass),s(a.target,c.loadingClass),t(a.target,Z)},Y=z(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,d,e=a[h](c.srcsetAttr);(b=c.customMedia[a[h]("data-media")||a[h]("media")])&&a.setAttribute("media",b),e&&a.setAttribute("srcset",e),b&&(d=a.parentNode,d.insertBefore(a.cloneNode(),a),d.removeChild(a))},aa=z(function(a,b,d,e,f){var g,i,k,l,o,q;(o=u(a,"lazybeforeunveil",b)).defaultPrevented||(e&&(d?r(a,c.autosizesClass):a.setAttribute("sizes",e)),i=a[h](c.srcsetAttr),g=a[h](c.srcAttr),f&&(k=a.parentNode,l=k&&m.test(k.nodeName||"")),q=b.firesLoad||"src"in a&&(i||g||l),o={target:a},q&&(t(a,T,!0),clearTimeout(n),n=j(T,2500),r(a,c.loadingClass),t(a,Z,!0)),l&&p.call(k.getElementsByTagName("source"),_),i?a.setAttribute("srcset",i):g&&!l&&(N.test(a.nodeName)?$(a,g):a.src=g),(i||l)&&v(a,{src:g})),y(function(){a._lazyRace&&delete a._lazyRace,s(a,c.lazyClass),(!q||a.complete)&&(q?T(o):R--,X(o))})}),ba=function(a){var b,d=M.test(a.nodeName),e=d&&(a[h](c.sizesAttr)||a[h]("sizes")),f="auto"==e;(!f&&l||!d||!a.src&&!a.srcset||a.complete||q(a,c.errorClass))&&(b=u(a,"lazyunveilread").detail,f&&D.updateElem(a,!0,a.offsetWidth),a._lazyRace=!0,R++,aa(a,b,f,e,d))},ca=function(){if(!l){if(e.now()-x<999)return void j(ca,999);var a=B(function(){c.loadMode=3,W()});l=!0,c.loadMode=3,W(),i("scroll",function(){3==c.loadMode&&(c.loadMode=2),a()},!0)}};return{_:function(){x=e.now(),f=b.getElementsByClassName(c.lazyClass),k=b.getElementsByClassName(c.lazyClass+" "+c.preloadClass),L=c.hFac,i("scroll",W,!0),i("resize",W,!0),a.MutationObserver?new MutationObserver(W).observe(d,{childList:!0,subtree:!0,attributes:!0}):(d[g]("DOMNodeInserted",W,!0),d[g]("DOMAttrModified",W,!0),setInterval(W,999)),i("hashchange",W,!0),["focus","mouseover","click","load","transitionend","animationend","webkitAnimationEnd"].forEach(function(a){b[g](a,W,!0)}),/d$|^c/.test(b.readyState)?ca():(i("load",ca),b[g]("DOMContentLoaded",W),j(ca,2e4)),W(f.length>0)},checkElems:W,unveil:ba}}(),D=function(){var a,d=z(function(a,b,c,d){var e,f,g;if(a._lazysizesWidth=d,d+="px",a.setAttribute("sizes",d),m.test(b.nodeName||""))for(e=b.getElementsByTagName("source"),f=0,g=e.length;g>f;f++)e[f].setAttribute("sizes",d);c.detail.dataAttr||v(a,c.detail)}),e=function(a,b,c){var e,f=a.parentNode;f&&(c=x(a,f,c),e=u(a,"lazybeforesizes",{width:c,dataAttr:!!b}),e.defaultPrevented||(c=e.detail.width,c&&c!==a._lazysizesWidth&&d(a,f,e,c)))},f=function(){var b,c=a.length;if(c)for(b=0;c>b;b++)e(a[b])},g=B(f);return{_:function(){a=b.getElementsByClassName(c.autosizesClass),i("resize",g)},checkElems:g,updateElem:e}}(),E=function(){E.i||(E.i=!0,D._(),C._())};return function(){var b,d={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};c=a.lazySizesConfig||a.lazysizesConfig||{};for(b in d)b in c||(c[b]=d[b]);a.lazySizesConfig=c,j(function(){c.init&&E()})}(),{cfg:c,autoSizer:D,loader:C,init:E,uP:v,aC:r,rC:s,hC:q,fire:u,gW:x,rAF:y}}});
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);
js/retina-cookie.js ADDED
@@ -0,0 +1 @@
 
1
+ document.cookie='devicePixelRatio='+((window.devicePixelRatio === undefined) ? 1 : window.devicePixelRatio)+'; path=/';
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
+ })();
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)}();
languages/wp-retina-2x-de_DE.mo ADDED
Binary file
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> :)"
languages/wp-retina-2x-fr_FR.mo ADDED
Binary file
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> :)"
languages/wp-retina-2x-it_IT.mo ADDED
Binary file
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"
languages/wp-retina-2x-sv_SE.mo ADDED
Binary file
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> :)"
readme.txt ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.7.2
6
+ Stable tag: 4.8.0
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 http://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
+ = 4.8.0 =
37
+ * Add: Retina Image Quality for JPG (between 0 and 100). I know this little setting was really wanted :)
38
+ * Fix: Disabled sizes weren't really disabled in the UI.
39
+ * Add: Handles incompatibility with JetPack's Photon.
40
+ * Info: If you are using Lightroom, please have a look at my plugin for synchronizing your Lightroom to WordPress: http://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 :)
41
+
42
+ = 4.7.7 =
43
+ * 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.
44
+
45
+ = 4.7.6 =
46
+ * Fix: Issue with Pro being non-Pro outside of WP Admin.
47
+ * Fix: Retina debugging file was not being created properly.
48
+
49
+ = 4.7.5 =
50
+ * Fix: Don't delete the full-size Retina if we re-generate.
51
+ * Fix: Little issue with Ignore.
52
+ * Update: Additional debugging.
53
+ * 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 :)
54
+
55
+ = 4.7.4 =
56
+ * 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.
57
+ * Add: New PictureFill option: inline CSS background can be now replaced by Retina images (excellent for sliders for example).
58
+ * 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.
59
+ * 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.
60
+ * Fix: Check if the CDN is already present before modifying/adding.
61
+
62
+ = 4.6.0 =
63
+ * Fix: Button Details was not working properly.
64
+ * Fix: Removed the beta Retina Uploader which is not working yet (was included by mistake).
65
+ * 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.)
66
+
67
+ = 4.5.8 =
68
+ * Update: LazyLoad 2.0.3
69
+ * Fix: Don't display Retina information for a media that is not an image.
70
+ * Update: Retina.js 2.0.0
71
+ * Fix: Drag & Drop upload was a bit buggy, it now has been improved a lot!
72
+ * Add: Option to hide the ads, flatter and message about the Pro.
73
+ * Update: Options styles.
74
+
75
+ = 4.4.6 =
76
+ * Update: LazyLoad 1.5
77
+ * Update: Retina.js 1.4
78
+ * Update: PictureFill JS 3.0.2
79
+ * Fix: LazyLoad was not playing well when WordPress creates the src-set by itself.
80
+ * Fix: Get the right max-upload size when using HHVM.
81
+ * Fix: Displays an error in the dashboard when the server-side fails to process uploads.
82
+ * Update: During bulk, doesn't stop in case of errors anymore but display an errors counter.
83
+ * Update: Ignore Responsive Images support if the media ID is not existent (in case of broken HTML).
84
+
85
+ = 4.4.0 =
86
+ * Info: Please read my blog post about WP 4.4 + Retina on http://meowapps.com/wordpress-4-4-retina/.
87
+ * Add: New "Responsive Images" method.
88
+ * Add: Lot more information is available in the Retina settings, to help the newbies :)
89
+ * Update: Headers are compliant to WP 4.4.
90
+ * Update: Dashboard has been revamped for Pro users. Standard users can still use Bulk functions.
91
+ * Update: Support for WP 4.4.
92
+
93
+ = 3.5.2 =
94
+ * Fix: Search string not null but empty induces error.
95
+ * Change: User Agent used for Pro authentication.
96
+ * Fix: Issues with class containing trailing spaces. Fixed in in SimpleHTMLDOM.
97
+ * Fix: Used to show weird numbers when using 9999 as width or height.
98
+ * Add: Filter and default filter to avoid certain IMG SRC to be checked/parsed by the plugin while rendering.
99
+
100
+ = 3.4.2 =
101
+ * Fix: Full-Size Retina wasn't removed when the original file was deleted from WP.
102
+ * Fix: Images set up with a 0x0 size must be skipped.
103
+ * Fix: There was an issue if the class starts with a space (broken HTML), plugin automatically fix it on the fly.
104
+ * Fix: Full-Size image had the wrong path in the Details screen.
105
+ * Fix: Option Auto Generate was wrongly show unchecked even though it is active by default.
106
+ * Update: Moved the filters to allow developers to use files hosted on another server.
107
+ * Update: Translation strings. If you want to translate the plugin in your language, please contact me :)
108
+
109
+ = 3.3.6 =
110
+ * Fix: There was an issue with local path for a few installs.
111
+ * Add: Introduced $wr2x_extra_debug for extra developer debug (might be handy).
112
+ * Fix: Issues with retina images outside the uploads directory.
113
+ * Add: Custom CDN Domain support (check the "Custom CDN Domain" option).
114
+ * Fix: Removed a console.log that was forgotten ;)
115
+ * Change: different way of getting the temporary folder to write files (might help in a few cases).
116
+
117
+ = 3.1.0 =
118
+ * Add: Lazy-loading option for PictureFill (Pro).
119
+ * Fix: For the Pro users having the IXR_client error.
120
+ * Fix: Plugin now works even behind a proxy.
121
+ * Fix: Little UI bug while uploading a new image.
122
+ * Add: In the dashboard, added tooltips showing the sizes of the little squares on hover.
123
+ * Fix: The plugin was not compatible with Polylang, now it works.
124
+
125
+ = 3.0.0 =
126
+ * Add: Link to logs from the dashboard (if logs are available), and possibility to clear it directly.
127
+ * Add: Replace the Full-Size directly by drag & drop in the box.
128
+ * Add: Support for WPML Media.
129
+ * Change: Picturefill script to 'v2.2.0 - 2014-02-03'.
130
+ * Change: Enhanced logs (in debug mode), much easier to read.
131
+ * Change: Dashboard enhanced, more clear, possibility of having many image sizes on the screen.
132
+ * Fix: Better handing of non-image media and image detection.
133
+ * Fix: Rounding issues always been present, they are now fixed with an 2px error margin.
134
+ * Fix: Warnings and issues in case of broken metadata and images.
135
+ * Add: (PRO) New pop-up screen with detailed information.
136
+ * 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.
137
+ * Add: (PRO) Option to avoid removing img's src when using PictureFill.
138
+ * Info: The serial for the Pro version can be bought at http://meowapps.com/wp-retina-2x. Thanks for all your support, the plugin is going to be 3 years old this year! :)
139
+
140
+ = 2.6.0 =
141
+ * Add: Support Manual Image Crop, resize the @2x as the user manually cropped them (that's cool!).
142
+ * Change: Name will change little by little to WP Retina X and menus simplified to simply "Retina".
143
+ * Change: Simplification of the dashboard (more is coming).
144
+ * Change: PictureFill updated to 'v2.2.0 - 2014-12-19'.
145
+ * Fix: Issue with the upload directory on some installs.
146
+ * Info: Way more is coming soon to the dashboard, thanks for your patience :)
147
+ * 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.
148
+
149
+ = 1.6.0 =
150
+ * Add: HTML srcset method.
151
+
152
+ = 1.0.0 =
153
+ * Change: enhancement of the Retina Dashboard.
154
+ * Change: better management of the 'issues'.
155
+ * Change: handle images with technical problems.
156
+ * Fix: random little fixes again.
157
+ * Change: upload is now HTML5, by drag and drop in the Retina Dashboard!
158
+
159
+ = 0.9.4 =
160
+ * Fix: esthetical issue related to the icons in the Retina dashboard.
161
+ * Fix: warnings when uploading/replacing an image file.
162
+ * Change: Media Replace is not used anymore, the code has been embedded in the plugin directly.
163
+ * Update: to the new version of Retina.js (client-method).
164
+ * Fix: updated rewrite-rule (server-method) that works with multi-site.
165
+ * Fix: support for Network install (multi-site). Thanks to Jeremy (Retina-Images).
166
+
167
+ = 0.3.0 =
168
+ * Fix: was not generating the images properly on multisite WordPress installs.
169
+ * Add: warning message if using the server-side method without the pretty permalinks.
170
+ * Add: warning message if using the server-side method on a multisite WordPress install.
171
+ * Change: the client-method (retina.js) is now used by default.
172
+ * Fix: simplified version of the .htaccess directive.
173
+ * Fix: new version of the client-side method (Retina.js), works 100x faster.
174
+ * Fix: SQL optimization & memory usage huge improvement.
175
+
176
+ = 0.2.2 =
177
+ * Fix: the recommended resolution shown wasn't the most adequate one.
178
+ * Fix: in a few cases, the .htaccess wasn't properly generated.
179
+ * Fix: files were renamed to avoid conflicts.
180
+ * Add: paging for the Retina Dashboard.
181
+ * Add: 'Generate for all files' handles and shows if there are errors.
182
+ * Add: the Retina Dashboard.
183
+ * Add: can now generate Retina files in bulk.
184
+ * Fix: the cropped images were not 'cropped'.
185
+ * Add: The Retina Dashboard and the Media Library's column can be disabled via the settings.
186
+ * Fix: resolved more PHP warning and notices.
187
+
188
+ = 0.1 =
189
+ * Very first release.
190
+
191
+ == Installation ==
192
+
193
+ Quick and easy installation:
194
+
195
+ 1. Upload the folder `wp-retina-2x` to the `/wp-content/plugins/` directory.
196
+ 2. Activate the plugin through the 'Plugins' menu in WordPress.
197
+ 3. Check the settings of WP Retina 2x in the WordPress administration screen.
198
+ 4. Check the Retina Dashboard.
199
+ 6. Read the tutorial about the plugin: <a href='http://meowapps.com/wp-retina-2x/tutorial/'>WP Retina 2x Tutorial</a>.
200
+
201
+ == Frequently Asked Questions ==
202
+
203
+ Users, you will find the FAQ here: http://meowapps.com/wp-retina-2x/faq/.
204
+
205
+ Developers, WP Retina 2x has a little API. Here are a few filters and actions you might want to use.
206
+
207
+ = Functions =
208
+ * wr2x_get_retina_from_url( $url ): return the URL of the retina image (empty string if not found)
209
+ * wr2x_get_retina( $syspath ): return the system path of the retina image (null if not found)
210
+
211
+ = Actions =
212
+ * 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
213
+ * 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
214
+
215
+ = Filters =
216
+ * 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
217
+ * 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
218
+ * 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)
219
+ * wr2x_validate_src: the img src is passed; return it if it is valid, return null if it should be skipped
220
+
221
+ == Upgrade Notice ==
222
+
223
+ None.
224
+
225
+ == Screenshots ==
226
+
227
+ 1. Retina Dashboard
228
+ 2. Basic Settings
229
+ 3. Advanced Settings
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
screenshot.png ADDED
Binary file
wp-retina-2x.php ADDED
@@ -0,0 +1,1159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: WP Retina 2x
4
+ Plugin URI: http://meowapps.com
5
+ Description: Make your website look beautiful and crisp on modern displays by creating + displaying retina images. WP 4.4 is also supported and enhanced.
6
+ Version: 4.8.0
7
+ Author: Jordy Meow
8
+ Author URI: http://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 (http://jordymeow.com)
18
+ - Haikyo (http://www.haikyo.org)
19
+ */
20
+
21
+ /**
22
+ *
23
+ * @author Jordy Meow <http://meowapps.com>
24
+ * @package Wordpress
25
+ * @subpackage Administration
26
+ *
27
+ */
28
+
29
+ $wr2x_version = '4.8.0';
30
+ $wr2x_retinajs = '2.0.0';
31
+ $wr2x_picturefill = '3.0.2';
32
+ $wr2x_lazysizes = '2.0.3';
33
+ $wr2x_retina_image = '1.7.2';
34
+ $wr2x_extra_debug = false;
35
+
36
+ //add_action( 'admin_menu', 'wr2x_admin_menu' );
37
+ add_action( 'wp_enqueue_scripts', 'wr2x_wp_enqueue_scripts' );
38
+ add_action( 'admin_enqueue_scripts', 'wr2x_wp_enqueue_scripts' );
39
+ add_filter( 'wp_generate_attachment_metadata', 'wr2x_wp_generate_attachment_metadata' );
40
+ add_action( 'delete_attachment', 'wr2x_delete_attachment' );
41
+ add_filter( 'generate_rewrite_rules', array( 'WR2X_Admin', 'generate_rewrite_rules' ) );
42
+ add_filter( 'wr2x_validate_src', 'wr2x_validate_src' );
43
+ add_action( 'init', 'wr2x_init' );
44
+
45
+ register_deactivation_hook( __FILE__, 'wr2x_deactivate' );
46
+ register_activation_hook( __FILE__, 'wr2x_activate' );
47
+
48
+ global $wr2x_admin;
49
+ require( 'wr2x_admin.php');
50
+ $wr2x_admin = new WR2X_Admin();
51
+
52
+ if ( is_admin() ) {
53
+ require( 'wr2x_ajax.php' );
54
+ if ( !get_option( "wr2x_hide_retina_dashboard" ) )
55
+ require( 'wr2x_retina-dashboard.php' );
56
+ if ( !get_option( "wr2x_hide_retina_column" ) )
57
+ require( 'wr2x_media-library.php' );
58
+ }
59
+
60
+ require( 'wr2x_responsive.php' );
61
+
62
+ // if ( get_option( "ignore_mobile" ) && !class_exists( 'Mobile_Detect' ) )
63
+ // require( 'inc/Mobile_Detect.php');
64
+
65
+ //if ( !get_option( "wr2x_hide_retina_column" ) )
66
+ //require( 'wr2x_retina_uploader.php' );
67
+
68
+ function wr2x_init() {
69
+ load_plugin_textdomain( 'wp-retina-2x', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
70
+
71
+ if ( get_option( 'wr2x_disable_medium_large' ) ) {
72
+ remove_image_size( 'medium_large' );
73
+ add_filter( 'image_size_names_choose', 'wr2x_unset_medium_large' );
74
+ add_filter( 'intermediate_image_sizes_advanced', 'wr2x_unset_medium_large' );
75
+ }
76
+
77
+ if ( is_admin() ) {
78
+ wp_register_style( 'wr2x-admin-css', plugins_url( '/wr2x_admin.css', __FILE__ ) );
79
+ wp_enqueue_style( 'wr2x-admin-css' );
80
+ if ( !get_option( "wr2x_retina_admin" ) )
81
+ return;
82
+ }
83
+
84
+ $method = get_option( "wr2x_method" );
85
+ if ( $method == "Picturefill" ) {
86
+ add_action( 'wp_head', 'wr2x_picture_buffer_start' );
87
+ add_action( 'wp_footer', 'wr2x_picture_buffer_end' );
88
+ }
89
+ else if ( $method == 'HTML Rewrite' ) {
90
+ $is_retina = false;
91
+ if ( isset( $_COOKIE['devicePixelRatio'] ) ) {
92
+ $is_retina = ceil( floatval( $_COOKIE['devicePixelRatio'] ) ) > 1;
93
+ // if ( get_option( "wr2x_ignore_mobile" ) ) {
94
+ // $mobileDetect = new Mobile_Detect();
95
+ // $is_retina = !$mobileDetect->isMobile();
96
+ // }
97
+ }
98
+ if ( $is_retina || wr2x_is_debug() ) {
99
+ add_action( 'wp_head', 'wr2x_buffer_start' );
100
+ add_action( 'wp_footer', 'wr2x_buffer_end' );
101
+ }
102
+ }
103
+
104
+ }
105
+
106
+ function wr2x_unset_medium_large( $sizes ) {
107
+ unset( $sizes['medium_large'] );
108
+ return $sizes;
109
+ }
110
+
111
+ /**
112
+ *
113
+ * PICTURE METHOD
114
+ *
115
+ */
116
+
117
+
118
+
119
+ function wr2x_is_supported_image( $url ) {
120
+ $wr2x_supported_image = array( 'jpg', 'jpeg', 'png', 'gif' );
121
+ $ext = strtolower( pathinfo( $url, PATHINFO_EXTENSION ) );
122
+ if ( !in_array( $ext, $wr2x_supported_image ) ) {
123
+ wr2x_log( "Extension (" . $ext . ") is not " . implode( ', ', $wr2x_supported_image ) . "." );
124
+ return false;
125
+ }
126
+ return true;
127
+ }
128
+
129
+ function wr2x_picture_buffer_start () {
130
+ ob_start( "wr2x_picture_rewrite" );
131
+ wr2x_log( "* HTML REWRITE FOR PICTUREFILL" );
132
+ }
133
+
134
+ function wr2x_picture_buffer_end () {
135
+ ob_end_flush();
136
+ }
137
+
138
+ // Replace the IMG tags by PICTURE tags with SRCSET
139
+ function wr2x_picture_rewrite( $buffer ) {
140
+ global $wr2x_admin;
141
+ if ( !isset( $buffer ) || trim( $buffer ) === '' )
142
+ return $buffer;
143
+ if ( !function_exists( "str_get_html" ) )
144
+ require( 'inc/simple_html_dom.php' );
145
+
146
+ $lazysize = get_option( "wr2x_picturefill_lazysizes" ) && $wr2x_admin->is_pro();
147
+ $killsrc = !get_option( "wr2x_picturefill_keep_src" );
148
+ $nodes_count = 0;
149
+ $nodes_replaced = 0;
150
+ $html = str_get_html( $buffer );
151
+ if ( !$html ) {
152
+ wr2x_log( "The HTML buffer is null, another plugin might block the process." );
153
+ return $buffer;
154
+ }
155
+
156
+ // IMG TAGS
157
+ foreach( $html->find( 'img' ) as $element ) {
158
+ $nodes_count++;
159
+ $parent = $element->parent();
160
+ if ( $parent->tag == "picture" ) {
161
+ wr2x_log("The img tag is inside a picture tag. Tag ignored.");
162
+ continue;
163
+ }
164
+ else {
165
+ $valid = apply_filters( "wr2x_validate_src", $element->src );
166
+ if ( empty( $valid ) ) {
167
+ $nodes_count--;
168
+ continue;
169
+ }
170
+
171
+ // Original HTML
172
+ $from = substr( $element, 0 );
173
+
174
+ // SRC-SET already exists, let's check if LazySize is used
175
+ if ( !empty( $element->srcset ) ) {
176
+ if ( $lazysize ) {
177
+ wr2x_log( "The src-set has already been created but it will be modifid to data-srcset for lazyload." );
178
+ $element->class = $element->class . ' lazyload';
179
+ $element->{'data-srcset'} = $element->srcset;
180
+ $element->srcset = null;
181
+ if ( $killsrc )
182
+ $element->src = null;
183
+ $to = $element;
184
+ $buffer = str_replace( trim( $from, "</> "), trim( $to, "</> " ), $buffer );
185
+ wr2x_log( "The img tag '$from' was rewritten to '$to'" );
186
+ $nodes_replaced++;
187
+ }
188
+ else {
189
+ wr2x_log( "The src-set has already been created. Tag ignored." );
190
+ }
191
+ continue;
192
+ }
193
+
194
+ // Process of SRC-SET creation
195
+ if ( !wr2x_is_supported_image( $element->src ) ) {
196
+ $nodes_count--;
197
+ continue;
198
+ }
199
+ $retina_url = wr2x_get_retina_from_url( $element->src );
200
+ $retina_url = apply_filters( 'wr2x_img_retina_url', $retina_url );
201
+ if ( $retina_url != null ) {
202
+ $retina_url = wr2x_cdn_this( $retina_url );
203
+ $img_url = wr2x_cdn_this( $element->src );
204
+ $img_url = apply_filters( 'wr2x_img_url', $img_url );
205
+ if ( $lazysize ) {
206
+ $element->class = $element->class . ' lazyload';
207
+ $element->{'data-srcset'} = "$img_url, $retina_url 2x";
208
+ }
209
+ else
210
+ $element->srcset = "$img_url, $retina_url 2x";
211
+ if ( $killsrc )
212
+ $element->src = null;
213
+ else {
214
+ $img_src = apply_filters( 'wr2x_img_src', $element->src );
215
+ $element->src = wr2x_cdn_this( $img_src );
216
+ }
217
+ $to = $element;
218
+ $buffer = str_replace( trim( $from, "</> "), trim( $to, "</> " ), $buffer );
219
+ wr2x_log( "The img tag '$from' was rewritten to '$to'" );
220
+ $nodes_replaced++;
221
+ }
222
+ else {
223
+ wr2x_log( "The img tag was not rewritten. No retina for '" . $element->src . "'." );
224
+ }
225
+ }
226
+ }
227
+ wr2x_log( "$nodes_replaced/$nodes_count img tags were replaced." );
228
+
229
+ // INLINE CSS BACKGROUND
230
+ if ( get_option( 'wr2x_picturefill_css_background', false ) && $wr2x_admin->is_pro() ) {
231
+ preg_match_all( "/url(?:\(['\"]?)(.*?)(?:['\"]?\))/", $buffer, $matches );
232
+ $match_css = $matches[0];
233
+ $match_url = $matches[1];
234
+ if ( count( $matches ) != 2 )
235
+ return $buffer;
236
+ $nodes_count = 0;
237
+ $nodes_replaced = 0;
238
+ for ( $c = 0; $c < count( $matches[0] ); $c++ ) {
239
+ $css = $match_css[$c];
240
+ $url = $match_url[$c];
241
+ if ( !wr2x_is_supported_image( $url ) )
242
+ continue;
243
+ $nodes_count++;
244
+ $retina_url = wr2x_get_retina_from_url( $url );
245
+ $retina_url = apply_filters( 'wr2x_img_retina_url', $retina_url );
246
+ if ( $retina_url != null ) {
247
+ $retina_url = wr2x_cdn_this( $retina_url );
248
+ $minibuffer = str_replace( $url, $retina_url, $css );
249
+ $buffer = str_replace( $css, $minibuffer, $buffer );
250
+ wr2x_log( "The background src '$css' was rewritten to '$minibuffer'" );
251
+ $nodes_replaced++;
252
+ }
253
+ else {
254
+ wr2x_log( "The background src was not rewritten. No retina for '" . $url . "'." );
255
+ }
256
+ }
257
+ wr2x_log( "$nodes_replaced/$nodes_count background src were replaced." );
258
+ }
259
+
260
+ return $buffer;
261
+ }
262
+
263
+ /**
264
+ *
265
+ * HTML REWRITE METHOD
266
+ *
267
+ */
268
+
269
+ function wr2x_buffer_start () {
270
+ ob_start( "wr2x_html_rewrite" );
271
+ wr2x_log( "* HTML REWRITE" );
272
+ }
273
+
274
+ function wr2x_buffer_end () {
275
+ ob_end_flush();
276
+ }
277
+
278
+ // Replace the images by retina images (if available)
279
+ function wr2x_html_rewrite( $buffer ) {
280
+ if ( !isset( $buffer ) || trim( $buffer ) === '' )
281
+ return $buffer;
282
+ $nodes_count = 0;
283
+ $nodes_replaced = 0;
284
+ $doc = new DOMDocument();
285
+ @$doc->loadHTML( $buffer ); // = ($doc->strictErrorChecking = false;)
286
+ $imageTags = $doc->getElementsByTagName('img');
287
+ foreach ( $imageTags as $tag ) {
288
+ $nodes_count++;
289
+ $img_pathinfo = wr2x_get_pathinfo_from_image_src( $tag->getAttribute('src') );
290
+ $filepath = trailingslashit( wr2x_get_upload_root() ) . $img_pathinfo;
291
+ $system_retina = wr2x_get_retina( $filepath );
292
+ if ( $system_retina != null ) {
293
+ $retina_pathinfo = wr2x_cdn_this( ltrim( str_replace( wr2x_get_upload_root(), "", $system_retina ), '/' ) );
294
+ $buffer = str_replace( $img_pathinfo, $retina_pathinfo, $buffer );
295
+ wr2x_log( "The img src '$img_pathinfo' was replaced by '$retina_pathinfo'" );
296
+ $nodes_replaced++;
297
+ }
298
+ else {
299
+ wr2x_log( "The file '$system_retina' was not found. Tag not modified." );
300
+ }
301
+ }
302
+ wr2x_log( "$nodes_replaced/$nodes_count were replaced." );
303
+ return $buffer;
304
+ }
305
+
306
+
307
+ // Converts PHP INI size type (e.g. 24M) to int
308
+ function wr2x_parse_ini_size( $size ) {
309
+ $unit = preg_replace('/[^bkmgtpezy]/i', '', $size);
310
+ $size = preg_replace('/[^0-9\.]/', '', $size);
311
+ if ( $unit )
312
+ return round( $size * pow( 1024, stripos( 'bkmgtpezy', $unit[0] ) ) );
313
+ else
314
+ round( $size );
315
+ }
316
+
317
+ function wr2x_get_max_filesize() {
318
+ if ( defined ('HHVM_VERSION' ) ) {
319
+ return ini_get( 'upload_max_filesize' ) ? (int)wr2x_parse_ini_size( ini_get( 'upload_max_filesize' ) ) :
320
+ (int)ini_get( 'hhvm.server.upload.upload_max_file_size' );
321
+ }
322
+ else {
323
+ return (int)wr2x_parse_ini_size( ini_get( 'upload_max_filesize' ) );
324
+ }
325
+ }
326
+
327
+ /**
328
+ *
329
+ * ISSUES CALCULATION AND FUNCTIONS
330
+ *
331
+ */
332
+
333
+ // Compares two images dimensions (resolutions) against each while accepting an margin error
334
+ function wr2x_are_dimensions_ok( $width, $height, $retina_width, $retina_height ) {
335
+ $w_margin = $width - $retina_width;
336
+ $h_margin = $height - $retina_height;
337
+ return ( $w_margin >= -2 && $h_margin >= -2 );
338
+ }
339
+
340
+ // UPDATE THE ISSUE STATUS OF THIS ATTACHMENT
341
+ function wr2x_update_issue_status( $attachmentId, $issues = null, $info = null ) {
342
+ if ( wr2x_is_ignore( $attachmentId ) )
343
+ return;
344
+ if ( $issues == null )
345
+ $issues = wr2x_get_issues();
346
+ if ( $info == null )
347
+ $info = wr2x_retina_info( $attachmentId );
348
+ $consideredIssue = in_array( $attachmentId, $issues );
349
+ $realIssue = wr2x_info_has_issues( $info );
350
+ if ( $consideredIssue && !$realIssue )
351
+ wr2x_remove_issue( $attachmentId );
352
+ else if ( !$consideredIssue && $realIssue )
353
+ wr2x_add_issue( $attachmentId );
354
+ return $realIssue;
355
+ }
356
+
357
+ function wr2x_get_issues() {
358
+ $issues = get_transient( 'wr2x_issues' );
359
+ if ( !$issues || !is_array( $issues ) ) {
360
+ $issues = array();
361
+ set_transient( 'wr2x_issues', $issues );
362
+ }
363
+ return $issues;
364
+ }
365
+
366
+ // CHECK IF THE 'INFO' OBJECT CONTAINS ISSUE (RETURN TRUE OR FALSE)
367
+ function wr2x_info_has_issues( $info ) {
368
+ foreach ( $info as $aindex => $aval ) {
369
+ if ( is_array( $aval ) || $aval == 'PENDING' )
370
+ return true;
371
+ }
372
+ return false;
373
+ }
374
+
375
+ function wr2x_calculate_issues() {
376
+ global $wpdb;
377
+ $postids = $wpdb->get_col( "
378
+ SELECT p.ID FROM $wpdb->posts p
379
+ WHERE post_status = 'inherit'
380
+ AND post_type = 'attachment'" . wr2x_create_sql_if_wpml_original() . "
381
+ AND ( post_mime_type = 'image/jpeg' OR
382
+ post_mime_type = 'image/jpg' OR
383
+ post_mime_type = 'image/png' OR
384
+ post_mime_type = 'image/gif' )
385
+ " );
386
+ $issues = array();
387
+ foreach ( $postids as $id ) {
388
+ $info = wr2x_retina_info( $id );
389
+ if ( wr2x_info_has_issues( $info ) )
390
+ array_push( $issues, $id );
391
+
392
+ }
393
+ set_transient( 'wr2x_ignores', array() );
394
+ set_transient( 'wr2x_issues', $issues );
395
+ }
396
+
397
+ function wr2x_add_issue( $attachmentId ) {
398
+ if ( wr2x_is_ignore( $attachmentId ) )
399
+ return;
400
+ $issues = wr2x_get_issues();
401
+ if ( !in_array( $attachmentId, $issues ) ) {
402
+ array_push( $issues, $attachmentId );
403
+ set_transient( 'wr2x_issues', $issues );
404
+ }
405
+ return $issues;
406
+ }
407
+
408
+ function wr2x_remove_issue( $attachmentId, $onlyIgnore = false ) {
409
+ $issues = array_diff( wr2x_get_issues(), array( $attachmentId ) );
410
+ set_transient( 'wr2x_issues', $issues );
411
+ if ( !$onlyIgnore )
412
+ wr2x_remove_ignore( $attachmentId );
413
+ return $issues;
414
+ }
415
+
416
+ // IGNORE
417
+
418
+ function wr2x_get_ignores( $force = false ) {
419
+ $ignores = get_transient( 'wr2x_ignores' );
420
+ if ( !$ignores || !is_array( $ignores ) ) {
421
+ $ignores = array();
422
+ set_transient( 'wr2x_ignores', $ignores );
423
+ }
424
+ return $ignores;
425
+ }
426
+
427
+ function wr2x_is_ignore( $attachmentId ) {
428
+ $ignores = wr2x_get_ignores();
429
+ return in_array( $attachmentId, wr2x_get_ignores() );
430
+ }
431
+
432
+ function wr2x_remove_ignore( $attachmentId ) {
433
+ $ignores = wr2x_get_ignores();
434
+ $ignores = array_diff( $ignores, array( $attachmentId ) );
435
+ set_transient( 'wr2x_ignores', $ignores );
436
+ return $ignores;
437
+ }
438
+
439
+ function wr2x_add_ignore( $attachmentId ) {
440
+ $ignores = wr2x_get_ignores();
441
+ if ( !in_array( $attachmentId, $ignores ) ) {
442
+ array_push( $ignores, $attachmentId );
443
+ set_transient( 'wr2x_ignores', $ignores );
444
+ }
445
+ wr2x_remove_issue( $attachmentId, true );
446
+ return $ignores;
447
+ }
448
+
449
+ /**
450
+ *
451
+ * INFORMATION ABOUT THE RETINA IMAGE IN HTML
452
+ *
453
+ */
454
+
455
+ function wpr2x_html_get_basic_retina_info_full( $attachmentId, $retina_info ) {
456
+ $status = ( isset( $retina_info ) && isset( $retina_info['full-size'] ) ) ? $retina_info['full-size'] : 'IGNORED';
457
+ if ( $status == 'EXISTS' ) {
458
+ return '<ul class="meow-sized-images"><li class="meow-bk-blue" title="full-size"></li></ul>';
459
+ }
460
+ else if ( is_array( $status ) ) {
461
+ return '<ul class="meow-sized-images"><li class="meow-bk-orange" title="full-size"></li></ul>';
462
+ }
463
+ else if ( $status == 'IGNORED' ) {
464
+ return __( "N/A", "wp-retina-2x" );
465
+ }
466
+ return $status;
467
+ }
468
+
469
+ function wr2x_format_title( $i, $size ) {
470
+ return $i . ' (' . ( $size['width'] * 2 ) . 'x' . ( $size['height'] * 2 ) . ')';
471
+ }
472
+
473
+ // Information for the 'Media Sizes Retina-ized' Column in the Retina Dashboard
474
+ function wpr2x_html_get_basic_retina_info( $attachmentId, $retina_info ) {
475
+ $sizes = wr2x_get_active_image_sizes();
476
+ $result = '<ul class="meow-sized-images" postid="' . ( is_integer( $attachmentId ) ? $attachmentId : $attachmentId->ID ) . '">';
477
+ foreach ( $sizes as $i => $size ) {
478
+ $status = ( isset( $retina_info ) && isset( $retina_info[$i] ) ) ? $retina_info[$i] : null;
479
+ if ( is_array( $status ) )
480
+ $result .= '<li class="meow-bk-red" title="' . wr2x_format_title( $i, $size ) . '">'
481
+ . Meow_Admin::size_shortname( $i ) . '</li>';
482
+ else if ( $status == 'EXISTS' )
483
+ $result .= '<li class="meow-bk-blue" title="' . wr2x_format_title( $i, $size ) . '">'
484
+ . Meow_Admin::size_shortname( $i ) . '</li>';
485
+ else if ( $status == 'PENDING' )
486
+ $result .= '<li class="meow-bk-orange" title="' . wr2x_format_title( $i, $size ) . '">'
487
+ . Meow_Admin::size_shortname( $i ) . '</li>';
488
+ else if ( $status == 'MISSING' )
489
+ $result .= '<li class="meow-bk-red" title="' . wr2x_format_title( $i, $size ) . '">'
490
+ . Meow_Admin::size_shortname( $i ) . '</li>';
491
+ else if ( $status == 'IGNORED' )
492
+ $result .= '<li class="meow-bk-gray" title="' . wr2x_format_title( $i, $size ) . '">'
493
+ . Meow_Admin::size_shortname( $i ) . '</li>';
494
+ else {
495
+ error_log( "Retina: This status is not recognized: " . $status );
496
+ }
497
+ }
498
+ $result .= '</ul>';
499
+ return $result;
500
+ }
501
+
502
+ // Information for Details in the Retina Dashboard
503
+ function wpr2x_html_get_details_retina_info( $post, $retina_info ) {
504
+ global $wr2x_admin;
505
+ if ( !$wr2x_admin->is_pro() ) {
506
+ return __( "PRO VERSION ONLY", 'wp-retina-2x' );
507
+ }
508
+
509
+ $sizes = wr2x_get_image_sizes();
510
+ $total = 0; $possible = 0; $issue = 0; $ignored = 0; $retina = 0;
511
+
512
+ $postinfo = get_post( $post, OBJECT );
513
+ $meta = wp_get_attachment_metadata( $post );
514
+ $fullsize_file = get_attached_file( $post );
515
+ $pathinfo_system = pathinfo( $fullsize_file );
516
+ $pathinfo = pathinfo( $meta['file'] );
517
+ $uploads = wp_upload_dir();
518
+ $basepath_url = trailingslashit( $uploads['baseurl'] ) . $pathinfo['dirname'];
519
+ if ( get_option( "wr2x_full_size" ) ) {
520
+ $sizes['full-size']['file'] = $pathinfo['basename'];
521
+ $sizes['full-size']['width'] = $meta['width'];
522
+ $sizes['full-size']['height'] = $meta['height'];
523
+ $meta['sizes']['full-size']['file'] = $pathinfo['basename'];
524
+ $meta['sizes']['full-size']['width'] = $meta['width'];
525
+ $meta['sizes']['full-size']['height'] = $meta['height'];
526
+ }
527
+ $result = "<p>This screen displays all the image sizes set-up by your WordPress configuration with the Retina details.</p>";
528
+ $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'>";
529
+ $result .= "Title: <b>" . ( $postinfo->post_title ? $postinfo->post_title : '<i>Untitled</i>' ) . "</b><br />";
530
+ $result .= "Full-size: <b>" . $meta['width'] . "×" . $meta['height'] . "</b><br />";
531
+ $result .= "Image URL: <a target='_blank' href='" . trailingslashit( $uploads['baseurl'] ) . $meta['file'] . "'>" . trailingslashit( $uploads['baseurl'] ) . $meta['file'] . "</a><br />";
532
+ $result .= "Image Path: " . $fullsize_file . "<br />";
533
+ $result .= "</div><div style='clear: both;'></div><br />";
534
+ $result .= "<div class='scrollable-info'>";
535
+
536
+ foreach ( $sizes as $i => $sizemeta ) {
537
+ $total++;
538
+ $normal_file_system = ""; $retina_file_system = "";
539
+ $normal_file = ""; $retina_file = ""; $width = ""; $height = "";
540
+
541
+ if ( isset( $retina_info[$i] ) && $retina_info[$i] == 'IGNORED' ) {
542
+ $status = "IGNORED";
543
+ }
544
+ else if ( !isset( $meta['sizes'] ) ) {
545
+ $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' );
546
+ $status = "MISSING";
547
+ }
548
+ else if ( !isset( $meta['sizes'][$i] ) ) {
549
+ $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 );
550
+ $status = "MISSING";
551
+ }
552
+ else {
553
+ $normal_file_system = trailingslashit( $pathinfo_system['dirname'] ) . $meta['sizes'][$i]['file'];
554
+ $retina_file_system = wr2x_get_retina( $normal_file_system );
555
+ $normal_file = trailingslashit( $basepath_url ) . $meta['sizes'][$i]['file'];
556
+ $retina_file = wr2x_get_retina_from_url( $normal_file );
557
+ $status = ( isset( $retina_info ) && isset( $retina_info[$i] ) ) ? $retina_info[$i] : null;
558
+ $width = $meta['sizes'][$i]['width'];
559
+ $height = $meta['sizes'][$i]['height'];
560
+ }
561
+
562
+ $result .= "<h3>";
563
+
564
+ // Status Icon
565
+ if ( is_array( $status ) && $i == 'full-size' ) {
566
+ $result .= '<div class="meow-sized-image meow-bk-red"></div>';
567
+ $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'] );
568
+ }
569
+ else if ( is_array( $status ) ) {
570
+ $result .= '<div class="meow-sized-image meow-bk-red"></div>';
571
+ $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'] );
572
+ $issue++;
573
+ }
574
+ else if ( $status == 'EXISTS' ) {
575
+ $result .= '<div class="meow-sized-image meow-bk-blue"></div>';
576
+ $statusText = "";
577
+ $retina++;
578
+ }
579
+ else if ( $status == 'PENDING' ) {
580
+ $result .= '<div class="meow-sized-image meow-bk-orange"></div>';
581
+ $statusText = __( "The retina image can be created. Please use the 'GENERATE' button.", 'wp-retina-2x' );
582
+ $possible++;
583
+ }
584
+ else if ( $status == 'MISSING' ) {
585
+ $result .= '<div class="meow-sized-image meow-bk-gray"></div>';
586
+ $statusText = __( "The standard image normally created by WordPress is missing.", 'wp-retina-2x' );
587
+ $total--;
588
+ }
589
+ else if ( $status == 'IGNORED' ) {
590
+ $result .= '<div class="meow-sized-image meow-bk-gray"></div>';
591
+ $statusText = __( "This size is ignored by your retina settings.", 'wp-retina-2x' );
592
+ $ignored++;
593
+ $total--;
594
+ }
595
+
596
+ $result .= "&nbsp;Size: $i</h3><p>$statusText</p>";
597
+
598
+ if ( !is_array( $status ) && $status !== 'IGNORED' && $status !== 'MISSING' ) {
599
+ $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>";
600
+ $result .= "<p><small>";
601
+ $result .= "Image URL: <a target='_blank' href='$normal_file'>$normal_file</a><br />";
602
+ $result .= "Retina URL: <a target='_blank' href='$retina_file'>$retina_file</a><br />";
603
+ $result .= "Image Path: $normal_file_system<br />";
604
+ $result .= "Retina Path: $retina_file_system<br />";
605
+ $result .= "</small></p>";
606
+ }
607
+ }
608
+ $result .= "</table>";
609
+ $result .= "</div>";
610
+ return $result;
611
+ }
612
+
613
+ /**
614
+ *
615
+ * WP RETINA 2X CORE
616
+ *
617
+ */
618
+
619
+ // Get WordPress upload directory
620
+ function wr2x_get_upload_root() {
621
+ $uploads = wp_upload_dir();
622
+ return $uploads['basedir'];
623
+ }
624
+
625
+ function wr2x_get_upload_root_url() {
626
+ $uploads = wp_upload_dir();
627
+ return $uploads['baseurl'];
628
+ }
629
+
630
+ // Get WordPress directory
631
+ function wr2x_get_wordpress_root() {
632
+ return ABSPATH;
633
+ }
634
+
635
+ // Return the retina file if there is any (system path)
636
+ function wr2x_get_retina( $file ) {
637
+ $pathinfo = pathinfo( $file ) ;
638
+ if ( empty( $pathinfo ) || !isset( $pathinfo['dirname'] ) ) {
639
+ if ( empty( $file ) ) {
640
+ wr2x_log( "An empty filename was given to wr2x_get_retina()." );
641
+ error_log( "An empty filename was given to wr2x_get_retina()." );
642
+ }
643
+ else {
644
+ wr2x_log( "Pathinfo is null for " . $file . "." );
645
+ error_log( "Pathinfo is null for " . $file . "." );
646
+ }
647
+ return null;
648
+ }
649
+ $retina_file = trailingslashit( $pathinfo['dirname'] ) . $pathinfo['filename'] .
650
+ wr2x_retina_extension() . ( isset( $pathinfo['extension'] ) ? $pathinfo['extension'] : "" );
651
+ if ( file_exists( $retina_file ) )
652
+ return $retina_file;
653
+ wr2x_log( "Retina file at '{$retina_file}' does not exist." );
654
+ return null;
655
+ }
656
+
657
+ function wr2x_get_retina_from_remote_url( $url ) {
658
+ global $wr2x_admin;
659
+ $over_http = get_option( 'wr2x_over_http_check', false ) && $wr2x_admin->is_pro();
660
+ if ( !$over_http )
661
+ return null;
662
+ $potential_retina_url = wr2x_rewrite_url_to_retina( $url );
663
+ $response = wp_remote_head( $potential_retina_url, array(
664
+ 'user-agent' => "MeowApps-Retina",
665
+ 'sslverify' => false,
666
+ 'timeout' => 10
667
+ ));
668
+ if ( is_array( $response ) && is_array( $response['response'] ) && isset( $response['response']['code'] ) ) {
669
+ if ( $response['response']['code'] == 200 ) {
670
+ wr2x_log( "Retina URL: " . $potential_retina_url, true);
671
+ return $potential_retina_url;
672
+ }
673
+ else
674
+ wr2x_log( "Remote head failed with code " . $response['response']['code'] . "." );
675
+ }
676
+ wr2x_log( "Retina URL couldn't be found (URL -> Retina URL).", true);
677
+ }
678
+
679
+ // Return retina URL from the image URL
680
+ function wr2x_get_retina_from_url( $url ) {
681
+ wr2x_log( "Standard URL: " . $url, true);
682
+ global $wr2x_admin;
683
+ $over_http = get_option( 'wr2x_over_http_check', false ) && $wr2x_admin->is_pro();
684
+ $filepath = wr2x_from_url_to_system( $url );
685
+ if ( empty ( $filepath ) )
686
+ return wr2x_get_retina_from_remote_url( $url );
687
+ wr2x_log( "Standard PATH: " . $filepath, true);
688
+ $system_retina = wr2x_get_retina( $filepath );
689
+ if ( empty ( $system_retina ) )
690
+ return wr2x_get_retina_from_remote_url( $url );
691
+ wr2x_log( "Retina PATH: " . $system_retina, true);
692
+ $retina_url = wr2x_rewrite_url_to_retina( $url );
693
+ wr2x_log( "Retina URL: " . $retina_url, true);
694
+ return $retina_url;
695
+ }
696
+
697
+ // Get the filepath from the URL
698
+ function wr2x_from_url_to_system( $url ) {
699
+ $img_pathinfo = wr2x_get_pathinfo_from_image_src( $url );
700
+ $filepath = trailingslashit( wr2x_get_wordpress_root() ) . $img_pathinfo;
701
+ if ( file_exists( $filepath ) )
702
+ return $filepath;
703
+ $filepath = trailingslashit( wr2x_get_upload_root() ) . $img_pathinfo;
704
+ if ( file_exists( $filepath ) )
705
+ return $filepath;
706
+ wr2x_log( "Standard PATH couldn't be found (URL -> System).", true);
707
+ return null;
708
+ }
709
+
710
+ function wr2x_rewrite_url_to_retina( $url ) {
711
+ $whereisdot = strrpos( $url, '.' );
712
+ $url = substr( $url, 0, $whereisdot ) . wr2x_retina_extension() . substr( $url, $whereisdot + 1 );
713
+ return $url;
714
+ }
715
+
716
+ // Clean the PathInfo of the IMG SRC.
717
+ // IMPORTANT: This function STRIPS THE UPLOAD FOLDER if it's found
718
+ // REASON: The reason is that on some installs the uploads folder is linked to a different "unlogical" physical folder
719
+ // http://wordpress.org/support/topic/cant-find-retina-file-with-custom-uploads-constant?replies=3#post-5078892
720
+ function wr2x_get_pathinfo_from_image_src( $image_src ) {
721
+ $uploads_url = trailingslashit( wr2x_get_upload_root_url() );
722
+ if ( strpos( $image_src, $uploads_url ) === 0 )
723
+ return ltrim( substr( $image_src, strlen( $uploads_url ) ), '/');
724
+ else if ( strpos( $image_src, wp_make_link_relative( $uploads_url ) ) === 0 )
725
+ return ltrim( substr( $image_src, strlen( wp_make_link_relative( $uploads_url ) ) ), '/');
726
+ $img_info = parse_url( $image_src );
727
+ return ltrim( $img_info['path'], '/' );
728
+ }
729
+
730
+ // Rename this filename with CDN
731
+ function wr2x_cdn_this( $url ) {
732
+ global $wr2x_admin;
733
+ $cdn_domain = "";
734
+ if ( $wr2x_admin->is_pro() )
735
+ $cdn_domain = get_option( "wr2x_cdn_domain" );
736
+ if ( empty( $cdn_domain ) )
737
+ return $url;
738
+
739
+ $home_url = parse_url( home_url() );
740
+ $uploads_url = trailingslashit( wr2x_get_upload_root_url() );
741
+ $uploads_url_cdn = str_replace( $home_url['host'], $cdn_domain, $uploads_url );
742
+ // Perform additional CDN check (Issue #1631 by Martin)
743
+ if ( strpos( $url, $uploads_url_cdn ) === 0 ) {
744
+ wr2x_log( "URL already has CDN: $url" );
745
+ return $url;
746
+ }
747
+ wr2x_log( "URL before CDN: $url" );
748
+ $site_url = preg_replace( '#^https?://#', '', rtrim( get_site_url(), '/' ) );
749
+ $new_url = str_replace( $site_url, $cdn_domain, $url );
750
+ wr2x_log( "URL with CDN: $new_url" );
751
+ return $new_url;
752
+ }
753
+
754
+ // function wr2x_admin_menu() {
755
+ // add_options_page( 'Retina', 'Retina', 'manage_options', 'wr2x_settings', 'wr2x_settings_page' );
756
+ // }
757
+
758
+ function wr2x_get_image_sizes() {
759
+ $sizes = array();
760
+ global $_wp_additional_image_sizes;
761
+ foreach ( get_intermediate_image_sizes() as $s ) {
762
+ $crop = false;
763
+ if ( isset( $_wp_additional_image_sizes[$s] ) ) {
764
+ $width = intval($_wp_additional_image_sizes[$s]['width']);
765
+ $height = intval($_wp_additional_image_sizes[$s]['height']);
766
+ $crop = $_wp_additional_image_sizes[$s]['crop'];
767
+ } else {
768
+ $width = get_option( $s . '_size_w' );
769
+ $height = get_option( $s . '_size_h' );
770
+ $crop = get_option( $s . '_crop' );
771
+ }
772
+ $sizes[$s] = array( 'width' => $width, 'height' => $height, 'crop' => $crop );
773
+ }
774
+ if ( get_option( 'wr2x_disable_medium_large' ) )
775
+ unset( $sizes['medium_large'] );
776
+ return $sizes;
777
+ }
778
+
779
+ function wr2x_get_active_image_sizes() {
780
+ $sizes = wr2x_get_image_sizes();
781
+ $active_sizes = array();
782
+ $ignore = get_option( "wr2x_ignore_sizes", array() );
783
+ if ( empty( $ignore ) )
784
+ $ignore = array();
785
+ $ignore = array_keys( $ignore );
786
+ foreach ( $sizes as $name => $attr ) {
787
+ $validSize = !empty( $attr['width'] ) || !empty( $attr['height'] );
788
+ if ( $validSize && !in_array( $name, $ignore ) ) {
789
+ $active_sizes[$name] = $attr;
790
+ }
791
+ }
792
+ return $active_sizes;
793
+ }
794
+
795
+ function wr2x_is_wpml_installed() {
796
+ return function_exists( 'icl_object_id' ) && !class_exists( 'Polylang' );
797
+ }
798
+
799
+ // SQL Query if WPML with an AND to check if the p.ID (p is attachment) is indeed an original
800
+ // That is to limit the SQL that queries all the attachments
801
+ function wr2x_create_sql_if_wpml_original() {
802
+ $whereIsOriginal = "";
803
+ if ( wr2x_is_wpml_installed() ) {
804
+ global $wpdb;
805
+ global $sitepress;
806
+ $tbl_wpml = $wpdb->prefix . "icl_translations";
807
+ $language = $sitepress->get_default_language();
808
+ $whereIsOriginal = " AND p.ID IN (SELECT element_id FROM $tbl_wpml WHERE element_type = 'post_attachment' AND language_code = '$language') ";
809
+ }
810
+ return $whereIsOriginal;
811
+ }
812
+
813
+ function wr2x_is_debug() {
814
+ static $debug = -1;
815
+ if ( $debug == -1 ) {
816
+ $debug = get_option( "wr2x_debug" );
817
+ }
818
+ return !!$debug;
819
+ }
820
+
821
+ function wr2x_log( $data, $isExtra = false ) {
822
+ global $wr2x_extra_debug;
823
+ if ( !wr2x_is_debug() )
824
+ return;
825
+ $fh = fopen( trailingslashit( WP_PLUGIN_DIR ) . 'wp-retina-2x/wp-retina-2x.log', 'a' );
826
+ $date = date( "Y-m-d H:i:s" );
827
+ fwrite( $fh, "$date: {$data}\n" );
828
+ fclose( $fh );
829
+ }
830
+
831
+ // Based on http://wordpress.stackexchange.com/questions/6645/turn-a-url-into-an-attachment-post-id
832
+ function wr2x_get_attachment_id( $file ) {
833
+ $query = array(
834
+ 'post_type' => 'attachment',
835
+ 'meta_query' => array(
836
+ array(
837
+ 'key' => '_wp_attached_file',
838
+ 'value' => ltrim( $file, '/' )
839
+ )
840
+ )
841
+ );
842
+ $posts = get_posts( $query );
843
+ foreach( $posts as $post )
844
+ return $post->ID;
845
+ return false;
846
+ }
847
+
848
+ // Return the retina extension followed by a dot
849
+ function wr2x_retina_extension() {
850
+ return '@2x.';
851
+ }
852
+
853
+ function wr2x_is_image_meta( $meta ) {
854
+ if ( !isset( $meta ) )
855
+ return false;
856
+ if ( !isset( $meta['sizes'] ) )
857
+ return false;
858
+ if ( !isset( $meta['width'], $meta['height'] ) )
859
+ return false;
860
+ return true;
861
+ }
862
+
863
+ function wr2x_retina_info( $id ) {
864
+ global $wr2x_admin;
865
+ $result = array();
866
+ $meta = wp_get_attachment_metadata( $id );
867
+ if ( !wr2x_is_image_meta( $meta ) )
868
+ return $result;
869
+ $original_width = $meta['width'];
870
+ $original_height = $meta['height'];
871
+ $sizes = wr2x_get_image_sizes();
872
+ $required_files = true;
873
+ $originalfile = get_attached_file( $id );
874
+ $pathinfo = pathinfo( $originalfile );
875
+ $basepath = $pathinfo['dirname'];
876
+ $ignore = get_option( "wr2x_ignore_sizes", array() );
877
+ if ( empty( $ignore ) )
878
+ $ignore = array();
879
+ $ignore = array_keys( $ignore );
880
+
881
+ // Full-Size (if required in the settings)
882
+ $fullsize_required = get_option( "wr2x_full_size" ) && $wr2x_admin->is_pro();
883
+ $retina_file = trailingslashit( $pathinfo['dirname'] ) . $pathinfo['filename'] . wr2x_retina_extension() . $pathinfo['extension'];
884
+ if ( $retina_file && file_exists( $retina_file ) )
885
+ $result['full-size'] = 'EXISTS';
886
+ else if ( $fullsize_required && $retina_file )
887
+ $result['full-size'] = array( 'width' => $original_width * 2, 'height' => $original_height * 2 );
888
+ //}
889
+
890
+ if ( $sizes ) {
891
+ foreach ( $sizes as $name => $attr ) {
892
+ $validSize = !empty( $attr['width'] ) || !empty( $attr['height'] );
893
+ if ( !$validSize || in_array( $name, $ignore ) ) {
894
+ $result[$name] = 'IGNORED';
895
+ continue;
896
+ }
897
+ // Check if the file related to this size is present
898
+ $pathinfo = null;
899
+ $retina_file = null;
900
+
901
+ 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'] ) ) {
902
+ $normal_file = trailingslashit( $basepath ) . $meta['sizes'][$name]['file'];
903
+ $pathinfo = pathinfo( $normal_file ) ;
904
+ $retina_file = trailingslashit( $pathinfo['dirname'] ) . $pathinfo['filename'] . wr2x_retina_extension() . $pathinfo['extension'];
905
+ }
906
+ // None of the file exist
907
+ else {
908
+ $result[$name] = 'MISSING';
909
+ $required_files = false;
910
+ continue;
911
+ }
912
+
913
+ // The retina file exists
914
+ if ( $retina_file && file_exists( $retina_file ) ) {
915
+ $result[$name] = 'EXISTS';
916
+ continue;
917
+ }
918
+ // The size file exists
919
+ else if ( $retina_file )
920
+ $result[$name] = 'PENDING';
921
+
922
+ // The retina file exists
923
+ $required_width = $meta['sizes'][$name]['width'] * 2;
924
+ $required_height = $meta['sizes'][$name]['height'] * 2;
925
+ if ( !wr2x_are_dimensions_ok( $original_width, $original_height, $required_width, $required_height ) ) {
926
+ $result[$name] = array( 'width' => $required_width, 'height' => $required_height );
927
+ }
928
+ }
929
+ }
930
+ return $result;
931
+ }
932
+
933
+ function wr2x_delete_attachment( $attach_id, $deleteFullSize = true ) {
934
+ $meta = wp_get_attachment_metadata( $attach_id );
935
+ wr2x_delete_images( $meta, $deleteFullSize );
936
+ wr2x_remove_issue( $attach_id );
937
+ }
938
+
939
+ function wr2x_wp_generate_attachment_metadata( $meta ) {
940
+ if ( get_option( "wr2x_auto_generate" ) == true )
941
+ if ( wr2x_is_image_meta( $meta ) )
942
+ wr2x_generate_images( $meta );
943
+ return $meta;
944
+ }
945
+
946
+ function wr2x_generate_images( $meta ) {
947
+ require( 'wr2x_vt_resize.php' );
948
+ global $_wp_additional_image_sizes;
949
+ $sizes = wr2x_get_image_sizes();
950
+ if ( !isset( $meta['file'] ) )
951
+ return;
952
+ $originalfile = $meta['file'];
953
+ $uploads = wp_upload_dir();
954
+ $pathinfo = pathinfo( $originalfile );
955
+ $original_basename = $pathinfo['basename'];
956
+ $basepath = trailingslashit( $uploads['basedir'] ) . $pathinfo['dirname'];
957
+ $ignore = get_option( "wr2x_ignore_sizes" );
958
+ if ( empty( $ignore ) )
959
+ $ignore = array();
960
+ $ignore = array_keys( $ignore );
961
+ $issue = false;
962
+ $id = wr2x_get_attachment_id( $meta['file'] );
963
+
964
+ wr2x_log("* GENERATE RETINA FOR ATTACHMENT '{$meta['file']}'");
965
+ wr2x_log( "Full-Size is {$original_basename}." );
966
+
967
+ foreach ( $sizes as $name => $attr ) {
968
+ $normal_file = "";
969
+ if ( in_array( $name, $ignore ) ) {
970
+ wr2x_log( "Retina for {$name} ignored (settings)." );
971
+ continue;
972
+ }
973
+ // Is the file related to this size there?
974
+ $pathinfo = null;
975
+ $retina_file = null;
976
+
977
+ if ( isset( $meta['sizes'][$name] ) && isset( $meta['sizes'][$name]['file'] ) ) {
978
+ $normal_file = trailingslashit( $basepath ) . $meta['sizes'][$name]['file'];
979
+ $pathinfo = pathinfo( $normal_file ) ;
980
+ $retina_file = trailingslashit( $pathinfo['dirname'] ) . $pathinfo['filename'] . wr2x_retina_extension() . $pathinfo['extension'];
981
+ }
982
+
983
+ if ( $retina_file && file_exists( $retina_file ) ) {
984
+ wr2x_log( "Base for {$name} is '{$normal_file }'." );
985
+ wr2x_log( "Retina for {$name} already exists: '$retina_file'." );
986
+ continue;
987
+ }
988
+ if ( $retina_file ) {
989
+ $originalfile = trailingslashit( $pathinfo['dirname'] ) . $original_basename;
990
+
991
+ if ( !file_exists( $originalfile ) ) {
992
+ wr2x_log( "[ERROR] Original file '{$originalfile}' cannot be found." );
993
+ return $meta;
994
+ }
995
+
996
+ // Maybe that new image is exactly the size of the original image.
997
+ // In that case, let's make a copy of it.
998
+ if ( $meta['sizes'][$name]['width'] * 2 == $meta['width'] && $meta['sizes'][$name]['height'] * 2 == $meta['height'] ) {
999
+ copy ( $originalfile, $retina_file );
1000
+ wr2x_log( "Retina for {$name} created: '{$retina_file}' (as a copy of the full-size)." );
1001
+ }
1002
+ // Otherwise let's resize (if the original size is big enough).
1003
+ else if ( wr2x_are_dimensions_ok( $meta['width'], $meta['height'], $meta['sizes'][$name]['width'] * 2, $meta['sizes'][$name]['height'] * 2 ) ) {
1004
+ // Change proposed by Nicscott01, slighlty modified by Jordy (+isset)
1005
+ // (https://wordpress.org/support/topic/issue-with-crop-position?replies=4#post-6200271)
1006
+ $crop = isset( $_wp_additional_image_sizes[$name] ) ? $_wp_additional_image_sizes[$name]['crop'] : true;
1007
+ $customCrop = null;
1008
+
1009
+ // Support for Manual Image Crop
1010
+ // If the size of the image was manually cropped, let's keep it.
1011
+ if ( class_exists( 'ManualImageCrop' ) && isset( $meta['micSelectedArea'] ) && isset( $meta['micSelectedArea'][$name] ) && isset( $meta['micSelectedArea'][$name]['scale'] ) ) {
1012
+ $customCrop = $meta['micSelectedArea'][$name];
1013
+ }
1014
+ $image = wr2x_vt_resize( $originalfile, $meta['sizes'][$name]['width'] * 2,
1015
+ $meta['sizes'][$name]['height'] * 2, $crop, $retina_file, $customCrop );
1016
+ }
1017
+ if ( !file_exists( $retina_file ) ) {
1018
+ wr2x_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 . "." );
1019
+ $issue = true;
1020
+ }
1021
+ else {
1022
+ do_action( 'wr2x_retina_file_added', $id, $retina_file, $name );
1023
+ wr2x_log( "Retina for {$name} created: '{$retina_file}'." );
1024
+ }
1025
+ } else {
1026
+ if ( empty( $normal_file ) )
1027
+ wr2x_log( "[ERROR] Base file for '{$name}' does not exist." );
1028
+ else
1029
+ wr2x_log( "[ERROR] Base file for '{$name}' cannot be found here: '{$normal_file}'." );
1030
+ }
1031
+ }
1032
+
1033
+ // Checks attachment ID + issues
1034
+ if ( !$id )
1035
+ return $meta;
1036
+ if ( $issue )
1037
+ wr2x_add_issue( $id );
1038
+ else
1039
+ wr2x_remove_issue( $id );
1040
+ return $meta;
1041
+ }
1042
+
1043
+ function wr2x_delete_images( $meta, $deleteFullSize = false ) {
1044
+ if ( !wr2x_is_image_meta( $meta ) )
1045
+ return $meta;
1046
+ $sizes = $meta['sizes'];
1047
+ if ( !$sizes || !is_array( $sizes ) )
1048
+ return $meta;
1049
+ wr2x_log("* DELETE RETINA FOR ATTACHMENT '{$meta['file']}'");
1050
+ $originalfile = $meta['file'];
1051
+ $id = wr2x_get_attachment_id( $originalfile );
1052
+ $pathinfo = pathinfo( $originalfile );
1053
+ $uploads = wp_upload_dir();
1054
+ $basepath = trailingslashit( $uploads['basedir'] ) . $pathinfo['dirname'];
1055
+ foreach ( $sizes as $name => $attr ) {
1056
+ $pathinfo = pathinfo( $attr['file'] );
1057
+ $retina_file = $pathinfo['filename'] . wr2x_retina_extension() . $pathinfo['extension'];
1058
+ if ( file_exists( trailingslashit( $basepath ) . $retina_file ) ) {
1059
+ $fullpath = trailingslashit( $basepath ) . $retina_file;
1060
+ unlink( $fullpath );
1061
+ do_action( 'wr2x_retina_file_removed', $id, $retina_file );
1062
+ wr2x_log("Deleted '$fullpath'.");
1063
+ }
1064
+ }
1065
+ // Remove full-size if there is any
1066
+ if ( $deleteFullSize ) {
1067
+ $pathinfo = pathinfo( $originalfile );
1068
+ $retina_file = $pathinfo[ 'filename' ] . wr2x_retina_extension() . $pathinfo[ 'extension' ];
1069
+ if ( file_exists( trailingslashit( $basepath ) . $retina_file ) ) {
1070
+ $fullpath = trailingslashit( $basepath ) . $retina_file;
1071
+ unlink( $fullpath );
1072
+ do_action( 'wr2x_retina_file_removed', $id, $retina_file );
1073
+ wr2x_log( "Deleted '$fullpath'." );
1074
+ }
1075
+ }
1076
+ return $meta;
1077
+ }
1078
+
1079
+ function wr2x_activate() {
1080
+ global $wp_rewrite;
1081
+ $wp_rewrite->flush_rules();
1082
+ }
1083
+
1084
+ function wr2x_deactivate() {
1085
+ remove_filter( 'generate_rewrite_rules', array( 'WR2X_Admin', 'generate_rewrite_rules' ) );
1086
+ global $wp_rewrite;
1087
+ $wp_rewrite->flush_rules();
1088
+ }
1089
+
1090
+ /**
1091
+ *
1092
+ * FILTERS
1093
+ *
1094
+ */
1095
+
1096
+ function wr2x_validate_src( $src ) {
1097
+ if ( preg_match( "/^data:/i", $src ) )
1098
+ return null;
1099
+ return $src;
1100
+ }
1101
+
1102
+ /**
1103
+ *
1104
+ * LOAD SCRIPTS IF REQUIRED
1105
+ *
1106
+ */
1107
+
1108
+ function wr2x_wp_enqueue_scripts () {
1109
+ global $wr2x_version, $wr2x_retinajs, $wr2x_retina_image, $wr2x_picturefill, $wr2x_lazysizes;
1110
+ global $wr2x_admin;
1111
+ $method = get_option( "wr2x_method" );
1112
+
1113
+ if ( is_admin() && !get_option( "wr2x_retina_admin" ) )
1114
+ return;
1115
+
1116
+ // Picturefill
1117
+ if ( $method == "Picturefill" ) {
1118
+ if ( wr2x_is_debug() )
1119
+ wp_enqueue_script( 'wr2x-debug', plugins_url( '/js/debug.js', __FILE__ ), array(), $wr2x_version, false );
1120
+ // Picturefill
1121
+ if ( !get_option( "wr2x_picturefill_noscript" ) )
1122
+ wp_enqueue_script( 'picturefill', plugins_url( '/js/picturefill.min.js', __FILE__ ), array(), $wr2x_picturefill, false );
1123
+ // Lazysizes
1124
+ if ( get_option( "wr2x_picturefill_lazysizes" ) && $wr2x_admin->is_pro() )
1125
+ wp_enqueue_script( 'lazysizes', plugins_url( '/js/lazysizes.min.js', __FILE__ ), array(), $wr2x_lazysizes, false );
1126
+ return;
1127
+ }
1128
+
1129
+ // Debug + HTML Rewrite = No JS!
1130
+ if ( wr2x_is_debug() && $method == "HTML Rewrite" ) {
1131
+ return;
1132
+ }
1133
+
1134
+ // Debug mode, we force the devicePixelRatio to be Retina
1135
+ if ( wr2x_is_debug() )
1136
+ wp_enqueue_script( 'wr2x-debug', plugins_url( '/js/debug.js', __FILE__ ), array(), $wr2x_version, false );
1137
+ // Not Debug Mode + Ignore Mobile
1138
+ // else if ( get_option( "wr2x_ignore_mobile" ) ) {
1139
+ // $mobileDetect = new Mobile_Detect();
1140
+ // if ( $mobileDetect->isMobile() )
1141
+ // return;
1142
+ // }
1143
+
1144
+ // Retina-Images and HTML Rewrite both need the devicePixelRatio cookie on the server-side
1145
+ if ( $method == "Retina-Images" || $method == "HTML Rewrite" )
1146
+ wp_enqueue_script( 'retina-images', plugins_url( '/js/retina-cookie.js', __FILE__ ), array(), $wr2x_retina_image, false );
1147
+
1148
+ // Retina.js only needs itself
1149
+ if ($method == "retina.js")
1150
+ wp_enqueue_script( 'retinajs', plugins_url( '/js/retina.min.js', __FILE__ ), array(), $wr2x_retinajs, true );
1151
+ }
1152
+
1153
+ // Function still use by WP Rocket (and maybe another plugin as well)
1154
+ function wr2x_is_pro() {
1155
+ global $wr2x_admin;
1156
+ return $wr2x_admin->is_pro();
1157
+ }
1158
+
1159
+ ?>
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('./img/replace.png');
13
+ background-position: 5px 4px;
14
+ background-repeat: no-repeat;
15
+ }
16
+
17
+ .wr2x-loading-file .wr2x-title {
18
+ background: url('./img/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('./img/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
+ }
wr2x_admin.php ADDED
@@ -0,0 +1,463 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ include "common/meow_admin.php";
4
+
5
+ class WR2X_Admin extends Meow_Admin {
6
+
7
+ public function __construct() {
8
+ parent::__construct( 'wr2x', 'retina' );
9
+
10
+ $method = get_option( 'wr2x_method', 666 );
11
+ if ( $method == 666 )
12
+ $this->initial_setup();
13
+
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 ( delete_transient( 'wr2x_flush_rules' ) ) {
22
+ global $wp_rewrite;
23
+ WR2X_Admin::generate_rewrite_rules( $wp_rewrite, true );
24
+ }
25
+ if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) {
26
+ echo "<div class='error' style='margin-top: 20px;'><p>";
27
+ _e( "JetPack's <b>Photon</b> module is not compatible with WP Retina 2x. A common alternative is to use <a href='http://tracking.maxcdn.com/c/97349/3982/378'>MaxCDN</a> (very popular) instead, or CloudFlare.", 'wp-retina-2x' );
28
+ echo "</p></div>";
29
+ }
30
+ }
31
+
32
+ function initial_setup() {
33
+ $ignore_sizes = $this->old_getoption( 'ignore_sizes', 'wr2x_basics', array() );
34
+ update_option( 'wr2x_ignore_sizes', $ignore_sizes, false );
35
+ $auto_generate = $this->old_getoption( 'auto_generate', 'wr2x_basics', true );
36
+ update_option( 'wr2x_auto_generate', $auto_generate, true );
37
+ $method = $this->old_getoption( 'method', 'wr2x_advanced', 'Picturefill' );
38
+ update_option( 'wr2x_method', $method, true );
39
+ $full_size = $this->old_getoption( 'full_size', 'wr2x_basics', false );
40
+ update_option( 'wr2x_full_size', $full_size, false );
41
+ $disable_responsive = $this->old_getoption( 'disable_responsive', 'wr2x_basics', false );
42
+ update_option( 'wr2x_disable_responsive', $disable_responsive, false );
43
+ $disable_medium_large = $this->old_getoption( 'disable_medium_large', 'wr2x_basics', true );
44
+ update_option( 'wr2x_disable_medium_large', $disable_medium_large, false );
45
+ $debug = $this->old_getoption( 'debug', 'wr2x_advanced', false );
46
+ update_option( 'wr2x_debug', $debug, false );
47
+ $cdn_domain = $this->old_getoption( 'cdn_domain', 'wr2x_advanced', '' );
48
+ update_option( 'wr2x_cdn_domain', $cdn_domain, false );
49
+ $picturefill_keep_src = $this->old_getoption( 'picturefill_keep_src', 'wr2x_advanced', false );
50
+ update_option( 'wr2x_picturefill_keep_src', $picturefill_keep_src, false );
51
+ $picturefill_lazysizes = $this->old_getoption( 'picturefill_lazysizes', 'wr2x_advanced', false );
52
+ update_option( 'wr2x_picturefill_lazysizes', $picturefill_lazysizes, false );
53
+ $picturefill_noscript = $this->old_getoption( 'picturefill_noscript', 'wr2x_advanced', false );
54
+ update_option( 'wr2x_picturefill_noscript', $picturefill_noscript, false );
55
+ $hide_retina_column = $this->old_getoption( 'hide_retina_column', 'wr2x_advanced', false );
56
+ update_option( 'wr2x_hide_retina_column', $hide_retina_column, false );
57
+ $hide_retina_dashboard = $this->old_getoption( 'hide_retina_dashboard', 'wr2x_advanced', false );
58
+ update_option( 'wr2x_hide_retina_dashboard', $hide_retina_dashboard, false );
59
+ delete_option( 'wr2x_basics' );
60
+ delete_option( 'wr2x_advanced' );
61
+ delete_option( 'wr2x_pro' );
62
+ }
63
+
64
+ static function generate_rewrite_rules( $wp_rewrite, $flush = false ) {
65
+ global $wp_rewrite;
66
+ $method = get_option( "wr2x_method" );
67
+ if ( $method == "Retina-Images" ) {
68
+
69
+ // MODIFICATION: docwhat
70
+ // get_home_url() -> trailingslashit(site_url())
71
+ // REFERENCE: http://wordpress.org/support/topic/plugin-wp-retina-2x-htaccess-generated-with-incorrect-rewriterule
72
+
73
+ // MODIFICATION BY h4ir9
74
+ // .*\.(jpg|jpeg|gif|png|bmp) -> (.+.(?:jpe?g|gif|png))
75
+ // REFERENCE: http://wordpress.org/support/topic/great-but-needs-a-little-update
76
+
77
+ $handlerurl = str_replace( trailingslashit( site_url()), '', plugins_url( 'wr2x_image.php', __FILE__ ) );
78
+ add_rewrite_rule( '(.+.(?:jpe?g|gif|png))', $handlerurl, 'top' );
79
+ }
80
+ if ( $flush == true ) {
81
+ $wp_rewrite->flush_rules();
82
+ }
83
+ }
84
+
85
+ function common_url( $file ) {
86
+ return trailingslashit( plugin_dir_url( __FILE__ ) ) . 'common/' . $file;
87
+ }
88
+
89
+ function app_menu() {
90
+
91
+ // SUBMENU > Settings
92
+ add_submenu_page( 'meowapps-main-menu', 'Retina', 'Retina', 'manage_options',
93
+ 'wr2x_settings-menu', array( $this, 'admin_settings' ) );
94
+
95
+ // SUBMENU > Settings > Basic Settings
96
+ add_settings_section( 'wr2x_settings', null, null, 'wr2x_settings-menu' );
97
+ add_settings_field( 'wr2x_ignore_sizes', __( "Disabled Sizes", 'wp-retina-2x' ),
98
+ array( $this, 'admin_ignore_sizes_callback' ),
99
+ 'wr2x_settings-menu', 'wr2x_settings' );
100
+ add_settings_field( 'wr2x_auto_generate', __( "Auto Generate", 'wp-retina-2x' ),
101
+ array( $this, 'admin_auto_generate_callback' ),
102
+ 'wr2x_settings-menu', 'wr2x_settings' );
103
+ add_settings_field( 'wr2x_method', __( "Method", 'wp-retina-2x' ),
104
+ array( $this, 'admin_method_callback' ),
105
+ 'wr2x_settings-menu', 'wr2x_settings' );
106
+ add_settings_field( 'wr2x_full_size', __( "Full Size Retina", 'wp-retina-2x' ) . "<br />(Pro)",
107
+ array( $this, 'admin_full_size_callback' ),
108
+ 'wr2x_settings-menu', 'wr2x_settings' );
109
+ // add_settings_field( 'wr2x_method', __( "Method", 'wp-retina-2x' ),
110
+ // array( $this, 'admin_method_callback' ),
111
+ // 'wr2x_settings-menu', 'wr2x_settings' );
112
+ add_settings_field( 'wr2x_quality', __( "Retina Quality", 'wp-retina-2x' ),
113
+ array( $this, 'admin_quality_callback' ),
114
+ 'wr2x_settings-menu', 'wr2x_settings' );
115
+
116
+ register_setting( 'wr2x_settings', 'wr2x_ignore_sizes' );
117
+ register_setting( 'wr2x_settings', 'wr2x_auto_generate' );
118
+ register_setting( 'wr2x_settings', 'wr2x_full_size' );
119
+ register_setting( 'wr2x_settings', 'wr2x_method' );
120
+ register_setting( 'wr2x_settings', 'wr2x_quality' );
121
+
122
+ // SUBMENU > Settings > Advanced Settings
123
+ add_settings_section( 'wr2x_advanced_settings', null, null, 'wr2x_advanced_settings-menu' );
124
+ add_settings_field( 'wr2x_disable_responsive', __( "Disable Responsive", 'wp-retina-2x' ),
125
+ array( $this, 'admin_disable_responsive_callback' ),
126
+ 'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
127
+ add_settings_field( 'wr2x_disable_medium_large', __( "Disable Medium Large", 'wp-retina-2x' ),
128
+ array( $this, 'admin_disable_medium_large_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
+ add_settings_field( 'wr2x_over_http_check', __( "Over HTTP Check", 'wp-retina-2x' ) . "<br />(Pro)",
134
+ array( $this, 'admin_over_http_check_callback' ),
135
+ 'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
136
+ add_settings_field( 'wr2x_debug', __( "Debug", 'wp-retina-2x' ),
137
+ array( $this, 'admin_debug_callback' ),
138
+ 'wr2x_advanced_settings-menu', 'wr2x_advanced_settings' );
139
+
140
+ register_setting( 'wr2x_advanced_settings', 'wr2x_disable_responsive' );
141
+ register_setting( 'wr2x_advanced_settings', 'wr2x_disable_medium_large' );
142
+ register_setting( 'wr2x_advanced_settings', 'wr2x_cdn_domain' );
143
+ register_setting( 'wr2x_advanced_settings', 'wr2x_over_http_check' );
144
+ register_setting( 'wr2x_advanced_settings', 'wr2x_debug' );
145
+
146
+ // SUBMENU > Settings > PictureFill
147
+ add_settings_section( 'wr2x_picturefill_settings', null, null, 'wr2x_picturefill_settings-menu' );
148
+ add_settings_field( 'wr2x_picturefill_keep_src', "Keep IMG SRC",
149
+ array( $this, 'admin_picturefill_keep_src_callback' ),
150
+ 'wr2x_picturefill_settings-menu', 'wr2x_picturefill_settings' );
151
+ add_settings_field( 'wr2x_picturefill_lazysizes', "Lazy Retina<br />(Pro)",
152
+ array( $this, 'admin_picturefill_lazysizes_callback' ),
153
+ 'wr2x_picturefill_settings-menu', 'wr2x_picturefill_settings' );
154
+ add_settings_field( 'wr2x_picturefill_css_background', "CSS Background<br />(Pro)",
155
+ array( $this, 'admin_picturefill_css_background_callback' ),
156
+ 'wr2x_picturefill_settings-menu', 'wr2x_picturefill_settings' );
157
+ add_settings_field( 'wr2x_picturefill_noscript', "Polyfill Script",
158
+ array( $this, 'admin_picturefill_noscript_callback' ),
159
+ 'wr2x_picturefill_settings-menu', 'wr2x_picturefill_settings' );
160
+
161
+ register_setting( 'wr2x_picturefill_settings', 'wr2x_picturefill_keep_src' );
162
+ register_setting( 'wr2x_picturefill_settings', 'wr2x_picturefill_lazysizes' );
163
+ register_setting( 'wr2x_picturefill_settings', 'wr2x_picturefill_css_background' );
164
+ register_setting( 'wr2x_picturefill_settings', 'wr2x_picturefill_noscript' );
165
+
166
+ // SUBMENU > Settings > Admin UI
167
+ add_settings_section( 'wr2x_ui_settings', null, null, 'wr2x_ui_settings-menu' );
168
+ add_settings_field( 'wr2x_hide_retina_column', __( "Retina Column", 'wp-retina-2x' ),
169
+ array( $this, 'admin_hide_retina_column_callback' ),
170
+ 'wr2x_ui_settings-menu', 'wr2x_ui_settings' );
171
+ add_settings_field( 'wr2x_hide_retina_dashboard', __( "Retina Dashboard", 'wp-retina-2x' ),
172
+ array( $this, 'admin_hide_retina_dashboard_callback' ),
173
+ 'wr2x_ui_settings-menu', 'wr2x_ui_settings' );
174
+
175
+ register_setting( 'wr2x_ui_settings', 'wr2x_hide_retina_column' );
176
+ register_setting( 'wr2x_ui_settings', 'wr2x_hide_retina_dashboard' );
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>.', 'meow-gallery' ) ?>
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 = wr2x_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>", Meow_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.', '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>Generate on new upload and regenerate</label><br /><small>The <i>Disabled Sizes</i> will be skipped.</small>';
321
+ echo $html;
322
+ }
323
+
324
+ function admin_disable_responsive_callback( $args ) {
325
+ $value = get_option( 'wr2x_disable_responsive', null );
326
+ $html = '<input type="checkbox" id="wr2x_disable_responsive" name="wr2x_disable_responsive" value="1" ' .
327
+ checked( 1, get_option( 'wr2x_disable_responsive' ), false ) . '/>';
328
+ $html .= '<label>Disable the Responsive Images feature.</label><br /><small>Get back control over your HTML if you need.</small>';
329
+ echo $html;
330
+ }
331
+
332
+ function admin_disable_medium_large_callback( $args ) {
333
+ $value = get_option( 'wr2x_disable_medium_large', null );
334
+ $html = '<input type="checkbox" id="wr2x_disable_medium_large" name="wr2x_disable_medium_large" value="1" ' .
335
+ checked( 1, get_option( 'wr2x_disable_medium_large' ), false ) . '/>';
336
+ $html .= '<label>Remove the "Medium Large" image size.</label><br /><small>You probably don\'t need this.</small>';
337
+ echo $html;
338
+ }
339
+
340
+ function admin_method_callback( $args ) {
341
+ $value = get_option( 'wr2x_method', 'none' );
342
+ $html = '<select id="wr2x_method" name="wr2x_method">
343
+ <option ' . selected( 'Picturefill', $value, false ) . 'value="Picturefill">Recommended: Picturefill</option>
344
+ <option ' . selected( 'Responsive', $value, false ) . 'value="Responsive">Responsive-Images (Native WP 4.4+)</option>
345
+ <option ' . selected( 'retina.js', $value, false ) . 'value="retina.js">Retina.js (Client-side)</option>
346
+ <option ' . selected( 'HTML Rewrite', $value, false ) . 'value="HTML Rewrite">HTML Rewrite</option>
347
+ <option ' . selected( 'Retina-Images', $value, false ) . 'value="Retina-Images">Retina-Images</option>
348
+ <option ' . selected( 'none', $value, false ) . 'value="none">None</option>
349
+ </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>';
350
+ echo $html;
351
+ }
352
+
353
+ function admin_full_size_callback( $args ) {
354
+ $value = get_option( 'wr2x_full_size', null );
355
+ $html = '<input ' . disabled( $this->is_pro(), false, false ) . ' type="checkbox" id="wr2x_full_size" name="wr2x_full_size" value="1" ' .
356
+ checked( 1, get_option( 'wr2x_full_size' ), false ) . '/>';
357
+ $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>';
358
+ echo $html;
359
+ }
360
+
361
+ function admin_quality_callback( $args ) {
362
+ $value = get_option( 'wr2x_quality', 90 );
363
+ $html = '<input type="number" id="wr2x_quality" name="wr2x_quality" value="' . $value . '" />';
364
+ $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' );
365
+ echo $html;
366
+ }
367
+
368
+ function admin_debug_callback( $args ) {
369
+ $value = get_option( 'wr2x_debug', null );
370
+ $html = '<input type="checkbox" id="wr2x_debug" name="wr2x_debug" value="1" ' .
371
+ checked( 1, get_option( 'wr2x_debug' ), false ) . '/>';
372
+ $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' );
373
+ echo $html;
374
+ }
375
+
376
+ function admin_cdn_domain_callback( $args ) {
377
+ $value = get_option( 'wr2x_cdn_domain', null );
378
+ $html = '<input ' . disabled( $this->is_pro(), false, false ) . ' type="text" id="wr2x_cdn_domain" name="wr2x_cdn_domain" value="' . $value . '" />';
379
+ $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' );
380
+ echo $html;
381
+ }
382
+
383
+ function admin_over_http_check_callback( $args ) {
384
+ $value = get_option( 'wr2x_over_http_check', null );
385
+ $html = '<input type="checkbox" id="wr2x_over_http_check" name="wr2x_over_http_check" value="1" ' .
386
+ checked( 1, get_option( 'wr2x_over_http_check' ), false ) . '/>';
387
+ $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' );
388
+ echo $html;
389
+ }
390
+
391
+ function admin_picturefill_keep_src_callback( $args ) {
392
+ $value = get_option( 'wr2x_picturefill_keep_src', null );
393
+ $html = '<input type="checkbox" id="wr2x_picturefill_keep_src" name="wr2x_picturefill_keep_src" value="1" ' .
394
+ checked( 1, get_option( 'wr2x_picturefill_keep_src' ), false ) . '/>';
395
+ $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' );
396
+ echo $html;
397
+ }
398
+
399
+ function admin_picturefill_lazysizes_callback( $args ) {
400
+ $value = get_option( 'wr2x_picturefill_lazysizes', null );
401
+ $html = '<input ' . disabled( $this->is_pro(), false, false ) . ' type="checkbox" id="wr2x_picturefill_lazysizes"
402
+ name="wr2x_picturefill_lazysizes" value="1" ' .
403
+ checked( 1, get_option( 'wr2x_picturefill_lazysizes' ), false ) . '/>';
404
+ $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' );
405
+ echo $html;
406
+ }
407
+
408
+ function admin_picturefill_noscript_callback( $args ) {
409
+ $value = get_option( 'wr2x_picturefill_noscript', null );
410
+ $html = '<input ' . disabled( $this->is_pro(), false, false ) . ' type="checkbox" id="wr2x_picturefill_noscript"
411
+ name="wr2x_picturefill_noscript" value="1" ' .
412
+ checked( 1, get_option( 'wr2x_picturefill_noscript' ), false ) . '/>';
413
+ $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' );
414
+ echo $html;
415
+ }
416
+
417
+ function admin_picturefill_css_background_callback( $args ) {
418
+ $value = get_option( 'wr2x_picturefill_css_background', null );
419
+ $html = '<input type="checkbox" id="wr2x_picturefill_css_background" name="wr2x_picturefill_css_background" value="1" ' .
420
+ checked( 1, get_option( 'wr2x_picturefill_css_background' ), false ) . '/>';
421
+ $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' );
422
+ echo $html;
423
+ }
424
+
425
+ function admin_hide_retina_column_callback( $args ) {
426
+ $value = get_option( 'wr2x_hide_retina_column', null );
427
+ $html = '<input type="checkbox" id="wr2x_hide_retina_column" name="wr2x_hide_retina_column" value="1" ' .
428
+ checked( 1, get_option( 'wr2x_hide_retina_column' ), false ) . '/>';
429
+ $html .= __( '<label>Hide</label><br /><small>Hide the <i>Retina Column</i> in the Media Library.</small>', 'wp-retina-2x' );
430
+ echo $html;
431
+ }
432
+
433
+ function admin_hide_retina_dashboard_callback( $args ) {
434
+ $value = get_option( 'wr2x_hide_retina_dashboard', null );
435
+ $html = '<input type="checkbox" id="wr2x_hide_retina_dashboard" name="wr2x_hide_retina_dashboard" value="1" ' .
436
+ checked( 1, get_option( 'wr2x_hide_retina_dashboard' ), false ) . '/>';
437
+ $html .= __( '<label>Hide</label><br /><small>Disable <i>Retina Dashboard</i> menu and tools.</small>', 'wp-retina-2x' );
438
+ echo $html;
439
+ }
440
+
441
+ /**
442
+ *
443
+ * GET / SET OPTIONS (TO REMOVE)
444
+ *
445
+ */
446
+
447
+ function old_getoption( $option, $section, $default = '' ) {
448
+ $options = get_option( $section );
449
+ if ( isset( $options[$option] ) ) {
450
+ if ( $options[$option] == "off" ) {
451
+ return false;
452
+ }
453
+ if ( $options[$option] == "on" ) {
454
+ return true;
455
+ }
456
+ return $options[$option];
457
+ }
458
+ return $default;
459
+ }
460
+
461
+ }
462
+
463
+ ?>
wr2x_ajax.php ADDED
@@ -0,0 +1,664 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_action( 'wp_ajax_wr2x_generate', 'wr2x_wp_ajax_wr2x_generate' );
4
+ add_action( 'wp_ajax_wr2x_delete', 'wr2x_wp_ajax_wr2x_delete' );
5
+ add_action( 'wp_ajax_wr2x_delete_full', 'wr2x_wp_ajax_wr2x_delete_full' );
6
+ add_action( 'wp_ajax_wr2x_list_all', 'wr2x_wp_ajax_wr2x_list_all' );
7
+ add_action( 'wp_ajax_wr2x_replace', 'wr2x_wp_ajax_wr2x_replace' );
8
+ add_action( 'wp_ajax_wr2x_upload', 'wr2x_wp_ajax_wr2x_upload' );
9
+ add_action( 'wp_ajax_wr2x_retina_details', 'wr2x_wp_ajax_wr2x_retina_details' );
10
+ add_action( 'admin_head', 'wr2x_admin_head' );
11
+
12
+ /**
13
+ *
14
+ * AJAX CLIENT-SIDE
15
+ *
16
+ */
17
+
18
+ function wr2x_admin_head() {
19
+ ?>
20
+ <script type="text/javascript" >
21
+
22
+ /* GENERATE RETINA IMAGES ACTION */
23
+
24
+ var current;
25
+ var maxPhpSize = <?php echo wr2x_get_max_filesize(); ?>;
26
+ var ids = [];
27
+ var errors = 0;
28
+ var ajax_action = "generate"; // generate | delete
29
+
30
+ function wr2x_display_please_refresh() {
31
+ wr2x_refresh_progress_status();
32
+ jQuery('#wr2x_progression').html(jQuery('#wr2x_progression').html() + " - <?php echo _e( "<a href='?page=wp-retina-2x&view=issues&refresh=true'>Refresh</a> this page.", 'wp-retina-2x' ); ?>");
33
+ }
34
+
35
+ function wr2x_refresh_progress_status() {
36
+ var errortext = "";
37
+ if ( errors > 0 ) {
38
+ errortext = ' - ' + errors + ' error(s)';
39
+ }
40
+ jQuery('#wr2x_progression').text(current + "/" + ids.length +
41
+ " (" + Math.round(current / ids.length * 100) + "%)" + errortext);
42
+ }
43
+
44
+ function wr2x_do_next () {
45
+ var data = { action: 'wr2x_' + ajax_action, attachmentId: ids[current - 1] };
46
+ wr2x_refresh_progress_status();
47
+ jQuery.post(ajaxurl, data, function (response) {
48
+ try {
49
+ reply = jQuery.parseJSON(response);
50
+ }
51
+ catch (e) {
52
+ reply = null;
53
+ }
54
+ if ( !reply || !reply.success )
55
+ errors++;
56
+ else {
57
+ wr2x_refresh_media_sizes(reply.results);
58
+ if (reply.results_full)
59
+ wr2x_refresh_full(reply.results_full);
60
+ }
61
+ if (++current <= ids.length)
62
+ wr2x_do_next();
63
+ else {
64
+ current--;
65
+ wr2x_display_please_refresh();
66
+ }
67
+ }).fail(function () {
68
+ errors++;
69
+ if (++current <= ids.length)
70
+ wr2x_do_next();
71
+ else {
72
+ current--;
73
+ wr2x_display_please_refresh();
74
+ }
75
+ });
76
+ }
77
+
78
+ function wr2x_do_all () {
79
+ current = 1;
80
+ ids = [];
81
+ errors = 0;
82
+ var data = { action: 'wr2x_list_all', issuesOnly: 0 };
83
+ jQuery('#wr2x_progression').text("<?php _e( "Wait...", 'wp-retina-2x' ); ?>");
84
+ jQuery.post(ajaxurl, data, function (response) {
85
+ reply = jQuery.parseJSON(response);
86
+ if (reply.success = false) {
87
+ alert('Error: ' + reply.message);
88
+ return;
89
+ }
90
+ if (reply.total == 0) {
91
+ jQuery('#wr2x_progression').html("<?php _e( "Nothing to do ;)", 'wp-retina-2x' ); ?>");
92
+ return;
93
+ }
94
+ ids = reply.ids;
95
+ jQuery('#wr2x_progression').text(current + "/" + ids.length + " (" + Math.round(current / ids.length * 100) + "%)");
96
+ wr2x_do_next();
97
+ });
98
+ }
99
+
100
+ function wr2x_delete_all () {
101
+ ajax_action = 'delete';
102
+ wr2x_do_all();
103
+ }
104
+
105
+ function wr2x_generate_all () {
106
+ ajax_action = 'generate';
107
+ wr2x_do_all();
108
+ }
109
+
110
+ // Refresh the dashboard retina full with the results from the Ajax operation (Upload)
111
+ function wr2x_refresh_full (results) {
112
+ jQuery.each(results, function (id, html) {
113
+ jQuery('#wr2x-info-full-' + id).html(html);
114
+ jQuery('#wr2x-info-full-' + id + ' img').attr('src', jQuery('#wr2x-info-full-' + id + ' img').attr('src')+'?'+ Math.random());
115
+ jQuery('#wr2x-info-full-' + id + ' img').on('click', function (evt) {
116
+ wr2x_delete_full( jQuery(evt.target).parents('.wr2x-file-row').attr('postid') );
117
+ });
118
+ });
119
+ }
120
+
121
+ // Refresh the dashboard media sizes with the results from the Ajax operation (Replace or Generate)
122
+ function wr2x_refresh_media_sizes (results) {
123
+ jQuery.each(results, function (id, html) {
124
+ jQuery('#wr2x-info-' + id).html(html);
125
+ });
126
+ }
127
+
128
+ function wr2x_generate (attachmentId, retinaDashboard) {
129
+ var data = { action: 'wr2x_generate', attachmentId: attachmentId };
130
+ jQuery('#wr2x_generate_button_' + attachmentId).text("<?php echo __( "Wait...", 'wp-retina-2x' ); ?>");
131
+ jQuery.post(ajaxurl, data, function (response) {
132
+ var reply = jQuery.parseJSON(response);
133
+ if (!reply.success) {
134
+ alert(reply.message);
135
+ return;
136
+ }
137
+ jQuery('#wr2x_generate_button_' + attachmentId).html("<?php echo __( "GENERATE", 'wp-retina-2x' ); ?>");
138
+ wr2x_refresh_media_sizes(reply.results);
139
+ });
140
+ }
141
+
142
+ /* REPLACE FUNCTION */
143
+
144
+ function wr2x_stop_propagation(evt) {
145
+ evt.stopPropagation();
146
+ evt.preventDefault();
147
+ }
148
+
149
+ function wr2x_delete_full(attachmentId) {
150
+ var data = {
151
+ action: 'wr2x_delete_full',
152
+ isAjax: true,
153
+ attachmentId: attachmentId
154
+ };
155
+
156
+ jQuery.post(ajaxurl, data, function (response) {
157
+ var data = jQuery.parseJSON(response);
158
+ if (data.success === false) {
159
+ alert(data.message);
160
+ }
161
+ else {
162
+ wr2x_refresh_full(data.results);
163
+ wr2x_display_please_refresh();
164
+ }
165
+ });
166
+ }
167
+
168
+ function wr2x_load_details(attachmentId) {
169
+ var data = {
170
+ action: 'wr2x_retina_details',
171
+ isAjax: true,
172
+ attachmentId: attachmentId
173
+ };
174
+
175
+ jQuery.post(ajaxurl, data, function (response) {
176
+ var data = jQuery.parseJSON(response);
177
+ if (data.success === false) {
178
+ alert(data.message);
179
+ }
180
+ else {
181
+ jQuery('#meow-modal-info .loading').css('display', 'none');
182
+ jQuery('#meow-modal-info .content').html(data.result);
183
+ }
184
+ });
185
+ }
186
+
187
+ function wr2x_filedropped (evt) {
188
+ wr2x_stop_propagation(evt);
189
+ var files = evt.dataTransfer.files;
190
+ var count = files.length;
191
+ if (count < 0) {
192
+ return;
193
+ }
194
+
195
+ var wr2x_replace = jQuery(evt.target).parent().hasClass('wr2x-fullsize-replace');
196
+ var wr2x_upload = jQuery(evt.target).parent().hasClass('wr2x-fullsize-retina-upload');
197
+
198
+ function wr2x_handleprogress(prg) {
199
+ console.debug("Upload of " + prg.srcElement.filename + ": " + prg.loaded / prg.total * 100 + "%");
200
+ }
201
+
202
+ function wr2x_uploadFile(file, attachmentId, filename) {
203
+ var action = "";
204
+ if (wr2x_replace) {
205
+ action = 'wr2x_replace';
206
+ }
207
+ else if (wr2x_upload) {
208
+ action = 'wr2x_upload';
209
+ }
210
+ else {
211
+ alert("Unknown command. Contact the developer.");
212
+ }
213
+ var data = new FormData();
214
+ data.append('file', file);
215
+ data.append('action', action);
216
+ data.append('attachmentId', attachmentId);
217
+ data.append('isAjax', true);
218
+ data.append('filename', filename);
219
+ // var data = {
220
+ // action: action,
221
+ // isAjax: true,
222
+ // filename: evt.target.filename,
223
+ // data: form_data,
224
+ // attachmentId: attachmentId
225
+ // };
226
+
227
+ jQuery.ajax({
228
+ type: 'POST',
229
+ url: ajaxurl,
230
+ contentType: false,
231
+ processData: false,
232
+ data: data,
233
+ success: function (response) {
234
+ jQuery('[postid=' + attachmentId + '] td').removeClass('wr2x-loading-file');
235
+ jQuery('[postid=' + attachmentId + '] .wr2x-dragdrop').removeClass('wr2x-hover-drop');
236
+ try {
237
+ var data = jQuery.parseJSON(response);
238
+ }
239
+ catch (e) {
240
+ 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).");
241
+ console.debug(response);
242
+ return;
243
+ }
244
+ if (wr2x_replace) {
245
+ var imgSelector = '[postid=' + attachmentId + '] .wr2x-info-thumbnail img';
246
+ jQuery(imgSelector).attr('src', jQuery(imgSelector).attr('src')+'?'+ Math.random());
247
+ }
248
+ if (wr2x_upload) {
249
+ var imgSelector = '[postid=' + attachmentId + '] .wr2x-info-full img';
250
+ jQuery(imgSelector).attr('src', jQuery(imgSelector).attr('src')+'?'+ Math.random());
251
+ }
252
+ if (data.success === false) {
253
+ alert(data.message);
254
+ }
255
+ else {
256
+ if ( wr2x_replace ) {
257
+ wr2x_refresh_media_sizes(data.results);
258
+ }
259
+ else if ( wr2x_upload ) {
260
+ wr2x_refresh_full(data.results);
261
+ }
262
+ }
263
+ },
264
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
265
+ jQuery('[postid=' + attachmentId + '] td').removeClass('wr2x-loading-file');
266
+ jQuery('[postid=' + attachmentId + '] .wr2x-dragdrop').removeClass('wr2x-hover-drop');
267
+ alert("An error occurred on the server-side. Please check your PHP error logs.");
268
+ }
269
+ });
270
+ }
271
+ var file = files[0];
272
+ if (file.size > maxPhpSize) {
273
+ jQuery(this).removeClass('wr2x-hover-drop');
274
+ alert( "Your PHP configuration only allows file upload of a maximum of " + (maxPhpSize / 1000000) + "MB." );
275
+ return;
276
+ }
277
+ var postId = jQuery(evt.target).parents('.wr2x-file-row').attr('postid');
278
+ jQuery(evt.target).parents('td').addClass('wr2x-loading-file');
279
+ wr2x_uploadFile(file, postId, file.name);
280
+ }
281
+
282
+ jQuery(document).ready(function () {
283
+ jQuery('.wr2x-dragdrop').on('dragenter', function (evt) {
284
+ wr2x_stop_propagation(evt);
285
+ jQuery(this).addClass('wr2x-hover-drop');
286
+ });
287
+
288
+ jQuery('.wr2x-dragdrop').on('dragover', function (evt) {
289
+ wr2x_stop_propagation(evt);
290
+ jQuery(this).addClass('wr2x-hover-drop');
291
+ });
292
+
293
+ jQuery('.wr2x-dragdrop').on('dragleave', function (evt) {
294
+ wr2x_stop_propagation(evt);
295
+ jQuery(this).removeClass('wr2x-hover-drop');
296
+ });
297
+
298
+ jQuery('.wr2x-dragdrop').on('dragexit', wr2x_stop_propagation);
299
+
300
+ jQuery('.wr2x-dragdrop').each(function (index, elem) {
301
+ this.addEventListener('drop', wr2x_filedropped);
302
+ });
303
+
304
+ jQuery('.wr2x-info, .wr2x-button-view').on('click', function (evt) {
305
+ jQuery('#meow-modal-info-backdrop').css('display', 'block');
306
+ jQuery('#meow-modal-info .content').html("");
307
+ jQuery('#meow-modal-info .loading').css('display', 'block');
308
+ jQuery('#meow-modal-info').css('display', 'block');
309
+ jQuery('#meow-modal-info').focus();
310
+ var postid = jQuery(evt.target).parents('.wr2x-info').attr('postid');
311
+ if (!postid)
312
+ postid = jQuery(evt.target).parents('.wr2x-file-row').attr('postid');
313
+ wr2x_load_details(postid);
314
+ });
315
+
316
+ jQuery('#meow-modal-info .close, #meow-modal-info-backdrop').on('click', function (evt) {
317
+ jQuery('#meow-modal-info').css('display', 'none');
318
+ jQuery('#meow-modal-info-backdrop').css('display', 'none');
319
+ });
320
+
321
+ jQuery('.wr2x-info-full img').on('click', function (evt) {
322
+ wr2x_delete_full( jQuery(evt.target).parents('.wr2x-file-row').attr('postid') );
323
+ });
324
+
325
+ jQuery('#meow-modal-info').bind('keydown', function (evt) {
326
+ if (evt.keyCode === 27) {
327
+ jQuery('#meow-modal-info').css('display', 'none');
328
+ jQuery('#meow-modal-info-backdrop').css('display', 'none');
329
+ }
330
+ });
331
+ });
332
+
333
+ </script>
334
+ <?php
335
+ }
336
+
337
+ /**
338
+ *
339
+ * AJAX SERVER-SIDE
340
+ *
341
+ */
342
+
343
+ // Using issuesOnly, only the IDs with a PENDING status will be processed
344
+ function wr2x_wp_ajax_wr2x_list_all( $issuesOnly ) {
345
+ $issuesOnly = intval( $_POST['issuesOnly'] );
346
+ if ( $issuesOnly == 1 ) {
347
+ $ids = wr2x_get_issues();
348
+ echo json_encode(
349
+ array(
350
+ 'success' => true,
351
+ 'message' => "List of issues only.",
352
+ 'ids' => $ids,
353
+ 'total' => count( $ids )
354
+ ) );
355
+ die;
356
+ }
357
+ $reply = array();
358
+ try {
359
+ $ids = array();
360
+ $total = 0;
361
+ global $wpdb;
362
+ $postids = $wpdb->get_col( "
363
+ SELECT p.ID
364
+ FROM $wpdb->posts p
365
+ WHERE post_status = 'inherit'
366
+ AND post_type = 'attachment'
367
+ AND ( post_mime_type = 'image/jpeg' OR
368
+ post_mime_type = 'image/png' OR
369
+ post_mime_type = 'image/gif' )
370
+ " );
371
+ foreach ($postids as $id) {
372
+ if ( wr2x_is_ignore( $id ) )
373
+ continue;
374
+ array_push( $ids, $id );
375
+ $total++;
376
+ }
377
+ echo json_encode(
378
+ array(
379
+ 'success' => true,
380
+ 'message' => "List of everything.",
381
+ 'ids' => $ids,
382
+ 'total' => $total
383
+ ) );
384
+ die;
385
+ }
386
+ catch (Exception $e) {
387
+ echo json_encode(
388
+ array(
389
+ 'success' => false,
390
+ 'message' => $e->getMessage()
391
+ ) );
392
+ die;
393
+ }
394
+ }
395
+
396
+ function wr2x_wp_ajax_wr2x_delete_full( $pleaseReturn = false ) {
397
+
398
+ if ( !isset( $_POST['attachmentId'] ) ) {
399
+ echo json_encode(
400
+ array(
401
+ 'success' => false,
402
+ 'message' => __( "The attachment ID is missing.", 'wp-retina-2x' )
403
+ )
404
+ );
405
+ die();
406
+ }
407
+ $attachmentId = intval( $_POST['attachmentId'] );
408
+ $originalfile = get_attached_file( $attachmentId );
409
+ $pathinfo = pathinfo( $originalfile );
410
+ $retina_file = trailingslashit( $pathinfo['dirname'] ) . $pathinfo['filename'] . wr2x_retina_extension() . $pathinfo['extension'];
411
+ if ( $retina_file && file_exists( $retina_file ) )
412
+ unlink( $retina_file );
413
+
414
+ // RESULTS FOR RETINA DASHBOARD
415
+ $info = wpr2x_html_get_basic_retina_info_full( $attachmentId, wr2x_retina_info( $attachmentId ) );
416
+ $results[$attachmentId] = $info;
417
+
418
+ // Return if that's not the final step.
419
+ if ( $pleaseReturn )
420
+ return $info;
421
+
422
+ echo json_encode(
423
+ array(
424
+ 'results' => $results,
425
+ 'success' => true,
426
+ 'message' => __( "Full retina file deleted.", 'wp-retina-2x' )
427
+ )
428
+ );
429
+ die();
430
+ }
431
+
432
+ function wr2x_wp_ajax_wr2x_delete() {
433
+
434
+ if ( !isset( $_POST['attachmentId'] ) ) {
435
+ echo json_encode(
436
+ array(
437
+ 'success' => false,
438
+ 'message' => __( "The attachment ID is missing.", 'wp-retina-2x' )
439
+ )
440
+ );
441
+ die();
442
+ }
443
+
444
+ // Information for the retina version of the full-size
445
+ $attachmentId = intval( $_POST['attachmentId'] );
446
+ $results_full[$attachmentId] = wr2x_wp_ajax_wr2x_delete_full( true );
447
+
448
+ wr2x_delete_attachment( $attachmentId, true );
449
+ $meta = wp_get_attachment_metadata( $attachmentId );
450
+
451
+ // RESULTS FOR RETINA DASHBOARD
452
+ wr2x_update_issue_status( $attachmentId );
453
+ $info = wpr2x_html_get_basic_retina_info( $attachmentId, wr2x_retina_info( $attachmentId ) );
454
+ $results[$attachmentId] = $info;
455
+ echo json_encode(
456
+ array(
457
+ 'results' => $results,
458
+ 'results_full' => $results_full,
459
+ 'success' => true,
460
+ 'message' => __( "Retina files deleted.", 'wp-retina-2x' )
461
+ )
462
+ );
463
+ die();
464
+ }
465
+
466
+ function wr2x_wp_ajax_wr2x_retina_details() {
467
+ if ( !isset( $_POST['attachmentId'] ) ) {
468
+ echo json_encode(
469
+ array(
470
+ 'success' => false,
471
+ 'message' => __( "The attachment ID is missing.", 'wp-retina-2x' )
472
+ )
473
+ );
474
+ die();
475
+ }
476
+
477
+ $attachmentId = intval( $_POST['attachmentId'] );
478
+ $info = wpr2x_html_get_details_retina_info( $attachmentId, wr2x_retina_info( $attachmentId ) );
479
+ echo json_encode(
480
+ array(
481
+ 'result' => $info,
482
+ 'success' => true,
483
+ 'message' => __( "Details retrieved.", 'wp-retina-2x' )
484
+ )
485
+ );
486
+ die();
487
+ }
488
+
489
+ function wr2x_wp_ajax_wr2x_generate() {
490
+ if ( !isset( $_POST['attachmentId'] ) ) {
491
+ echo json_encode(
492
+ array(
493
+ 'success' => false,
494
+ 'message' => __( "The attachment ID is missing.", 'wp-retina-2x' )
495
+ )
496
+ );
497
+ die();
498
+ }
499
+
500
+ $attachmentId = intval( $_POST['attachmentId'] );
501
+ wr2x_delete_attachment( $attachmentId, false );
502
+
503
+ // Regenerate the Thumbnails
504
+ $file = get_attached_file( $attachmentId );
505
+ $meta = wp_generate_attachment_metadata( $attachmentId, $file );
506
+ wp_update_attachment_metadata( $attachmentId, $meta );
507
+
508
+ // Regenerate Retina
509
+ //$meta = wp_get_attachment_metadata( $attachmentId );
510
+ wr2x_generate_images( $meta );
511
+
512
+ // RESULTS FOR RETINA DASHBOARD
513
+ $info = wpr2x_html_get_basic_retina_info( $attachmentId, wr2x_retina_info( $attachmentId ) );
514
+ $results[$attachmentId] = $info;
515
+ echo json_encode(
516
+ array(
517
+ 'results' => $results,
518
+ 'success' => true,
519
+ 'message' => __( "Retina files generated.", 'wp-retina-2x' )
520
+ )
521
+ );
522
+ die();
523
+ }
524
+
525
+ function wr2x_check_get_ajax_uploaded_file() {
526
+
527
+ if ( !current_user_can('upload_files') ) {
528
+ echo json_encode( array(
529
+ 'success' => false,
530
+ 'message' => __( "You do not have permission to upload files.", 'wp-retina-2x' )
531
+ ));
532
+ die();
533
+ }
534
+
535
+ $tmpfname = $_FILES['file']['tmp_name'];
536
+
537
+ // Check if it is an image
538
+ $file_info = getimagesize( $tmpfname );
539
+ if ( empty( $file_info ) ) {
540
+ wr2x_log( "The file is not an image or the upload went wrong." );
541
+ unlink( $tmpfname );
542
+ echo json_encode( array(
543
+ 'success' => false,
544
+ 'message' => __( "The file is not an image or the upload went wrong.", 'wp-retina-2x' )
545
+ ));
546
+ die();
547
+ }
548
+
549
+ $filedata = wp_check_filetype_and_ext( $tmpfname, $_POST['filename'] );
550
+ if ( $filedata["ext"] == "" ) {
551
+ wr2x_log( "You cannot use this file (wrong extension? wrong type?)." );
552
+ unlink( $current_file );
553
+ echo json_encode( array(
554
+ 'success' => false,
555
+ 'message' => __( "You cannot use this file (wrong extension? wrong type?).", 'wp-retina-2x' )
556
+ ));
557
+ die();
558
+ }
559
+
560
+ wr2x_log( "The temporary file was written successfully." );
561
+ return $tmpfname;
562
+ }
563
+
564
+ function wr2x_wp_ajax_wr2x_upload() {
565
+ try {
566
+ $tmpfname = wr2x_check_get_ajax_uploaded_file();
567
+ $attachmentId = (int) $_POST['attachmentId'];
568
+ $meta = wp_get_attachment_metadata( $attachmentId );
569
+ $current_file = get_attached_file( $attachmentId );
570
+ $pathinfo = pathinfo( $current_file );
571
+ $basepath = $pathinfo['dirname'];
572
+ $retinafile = trailingslashit( $pathinfo['dirname'] ) . $pathinfo['filename'] . wr2x_retina_extension() . $pathinfo['extension'];
573
+
574
+ if ( file_exists( $retinafile ) )
575
+ unlink( $retinafile );
576
+
577
+ // Insert the new file and delete the temporary one
578
+ list( $width, $height ) = getimagesize( $tmpfname );
579
+
580
+ if ( !wr2x_are_dimensions_ok( $width, $height, $meta['width'] * 2, $meta['height'] * 2 ) ) {
581
+ echo json_encode( array(
582
+ 'success' => false,
583
+ '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 ) . "."
584
+ ));
585
+ die();
586
+ }
587
+ require('wr2x_vt_resize.php');
588
+ wr2x_vt_resize( $tmpfname, $meta['width'] * 2, $meta['height'] * 2, null, $retinafile );
589
+ chmod( $retinafile, 0644 );
590
+ unlink( $tmpfname );
591
+
592
+ // Get the results
593
+ $info = wr2x_retina_info( $attachmentId );
594
+ wr2x_update_issue_status( $attachmentId );
595
+ $results[$attachmentId] = wpr2x_html_get_basic_retina_info_full( $attachmentId, $info );
596
+ }
597
+ catch (Exception $e) {
598
+ echo json_encode( array(
599
+ 'success' => false,
600
+ 'results' => null,
601
+ 'message' => __( "Error: " . $e->getMessage(), 'wp-retina-2x' )
602
+ ));
603
+ die();
604
+ }
605
+ echo json_encode( array(
606
+ 'success' => true,
607
+ 'results' => $results,
608
+ 'message' => __( "Uploaded successfully.", 'wp-retina-2x' )
609
+ ));
610
+ die();
611
+ }
612
+
613
+ function wr2x_wp_ajax_wr2x_replace() {
614
+ $tmpfname = wr2x_check_get_ajax_uploaded_file();
615
+ $attachmentId = (int) $_POST['attachmentId'];
616
+ $meta = wp_get_attachment_metadata( $attachmentId );
617
+ $current_file = get_attached_file( $attachmentId );
618
+ wr2x_delete_attachment( $attachmentId, false );
619
+ $pathinfo = pathinfo( $current_file );
620
+ $basepath = $pathinfo['dirname'];
621
+
622
+ // Let's clean everything first
623
+ if ( wp_attachment_is_image( $attachmentId ) ) {
624
+ $sizes = wr2x_get_image_sizes();
625
+ foreach ($sizes as $name => $attr) {
626
+ if ( isset( $meta['sizes'][$name] ) && isset( $meta['sizes'][$name]['file'] ) && file_exists( trailingslashit( $basepath ) . $meta['sizes'][$name]['file'] ) ) {
627
+ $normal_file = trailingslashit( $basepath ) . $meta['sizes'][$name]['file'];
628
+ $pathinfo = pathinfo( $normal_file );
629
+ $retina_file = trailingslashit( $pathinfo['dirname'] ) . $pathinfo['filename'] . wr2x_retina_extension() . $pathinfo['extension'];
630
+
631
+ // Test if the file exists and if it is actually a file (and not a dir)
632
+ // Some old WordPress Media Library are sometimes broken and link to directories
633
+ if ( file_exists( $normal_file ) && is_file( $normal_file ) )
634
+ unlink( $normal_file );
635
+ if ( file_exists( $retina_file ) && is_file( $retina_file ) )
636
+ unlink( $retina_file );
637
+ }
638
+ }
639
+ }
640
+ if ( file_exists( $current_file ) )
641
+ unlink( $current_file );
642
+
643
+ // Insert the new file and delete the temporary one
644
+ rename( $tmpfname, $current_file );
645
+ chmod( $current_file, 0644 );
646
+
647
+ // Generate the images
648
+ wp_update_attachment_metadata( $attachmentId, wp_generate_attachment_metadata( $attachmentId, $current_file ) );
649
+ $meta = wp_get_attachment_metadata( $attachmentId );
650
+ wr2x_generate_images( $meta );
651
+
652
+ // Get the results
653
+ $info = wr2x_retina_info( $attachmentId );
654
+ $results[$attachmentId] = wpr2x_html_get_basic_retina_info( $attachmentId, $info );
655
+
656
+ echo json_encode( array(
657
+ 'success' => true,
658
+ 'results' => $results,
659
+ 'message' => __( "Replaced successfully.", 'wp-retina-2x' )
660
+ ));
661
+ die();
662
+ }
663
+
664
+ ?>
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_media-library.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_filter( 'manage_media_columns', 'wr2x_manage_media_columns' );
4
+ add_action( 'manage_media_custom_column', 'wr2x_manage_media_custom_column', 10, 2 );
5
+ add_action( 'admin_footer', 'wr2x_admin_footer_library' );
6
+
7
+ /**
8
+ *
9
+ * MEDIA LIBRARY
10
+ *
11
+ */
12
+
13
+ function wr2x_manage_media_columns( $cols ) {
14
+ $cols["Retina"] = "Retina";
15
+ return $cols;
16
+ }
17
+
18
+ function wr2x_manage_media_custom_column( $column_name, $id ) {
19
+ if ( $column_name == 'Retina' ) {
20
+ $info = wr2x_retina_info( $id );
21
+ if ( empty( $info ) )
22
+ return;
23
+ $info = wpr2x_html_get_basic_retina_info( $id, $info );
24
+ echo "<a style='' onclick='wr2x_generate(" . $id . ", true)' id='wr2x_generate_button_" . $id . "' class='wr2x-button'>" . __( "GENERATE", 'wp-retina-2x' ) . "</a><br />";
25
+ echo '<div class="wr2x-info" postid="' . $id . '" id="wr2x-info-' . $id . '">';
26
+ echo $info;
27
+ echo '</div>';
28
+ }
29
+ else if ( $column_name == 'Retina-Actions' ) {
30
+ }
31
+ }
32
+
33
+ function wr2x_admin_footer_library() {
34
+ $screen = get_current_screen();
35
+ if ( $screen->base != 'upload' && $screen->base != 'media_page_wp-retina-2x' )
36
+ return;
37
+ ?>
38
+ <div id="meow-modal-info-backdrop" style="display: none;">
39
+ </div>
40
+
41
+ <div id="meow-modal-info" style="display: none;" tabindex="1">
42
+ <div class="close">X</div>
43
+ <h2 style="margin-top: 0px;">Retina Details</h2>
44
+ <div class="loading">
45
+ <img src="<?php echo plugin_dir_url( __FILE__ ); ?>img/loading.gif" />
46
+ </div>
47
+ <div class="content">
48
+ </div>
49
+ </div>
50
+ <?php
51
+ }
52
+
53
+
54
+ ?>
wr2x_responsive.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_filter( 'wp_calculate_image_srcset', 'wr2x_wp_calculate_image_srcset', 1000, 2 );
4
+ //add_filter( 'wp_calculate_image_sizes', 'wr2x_wp_calculate_image_sizes', 1000, 2 );
5
+ //add_filter( 'wp_get_attachment_image_attributes', 'wr2x_wp_get_attachment_image_attributes', 1000, 2 );
6
+
7
+ /**
8
+ *
9
+ * SUPPORT FOR WP 4.4
10
+ *
11
+ */
12
+
13
+ function wr2x_wp_calculate_image_srcset( $srcset, $size ) {
14
+ if ( get_option( "wr2x_disable_responsive" ) )
15
+ return null;
16
+ $method = get_option( "wr2x_method" );
17
+ if ( $method == "none" )
18
+ return $srcset;
19
+ $count = 0;
20
+ $total = 0;
21
+ $retinized_srcset = $srcset;
22
+ if ( empty( $srcset ) )
23
+ return $srcset;
24
+ foreach ( $srcset as $s => $cfg ) {
25
+ $total++;
26
+ $retina = wr2x_get_retina_from_url( $cfg['url'] );
27
+ if ( !empty( $retina ) ) {
28
+ $count++;
29
+ $retinized_srcset[(int)$s * 2] = array(
30
+ 'url' => $retina,
31
+ 'descriptor' => 'w',
32
+ 'value' => (int)$s * 2 );
33
+ }
34
+ }
35
+ wr2x_log( "WP's srcset: " . $count . " retina files added out of " . $total . " image sizes" );
36
+ return $retinized_srcset;
37
+ }
38
+
39
+ function wr2x_wp_calculate_image_sizes( $srcset, $size ) {
40
+ }
41
+
42
+ function wr2x_wp_get_attachment_image_attributes( $srcset, $size ) {
43
+ }
44
+
45
+ ?>
wr2x_retina-dashboard.php ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_action( 'admin_menu', 'wr2x_admin_menu_dashboard' );
4
+
5
+ /**
6
+ *
7
+ * RETINA DASHBOARD
8
+ *
9
+ */
10
+
11
+ function wr2x_admin_menu_dashboard () {
12
+ global $wr2x_admin;
13
+ $refresh = isset ( $_GET[ 'refresh' ] ) ? $_GET[ 'refresh' ] : 0;
14
+ $clearlogs = isset ( $_GET[ 'clearlogs' ] ) ? $_GET[ 'clearlogs' ] : 0;
15
+ $ignore = isset ( $_GET[ 'ignore' ] ) ? $_GET[ 'ignore' ] : false;
16
+ if ( $ignore ) {
17
+ if ( !$wr2x_admin->is_pro() ) {
18
+ echo "<div class='error' style='margin-top: 20px;'><p>";
19
+ _e( "Ignore is a Pro feature.", 'wp-retina-2x' );
20
+ echo "</p></div>";
21
+ }
22
+ else
23
+ wr2x_add_ignore( $ignore );
24
+ }
25
+ if ( $refresh ) {
26
+ wr2x_calculate_issues();
27
+ }
28
+ if ( $clearlogs ) {
29
+ if ( file_exists( plugin_dir_path( __FILE__ ) . '/wp-retina-2x.log' ) ) {
30
+ unlink( plugin_dir_path( __FILE__ ) . '/wp-retina-2x.log' );
31
+ }
32
+ }
33
+ $flagged = count( wr2x_get_issues() );
34
+ $warning_title = __( "Retina images", 'wp-retina-2x' );
35
+ $menu_label = sprintf( __( 'Retina %s' ), "<span class='update-plugins count-$flagged' title='$warning_title'><span class='update-count'>" . number_format_i18n( $flagged ) . "</span></span>" );
36
+ add_media_page( 'Retina', $menu_label, 'manage_options', 'wp-retina-2x', 'wpr2x_wp_retina_2x' );
37
+ }
38
+
39
+ function wpr2x_wp_retina_2x() {
40
+ global $wr2x_admin;
41
+ $hide_ads = get_option( 'meowapps_hide_ads', false );
42
+ $view = isset ( $_GET[ 'view' ] ) ? $_GET[ 'view' ] : 'issues';
43
+ $paged = isset ( $_GET[ 'paged' ] ) ? $_GET[ 'paged' ] : 1;
44
+ $s = isset( $_GET[ 's' ] ) && !empty( $_GET[ 's' ] ) ? sanitize_text_field( $_GET[ 's' ] ) : null;
45
+ $issues = $count = 0;
46
+ $posts_per_page = 15; // TODO: HOW TO GET THE NUMBER OF MEDIA PER PAGES? IT IS NOT get_option('posts_per_page');
47
+ $issues = wr2x_get_issues();
48
+ $ignored = wr2x_get_ignores();
49
+
50
+ echo '<div class="wrap">';
51
+ echo $wr2x_admin->display_title( "WP Retina 2x" );
52
+ echo '<p></p>';
53
+
54
+ if ( $wr2x_admin->is_pro() && $view == 'issues' ) {
55
+ global $wpdb;
56
+ $totalcount = $wpdb->get_var( $wpdb->prepare( "
57
+ SELECT COUNT(*)
58
+ FROM $wpdb->posts p
59
+ WHERE post_status = 'inherit'
60
+ AND post_type = 'attachment'" . wr2x_create_sql_if_wpml_original() . "
61
+ AND post_title LIKE %s
62
+ AND ( post_mime_type = 'image/jpeg' OR
63
+ post_mime_type = 'image/png' OR
64
+ post_mime_type = 'image/gif' )
65
+ ", '%' . $s . '%' ) );
66
+ $postin = count( $issues ) < 1 ? array( -1 ) : $issues;
67
+ $query = new WP_Query(
68
+ array(
69
+ 'post_status' => 'inherit',
70
+ 'post_type' => 'attachment',
71
+ 'post__in' => $postin,
72
+ 'paged' => $paged,
73
+ 'posts_per_page' => $posts_per_page,
74
+ 's' => $s
75
+ )
76
+ );
77
+ }
78
+ else if ( $wr2x_admin->is_pro() && $view == 'ignored' ) {
79
+ global $wpdb;
80
+ $totalcount = $wpdb->get_var( $wpdb->prepare( "
81
+ SELECT COUNT(*)
82
+ FROM $wpdb->posts p
83
+ WHERE post_status = 'inherit'
84
+ AND post_type = 'attachment'" . wr2x_create_sql_if_wpml_original() . "
85
+ AND post_title LIKE %s
86
+ AND ( post_mime_type = 'image/jpeg' OR
87
+ post_mime_type = 'image/jpg' OR
88
+ post_mime_type = 'image/png' OR
89
+ post_mime_type = 'image/gif' )
90
+ ", '%' . $s . '%' ) );
91
+ $postin = count( $ignored ) < 1 ? array( -1 ) : $ignored;
92
+ $query = new WP_Query(
93
+ array(
94
+ 'post_status' => 'inherit',
95
+ 'post_type' => 'attachment',
96
+ 'post__in' => $postin,
97
+ 'paged' => $paged,
98
+ 'posts_per_page' => $posts_per_page,
99
+ 's' => $s
100
+ )
101
+ );
102
+ }
103
+ else {
104
+ $query = new WP_Query(
105
+ array(
106
+ 'post_status' => 'inherit',
107
+ 'post_type' => 'attachment',
108
+ 'post_mime_type' => 'image/jpeg,image/gif,image/jpg,image/png',
109
+ 'paged' => $paged,
110
+ 'posts_per_page' => $posts_per_page,
111
+ 's' => $s
112
+ )
113
+ );
114
+
115
+ //$s
116
+ $totalcount = $query->found_posts;
117
+ }
118
+
119
+ $issues_count = count( $issues );
120
+
121
+ // If 'search', then we need to clean-up the issues count
122
+ if ( $s && $issues_count > 0 ) {
123
+ global $wpdb;
124
+ $issues_count = $wpdb->get_var( $wpdb->prepare( "
125
+ SELECT COUNT(*)
126
+ FROM $wpdb->posts p
127
+ WHERE id IN ( " . implode( ',', $issues ) . " )" . wr2x_create_sql_if_wpml_original() . "
128
+ AND post_title LIKE %s
129
+ ", '%' . $s . '%' ) );
130
+ }
131
+
132
+ $results = array();
133
+ $count = $query->found_posts;
134
+ $pagescount = $query->max_num_pages;
135
+ foreach ( $query->posts as $post ) {
136
+ $info = wr2x_retina_info( $post->ID );
137
+ array_push( $results, array( 'post' => $post, 'info' => $info ) );
138
+ }
139
+ ?>
140
+
141
+ <div style='background: #FFF; padding: 5px; border-radius: 4px; height: 28px; box-shadow: 0px 0px 6px #C2C2C2;'>
142
+
143
+ <!-- REFRESH -->
144
+ <a id='wr2x_refresh' href='?page=wp-retina-2x&view=issues&refresh=true' class='button' style='float: left;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php echo plugin_dir_url( __FILE__ ); ?>img/refresh.png' /><?php _e("Refresh", 'wp-retina-2x'); ?></a>
145
+
146
+ <!-- SEARCH -->
147
+ <form id="posts-filter" action="upload.php" method="get">
148
+ <p class="search-box" style='margin-left: 5px; float: left;'>
149
+ <input type="search" name="s" value="<?php echo $s ? $s : ""; ?>">
150
+ <input type="hidden" name="page" value="wp-retina-2x">
151
+ <input type="hidden" name="view" value="<?php echo $view; ?>">
152
+ <input type="hidden" name="paged" value="<?php echo $paged; ?>">
153
+ <input type="submit" class="button" value="Search">
154
+ </p>
155
+ </form>
156
+
157
+ <!-- REMOVE BUTTON ALL -->
158
+ <a id='wr2x_remove_button_all' onclick='wr2x_delete_all()' class='button button-red' style='float: right;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php echo plugin_dir_url( __FILE__ ); ?>img/burn.png' /><?php _e("Bulk Delete (Retina Only)", 'wp-retina-2x'); ?></a>
159
+
160
+ <!-- GENERATE ALL -->
161
+ <a id='wr2x_generate_button_all' onclick='wr2x_generate_all()' class='button-primary' style='float: right; margin-right: 5px;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php echo plugin_dir_url( __FILE__ ); ?>img/photo-album--plus.png' /><?php _e("Bulk Generate (Thumbnails & Retina)", 'wp-retina-2x'); ?></a>
162
+
163
+
164
+ <!-- PROGRESS -->
165
+ <span style='margin-left: 12px; font-size: 13px; top: 5px; position: relative; color: #24547C; font-weight: bold;' id='wr2x_progression'></span>
166
+
167
+ </div>
168
+
169
+ <?php
170
+ if (isset ( $_GET[ 'clearlogs' ] ) ? $_GET[ 'clearlogs' ] : 0) {
171
+ echo "<div class='updated' style='margin-top: 20px;'><p>";
172
+ _e( "The logs have been cleared.", 'wp-retina-2x' );
173
+ echo "</p></div>";
174
+ }
175
+
176
+ $active_sizes = wr2x_get_active_image_sizes();
177
+ $full_size_needed = get_option( "wr2x_full_size" );
178
+
179
+ $max_width = 0;
180
+ $max_height = 0;
181
+ foreach ( $active_sizes as $name => $active_size ) {
182
+ if ( $active_size['height'] != 9999 && $active_size['height'] > $max_height ) {
183
+ $max_height = $active_size['height'];
184
+ }
185
+ if ( $active_size['width'] != 9999 && $active_size['width'] > $max_width ) {
186
+ $max_width = $active_size['width'];
187
+ }
188
+ }
189
+ $max_width = $max_width * 2;
190
+ $max_height = $max_height * 2;
191
+
192
+ $upload_max_size = wr2x_get_max_filesize();
193
+ ?>
194
+
195
+ <p>
196
+ <?php printf( __( 'The full-size images should have a resolution of <b>%d×%d</b> at least for the plugin to be able generate the <b>%d retina images</b> required by your website.', 'wp-retina-2x' ), $max_width, $max_height, count( $active_sizes ) ); ?>
197
+ <?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 ); ?>
198
+ <?php _e("You can upload or replace the images by drag & drop.", 'wp-retina-2x' ); ?>
199
+ <?php printf( __( "Your PHP configuration allows uploads of <b>%dMB</b> maximum.", 'wp-retina-2x'), $upload_max_size / 1000000 ); ?>
200
+
201
+ <?php
202
+ if ( file_exists( plugin_dir_path( __FILE__ ) . '/wp-retina-2x.log' ) ) {
203
+ 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__ ) );
204
+ }
205
+ ?>
206
+ </p>
207
+
208
+ <!--
209
+ It is activated through a serial key that you can buy here: <a href='http://apps.meow.fr/wp-retina-2x/'>Meow Apps</a>. -->
210
+
211
+ <?php
212
+ if ( !$wr2x_admin->is_pro() && !$hide_ads ) {
213
+ echo '<div class="updated"><p>';
214
+ 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> :) The serial key for the Pro has to be inserted in your Settings > Retina > Pro tab. Thank you :)<br /><br /><a class="button-primary" href="http://meowapps.com/wp-retina-2x/" target="_blank">Get the serial key for the Pro</a>', 'wp-retina-2x' );
215
+ echo '</p></div>';
216
+ }
217
+ ?>
218
+
219
+ <div id='wr2x-pages'>
220
+ <?php
221
+ echo paginate_links(array(
222
+ 'base' => '?page=wp-retina-2x&s=' . urlencode($s) . '&view=' . $view . '%_%',
223
+ 'current' => $paged,
224
+ 'format' => '&paged=%#%',
225
+ 'total' => $pagescount,
226
+ 'prev_next' => false
227
+ ));
228
+ ?>
229
+ </div>
230
+
231
+ <ul class="subsubsub">
232
+ <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> |
233
+
234
+ <?php if ( $wr2x_admin->is_pro() ): ?>
235
+
236
+ <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> |
237
+ <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>
238
+
239
+ <?php else: ?>
240
+
241
+ <li class="all"><span><?php _e( "Issues", 'wp-retina-2x' ); ?></span> <span class="count">(<?php echo $issues_count; ?>)</span></li> |
242
+ <li class="all"><span><?php _e( "Ignored", 'wp-retina-2x' ); ?></span> <span class="count">(<?php echo count( $ignored ); ?>)</span></li>
243
+
244
+ <?php endif; ?>
245
+
246
+
247
+ </ul>
248
+ <table class='wp-list-table widefat fixed media wr2x-table'>
249
+ <thead><tr>
250
+ <?php
251
+ echo "<th style='width: 56px;'>Thumbnail</th>";
252
+ echo "<th style=' width: 360px;'>" . __( "Base image", 'wp-retina-2x' ) . "</th>";
253
+ echo "<th style=''>" . __( "Media Sizes<br />Retina-ized", 'wp-retina-2x' ) . "</th>";
254
+ echo "<th style=''>" . __( "Full-Size<br/><b>Replace</b>", 'wp-retina-2x' ) . "</th>";
255
+ echo "<th style=''>" . __( "Full-Size Retina", 'wp-retina-2x' ) . "</th>";
256
+ echo "<th style=''>" . __( "Full-Size Retina<br/><b>Upload</b>", 'wp-retina-2x' ) . "</th>";
257
+ ?>
258
+ </tr></thead>
259
+ <tbody>
260
+ <?php
261
+ foreach ($results as $index => $attr) {
262
+ $post = $attr['post'];
263
+ $info = $attr['info'];
264
+ $meta = wp_get_attachment_metadata( $post->ID );
265
+ // Let's clean the issues status
266
+ if ( $view != 'issues' ) {
267
+ wr2x_update_issue_status( $post->ID, $issues, $info );
268
+ }
269
+ if ( isset( $meta ) && isset( $meta['width'] ) ) {
270
+ $original_width = $meta['width'];
271
+ $original_height = $meta['height'];
272
+ }
273
+
274
+ $attachmentsrc = wp_get_attachment_image_src( $post->ID, 'thumbnail' );
275
+ echo "<tr class='wr2x-file-row' postId='" . $post->ID . "'>";
276
+ echo "<td class='wr2x-image wr2x-info-thumbnail'><img src='" . $attachmentsrc[0] . "' /></td>";
277
+ 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 />' .
278
+ "<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>";
279
+ echo "<div class='actions'>";
280
+ 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>";
281
+ if ( !wr2x_is_ignore( $post->ID ) )
282
+ 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>";
283
+ echo " <a style='position: relative;' class='wr2x-button wr2x-button-view'>" . __( "DETAILS", 'wp-retina-2x' ) . "</a>";
284
+ echo "</div></td>";
285
+
286
+ // Media Sizes Retina-ized
287
+ echo '<td id="wr2x-info-' . $post->ID . '" style="padding-top: 10px;" class="wr2x-info">';
288
+ echo wpr2x_html_get_basic_retina_info( $post, $info );
289
+ echo "</td>";
290
+
291
+ if ( $wr2x_admin->is_pro() ) {
292
+ // Full-Size Replace
293
+ echo "<td class='wr2x-fullsize-replace'><div class='wr2x-dragdrop'></div>";
294
+ echo "</td>";
295
+ // Full-Size Retina
296
+ echo '<td id="wr2x-info-full-' . $post->ID . '" class="wr2x-image wr2x-info-full">';
297
+ echo wpr2x_html_get_basic_retina_info_full( $post->ID, $info );
298
+ echo "</td>";
299
+ // Full-Size Retina Upload
300
+ echo "<td class='wr2x-fullsize-retina-upload'>";
301
+ echo "<div class='wr2x-dragdrop'></div>";
302
+ echo "</td>";
303
+ }
304
+ else
305
+ echo "<td colspan='3' style='text-align: center; background: #F9F9F9;'><small><br />PRO VERSION ONLY</small></td>";
306
+ echo "</tr>";
307
+ }
308
+ ?>
309
+ </tbody>
310
+ </table>
311
+ </div>
312
+
313
+ <?php
314
+ }
315
+ ?>
wr2x_retina_uploader.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Based on code provided by gmazzap on
4
+ // http://wordpress.stackexchange.com/questions/126969/what-filter-should-i-use-to-insert-a-button-inside-on-mediaadd-new
5
+
6
+ class WR2x_Retina_Uploader {
7
+
8
+ static function getLabel() {
9
+ // change here the label of your custom upload button
10
+ return 'Add Full Retina';
11
+ }
12
+
13
+ static function getUrl() {
14
+ // change here the url of your custom upload button
15
+ return add_query_arg( array( 'page' => 'my-custom-upload' ), admin_url( 'upload.php' ) );
16
+ }
17
+
18
+ function render() {
19
+ // this is the function that render your custom upload system
20
+ if ( !current_user_can( 'upload_files' ) ) {
21
+ echo '<h2>Sorry, you are not allowed to upload files.</h2>';
22
+ return;
23
+ }
24
+ ?>
25
+ <div class="wrap">
26
+ <h2>Upload New Media as a Retina for Full Size</h2>
27
+ <p>The image you are uploading here will be used as a Retina for Full Size. It means that whatever its size is, the normal size will be created depending on it (width and height divided by two)</p>
28
+ <div id="plupload-upload-ui" class="hide-if-no-js drag-drop">
29
+ <div id="drag-drop-area" style="position: relative;">
30
+ <div class="drag-drop-inside">
31
+ <p class="drag-drop-info">Drop files here</p>
32
+ <p>or</p>
33
+ <p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="Select Files" class="button" style="position: relative; z-index: 1;"></p>
34
+ </div>
35
+ </div>
36
+
37
+
38
+ </div>
39
+ <?php
40
+ }
41
+
42
+ function __construct() {
43
+ add_action( 'load-upload.php', array( $this, 'indexButton' ) );
44
+ add_action( 'admin_menu', array( $this, 'submenu') );
45
+ add_action( 'wp_before_admin_bar_render', array( $this, "adminBar" ) );
46
+ add_action( 'post-plupload-upload-ui', array( $this, 'mediaButton' ) );
47
+ }
48
+
49
+ function submenu() {
50
+ add_media_page( self::getLabel(), self::getLabel(), 'upload_files', 'my-custom-upload', array( $this, 'render') );
51
+ }
52
+
53
+ function adminBar() {
54
+ if ( !current_user_can( 'upload_files' ) || !is_admin_bar_showing() ) return;
55
+ global $wp_admin_bar;
56
+ $wp_admin_bar->add_node( array(
57
+ 'parent' => 'new-content',
58
+ 'id' => 'custom-upload-link',
59
+ 'title' => self::getLabel(),
60
+ 'href' => self::getUrl()
61
+ ) );
62
+ }
63
+
64
+
65
+ function mediaButton() {
66
+ if ( current_user_can( 'upload_files' ) ) {
67
+ echo '<div><p align="center">';
68
+ echo '<input id="custom-browse-button" type="button" value="' . self::getLabel() . '" class="button" />';
69
+ echo '</p></div>';
70
+ $this->mediaButtonScript();
71
+ }
72
+ }
73
+
74
+ function mediaButtonScript() {
75
+ if ( !current_user_can( 'upload_files' ) ) return;
76
+ ?>
77
+ <script>
78
+ jQuery(document).on('click', '#custom-browse-button', function(e) {
79
+ e.preventDefault();
80
+ window.location = '<?php echo self::getUrl(); ?>';
81
+ });
82
+ </script>
83
+ <?php
84
+ }
85
+
86
+ function indexButton() {
87
+ if ( !current_user_can( 'upload_files' ) ) return;
88
+ add_filter( 'esc_html', array(__CLASS__, 'h2Button'), 999, 2 );
89
+ }
90
+
91
+ static function h2Button( $safe_text, $text ) {
92
+ if ( !current_user_can( 'upload_files' ) ) return $safe_text;
93
+ if ( $text === __('Media Library') && did_action( 'all_admin_notices' ) ) {
94
+ remove_filter( 'esc_html', array(__CLASS__, 'h2Button'), 999, 2 );
95
+ $format = ' <a href="%s" class="add-new-h2">%s</a>';
96
+ $mybutton = sprintf($format, esc_url(self::getUrl()), esc_html(self::getLabel()) );
97
+ $safe_text .= $mybutton;
98
+ }
99
+ return $safe_text;
100
+ }
101
+
102
+ }
103
+
104
+ $ui = new WR2x_Retina_Uploader;
wr2x_vt_resize.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !function_exists( 'wr2x_vt_resize' ) ) {
4
+ function wr2x_vt_resize( $file_path, $width, $height, $crop, $newfile, $customCrop = false ) {
5
+ $crop_params = $crop == '1' ? true : $crop;
6
+ $orig_size = getimagesize( $file_path );
7
+ $image_src[0] = $file_path;
8
+ $image_src[1] = $orig_size[0];
9
+ $image_src[2] = $orig_size[1];
10
+ $file_info = pathinfo( $file_path );
11
+ $newfile_info = pathinfo( $newfile );
12
+ $extension = '.' . $newfile_info['extension'];
13
+ $no_ext_path = $file_info['dirname'] . '/' . $file_info['filename'];
14
+ $cropped_img_path = $no_ext_path . '-' . $width . 'x' . $height . "-tmp" . $extension;
15
+ $image = wp_get_image_editor( $file_path );
16
+
17
+ if ( is_wp_error( $image ) ) {
18
+ wr2x_log( "Resize failure: " . $image->get_error_message() );
19
+ error_log( "Resize failure: " . $image->get_error_message() );
20
+ return null;
21
+ }
22
+
23
+ // Resize or use Custom Crop
24
+ if ( !$customCrop )
25
+ $image->resize( $width, $height, $crop_params );
26
+ else
27
+ $image->crop( $customCrop['x'] * $customCrop['scale'], $customCrop['y'] * $customCrop['scale'], $customCrop['w'] * $customCrop['scale'], $customCrop['h'] * $customCrop['scale'], $width, $height, false );
28
+
29
+ // Quality
30
+ $quality = get_option( 'wr2x_quality', 90 );
31
+ $image->set_quality( $quality );
32
+
33
+ $saved = $image->save( $cropped_img_path );
34
+ if ( is_wp_error( $saved ) ) {
35
+ $error = $saved->get_error_message();
36
+ trigger_error( "Retina: Could not create/resize image " . $file_path . " to " . $newfile . ": " . $error , E_WARNING );
37
+ error_log( "Retina: Could not create/resize image " . $file_path . " to " . $newfile . ":" . $error );
38
+ return null;
39
+ }
40
+ if ( rename( $saved['path'], $newfile ) )
41
+ $cropped_img_path = $newfile;
42
+ else {
43
+ trigger_error( "Retina: Could not move " . $saved['path'] . " to " . $newfile . "." , E_WARNING );
44
+ error_log( "Retina: Could not move " . $saved['path'] . " to " . $newfile . "." );
45
+ return null;
46
+ }
47
+ $new_img_size = getimagesize( $cropped_img_path );
48
+ $new_img = str_replace( basename( $image_src[0] ), basename( $cropped_img_path ), $image_src[0] );
49
+ $vt_image = array ( 'url' => $new_img, 'width' => $new_img_size[0], 'height' => $new_img_size[1] );
50
+ return $vt_image;
51
+ }
52
+ }