WP Photo Album Plus - Version 8.1.07.002

Version Description

= 8.1.06 =

  • This version addresses various bug fixes, feature requests and security fixes.
Download this release

Release Info

Developer opajaap
Plugin Icon wp plugin WP Photo Album Plus
Version 8.1.07.002
Comparing to
See all releases

Code changes from version 8.1.07.001 to 8.1.07.002

changelog.txt CHANGED
@@ -5,6 +5,8 @@ WP Photo Album Plus Changelog
5
  * Maintenance release
6
  * Clicking the 'back to thumbnails' button in the slideshow breadcrumb now always returns to the right page,
7
  hilgliting the right item, regardless of either page size.
 
 
8
 
9
  = 8.1.06 =
10
 
5
  * Maintenance release
6
  * Clicking the 'back to thumbnails' button in the slideshow breadcrumb now always returns to the right page,
7
  hilgliting the right item, regardless of either page size.
8
+ * Fixed a possible conflict with wp customizer.
9
+ * Fixed a db warning at initial installation.
10
 
11
  = 8.1.06 =
12
 
theme/wppa-theme.php CHANGED
@@ -3,11 +3,11 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the albums/photos/slideshow in a page or post
6
- * Version 8.0.08.008
7
  */
8
  function wppa_theme() {
9
 
10
- global $wppa_version; $wppa_version = '8.0.08.008'; // The version number of this file
11
  global $wppa;
12
  global $wppa_show_statistics; // Can be set to true by a custom page template
13
  global $wppa_empty_content;
@@ -18,460 +18,416 @@ global $wppa_empty_content;
18
  $n_thumb_pages = '0'; // "
19
  $mocc = wppa( 'mocc' );
20
 
21
- // Delayed displsy?
22
- if ( wppa( 'delay' ) && ! wppa_switch( 'defer_javascript' ) ) {
23
 
24
- // Open container
25
- wppa_container( 'open' );
26
 
27
- // Get basic urls
28
- $link_url = wppa_get_permalink();
29
- $ajax_url = wppa_get_ajaxlink();
30
- $extra_url = wppa_get_extra_url();
31
 
32
- // Almost ready
33
- $link_url .= $extra_url;
34
- $ajax_url .= $extra_url;
35
 
36
- // Compress
37
- $link_url = wppa_trim_wppa_( $link_url );
38
- $ajax_url = wppa_trim_wppa_( $ajax_url );
39
 
40
- // Encrypt
41
- $link_url = wppa_encrypt_url( $link_url );
42
- $ajax_url = wppa_encrypt_url( $ajax_url );
 
 
 
 
43
 
44
- // Pretty
45
- $link_url = wppa_convert_to_pretty( $link_url );
 
46
 
47
- $link_url = str_replace( '&', '&', $link_url );
48
- $ajax_url = str_replace( '&', '&', $ajax_url );
 
49
 
50
- // Create script tag
51
- $html = "\n" . '<script>jQuery(document).ready(function(){wppaDoAjaxRender(' . wppa( 'mocc' ) . ', \'' . $ajax_url . '\', \'' . $link_url . '\');});</script>';
52
 
53
- // Output the results
54
- wppa_out( $html );
 
55
 
56
- // Close container
57
- wppa_container( 'close' );
 
58
 
59
- } // Delayed
 
 
 
60
 
61
- // Not delayed
62
- else {
63
-
64
- // Open container
65
- wppa_container( 'open' );
66
-
67
- // Show statistics if set so by the page template
68
- if ( $wppa_show_statistics ) wppa_statistics();
69
-
70
- // Display breadcrumb navigation only if it is set in the settings page
71
- wppa_breadcrumb( 'optional' );
72
-
73
-
74
- if ( wppa_page( 'albums' ) ) { // Page 'Albums' requested
75
-
76
- // Init for possible alt thumbsize on masonry
77
- $counter_thumbs = '0';
78
- $is_alt_thumbsize = false;
79
- $alb_id = wppa( 'start_album' );
80
- if ( wppa_is_int( $alb_id ) && $alb_id > '0' ) {
81
- $is_alt_thumbsize = wppa_get_album_item( $alb_id, 'alt_thumbsize' ) == 'yes';
82
- }
83
-
84
- // Get the albums and the thumbs and the number of pages for each set
85
- $albums = wppa_get_albums(); // Get the albums
86
- $n_album_pages = wppa_get_npages( 'albums', $albums ); // Get the number of album pages
87
-
88
- if ( wppa_opt( 'thumbtype' ) != 'none' ) {
89
- $thumbs = wppa_get_thumbs(); // Get the Thumbs
90
- } else $thumbs = false;
91
-
92
- $wanted_empty = wppa_is_wanted_empty( $thumbs ); // See if we need to display an empty thumbnail area
93
-
94
- $n_thumb_pages = wppa_get_npages( 'thumbs', $thumbs ); // Get the number of thumb pages
95
- if ( $n_thumb_pages == '0' && ! $wanted_empty ) $thumbs = false; // No pages: no thumbs. Maybe want covers only
96
- if ( $wanted_empty ) $n_thumb_pages = '1';
97
-
98
- // Get total number of pages
99
- if ( ! wppa_is_pagination() ) $totpag = '1'; // If both pagination is off, there is only one page
100
- else $totpag = $n_album_pages + $n_thumb_pages;
101
-
102
- // Make pagelinkbar if requested on top
103
- if ( wppa_opt( 'pagelink_pos' ) == 'top' || wppa_opt( 'pagelink_pos' ) == 'both' ) {
104
- wppa_page_links( $totpag, $curpage );
105
- }
106
-
107
- // Process the albums
108
- if ( ! wppa_switch( 'thumbs_first' ) ) {
109
- if ( $albums ) {
110
- $counter_albums = '0';
111
- wppa_album_list( 'open' ); // Open Albums sub-container
112
- foreach ( $albums as $album ) { // Loop the albums
113
- $counter_albums++;
114
- if ( wppa_onpage( 'albums', $counter_albums, $curpage ) ) {
115
- wppa_album_cover( $album['id'] ); // Show the cover
116
- $didsome = true;
117
- } // End if on page
118
- }
119
- wppa_album_list( 'close' ); // Close Albums sub-container
120
- } // If albums
121
- }
122
-
123
- if ( $didsome && wppa_is_pagination() ) $thumbs = false; // Pag on and didsome: force a pagebreak by faking no thumbs
124
- if ( is_array( $thumbs ) && ! count( $thumbs ) && ! $wanted_empty ) $thumbs = false; // Less than treshold value
125
- if ( wppa_switch( 'thumbs_first' ) && $curpage > $n_thumb_pages ) $thumbs = false; // If thumbs done, do not display an empty thumbarea
126
-
127
- // Process the thumbs
128
- if ( $thumbs || $wanted_empty )
129
- if ( ! $wanted_empty || ! wppa_switch( 'thumbs_first' ) || wppa_get_curpage() == '1' )
130
- if ( ! $wanted_empty || wppa_switch( 'thumbs_first' ) || wppa_get_curpage() == $totpag ) {
131
-
132
- // As covers
133
- if ( wppa_opt( 'thumbtype' ) == 'ascovers' ||
134
- wppa_opt( 'thumbtype' ) == 'ascovers-mcr' ) { // Do the thumbs As covers
135
- wppa_thumb_list( 'open' ); // Open Thumblist sub-container
136
- $relpage = wppa_switch( 'thumbs_first' ) ? $curpage : $curpage - $n_album_pages;
137
- foreach ( $thumbs as $tt ) : global $thumb; $thumb = $tt; // Loop the Thumbs
138
- $counter_thumbs++;
139
- if ( wppa_onpage( 'thumbs', $counter_thumbs, $relpage ) ) {
140
  $didsome = true;
141
- wppa_thumb_ascover( $thumb['id'] ); // Show Thumb as cover
142
  } // End if on page
143
- endforeach;
144
- wppa_thumb_list( 'close' ); // Close Thumblist sub-container
145
- } // As covers
146
-
147
- // Masonry vertical
148
- elseif ( wppa_opt( 'thumbtype' ) == 'masonry-v' ) { // Masonry
149
-
150
- // The header
151
- wppa_thumb_area( 'open' ); // Open Thumbarea sub-container
152
- wppa_popup(); // Prepare Popup box
153
- wppa_album_name( 'top' ); // Optionally display album name
154
- wppa_album_desc( 'top' ); // Optionally display album description
155
-
156
- // Init
157
- $relpage = wppa_switch( 'thumbs_first' ) ? $curpage : $curpage - $n_album_pages;
158
- $cont_width = wppa_get_container_width();
159
- $margin = wppa_opt( 'tn_margin' );
160
- if ( wppa_is_mobile() ) $margin = ceil( $margin / 2 );
161
- $count_cols = ceil( $cont_width / ( wppa_opt( $is_alt_thumbsize ? 'thumbsize_alt' : 'thumbsize' ) + $margin ) );
162
- if ( wppa_is_mobile() ) {
163
- $count_cols = ceil( $count_cols / 2 );
164
- }
165
- $correction = $margin * ( $cont_width / $count_cols ) / 100;
166
-
167
- // Init the table
168
- wppa_out( '<table class="wppa-masonry" style="margin-top:3px;" ><tbody class="wppa-masonry" ><tr class="wppa-masonry" >' );
169
-
170
- // Init the columns
171
- $col_headers = array();
172
- $col_contents = array();
173
- $col_heights = array();
174
- $col_widths = array();
175
-
176
- for ( $col = 0; $col < $count_cols; $col++ ) {
177
- $col_headers[$col] = '';
178
- $col_contents[$col] = '';
179
- $col_heights[$col] = 0;
180
- $col_widths[$col] = 100;
181
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
 
183
- // Process the thumbnails
184
- $col = '0';
185
- if ( $thumbs ) foreach ( $thumbs as $tt ) {
186
- $id = $tt['id'];
187
- $counter_thumbs++;
188
- if ( wppa_onpage( 'thumbs', $counter_thumbs, $relpage ) ) {
189
- $col_contents[$col] .= wppa_get_thumb_masonry( $id );
190
- $col_heights[$col] += ( $correction + wppa_get_thumby( $id ) ) / ( $correction + wppa_get_thumbx( $id ) ) * $col_widths[$col];
191
- $col += '1';
192
- if ( $col == $count_cols ) {
193
- $col = '0';
194
- }
195
- $didsome = true;
196
  }
 
197
  }
 
198
 
199
- // Find longest column
200
- $long = 0;
201
- for ( $col = 0; $col < $count_cols; $col++ ) {
202
- if ( $col_heights[$col] > $long ) $long = $col_heights[$col];
203
- }
204
 
205
- // Adjust column widths to resize lengths to equal lengths
206
- for ( $col = 0; $col < $count_cols; $col++ ) {
207
- if ( $col_heights[$col] ) {
208
- $col_widths[$col] = $long / $col_heights[$col] * $col_widths[$col];
209
- }
210
  }
 
211
 
212
- // Adjust column widths to total 100
213
- $wide = 0;
214
- for ( $col = 0; $col < $count_cols; $col++ ) {
215
- $wide += $col_widths[$col];
216
- }
217
- for ( $col = 0; $col < $count_cols; $col++ ) {
218
- $col_widths[$col] = $col_widths[$col] * 100 / $wide;
219
- }
220
 
221
- // Make column headers
222
- for ( $col = 0; $col < $count_cols; $col++ ) {
223
- $col_headers[$col] = '<td style="width: '.$col_widths[$col].'%; vertical-align:top;" class="wppa-masonry" >';
224
- }
225
 
226
- // Add the columns to the output stream
227
- for ( $col = 0; $col < $count_cols; $col++ ) {
228
- wppa_out( $col_headers[$col] );
229
- wppa_out( $col_contents[$col] );
230
- wppa_out( '</td>' );
231
- }
232
 
233
- // Close the table
234
- wppa_out( '</tr></tbody></table>' );
235
-
236
- // The footer
237
- wppa_album_name( 'bottom' ); // Optionally display album name
238
- wppa_album_desc( 'bottom' ); // Optionally display album description
239
- wppa_thumb_area( 'close' ); // Close Thumbarea sub-container
240
- } // Masonry-v
241
-
242
- // Masonry horizontal
243
- elseif ( wppa_opt( 'thumbtype' ) == 'masonry-h' ) { // Masonry
244
-
245
- // The header
246
- wppa_thumb_area( 'open' ); // Open Thumbarea sub-container
247
- wppa_popup(); // Prepare Popup box
248
- wppa_album_name( 'top' ); // Optionally display album name
249
- wppa_album_desc( 'top' ); // Optionally display album description
250
-
251
- // Init
252
- $relpage = wppa_switch( 'thumbs_first' ) ? $curpage : $curpage - $n_album_pages;
253
- $cont_width = wppa_get_container_width( 'netto' );
254
- $correction = wppa_opt( 'tn_margin' );
255
-
256
- // Init the table
257
- wppa_out( '<table class="wppa-masonry wppa-masonry-h" style="margin-top:3px;" ><tbody class="wppa-masonry" >' );
258
-
259
- // Process the thumbnails
260
- $row_content = '';
261
- $row_width = 0;
262
- $target_row_height = wppa_opt( $is_alt_thumbsize ? 'thumbsize_alt' : 'thumbsize' ) * 0.75 + $correction;
263
- $rw_count = 0;
264
- $tr_count = '1';
265
- $done_count = 0;
266
- $last = false;
267
- $max_row_height = $target_row_height * 0.8; // Init keep track for last
268
- if ( $thumbs ) foreach ( $thumbs as $tt ) {
269
- $id = $tt['id'];
270
- $counter_thumbs++;
271
- if ( wppa_onpage( 'thumbs', $counter_thumbs, $relpage ) ) {
272
- $row_content .= wppa_get_thumb_masonry( $tt['id'] );
273
- $rw_count += 1;
274
- $row_width += wppa_get_thumbratioxy( $id ) * ( $target_row_height - $correction );
275
- $didsome = true;
 
 
 
 
 
 
 
 
276
  }
277
- $done_count += 1;
278
- $last = $done_count == count( $thumbs );
279
- if ( $row_width > $cont_width || $last ) {
280
- $tot_marg = $rw_count * $correction;
281
- $row_height = $row_width ? ( ( $target_row_height - $correction ) * ( $cont_width - $tot_marg ) / ( $row_width ) + $correction ) : '0';
282
- if ( ! $last ) {
283
- $max_row_height = max( $max_row_height, $row_height );
284
- }
285
- if ( $last && $row_height > wppa_get_thumby( $id ) ) {
286
- $row_height = $max_row_height;
287
- }
288
- $row_height_p = $row_height / $cont_width * 100;
289
- wppa_out( '<tr class="wppa-masonry" >' .
290
- '<td style="border:none;padding:0;margin:0" >' .
291
- '<div' .
292
- ' id="wppa-mas-h-'.$tr_count.'-'.wppa( 'mocc' ).'"' .
293
- ' style="height:'.$row_height.'px;"' .
294
- ' class="wppa-masonry"' .
295
- ' data-height-perc="'.$row_height_p.'"' .
296
- ' >');
297
- wppa_out( $row_content );
298
- wppa_out( '</div></td></tr>' );
299
- $row_content = '';
300
- $row_width = 0;
301
- $row_height = wppa_opt( 'thumbsize' );
302
- $rw_count = 0;
303
- $tr_count += '1';
304
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
  }
306
- wppa_out( '<tr class="wppa-masonry" ><td class="wppa-dummy" style="padding:0;border:none;" ></td></tr>' );
307
- wppa_out( '</tbody></table>' );
308
-
309
- // The footer
310
- wppa_album_name( 'bottom' ); // Optionally display album name
311
- wppa_album_desc( 'bottom' ); // Optionally display album description
312
- wppa_out( '<script type="text/javascript" >' . // Fix bug in IE and Chrome
313
- 'jQuery(document).ready(function(){wppaSetMasHorFrameWidthsForIeAndChrome(' . wppa( 'mocc' ) . ');});' .
314
- '</script>' );
315
- wppa_thumb_area( 'close' ); // Close Thumbarea sub-container
316
-
317
- } // Masonry-h
318
-
319
- // Masonry plus
320
- elseif ( wppa_opt( 'thumbtype' ) == 'masonry-plus' ) {
321
-
322
- // The header
323
- wppa_thumb_area( 'open' ); // Open Thumbarea sub-container
324
- wppa_popup(); // Prepare Popup box
325
- wppa_album_name( 'top' ); // Optionally display album name
326
- wppa_album_desc( 'top' ); // Optionally display album description
327
-
328
- // Init
329
- $relpage = wppa_switch( 'thumbs_first' ) ? $curpage : $curpage - $n_album_pages;
330
-
331
- // Process the thumbnails
332
- if ( $thumbs ) {
333
-
334
- // Open masonry contatiner
335
- $html = '
336
- <div
337
- id="grid-' . $mocc . '"
338
- class="grid-' . $mocc . ' grid-masonryplus"
339
- style="padding-top:6px;padding-bottom:6px;padding-right:6px;margin:0 auto;"
340
- >';
341
-
342
- // Add css
343
- $html .= '
344
- <style type="text/css" >
345
- .grid-item-' . $mocc . ' {
346
- line-height: 0;
347
- visibility: hidden;
348
- text-align: center;
349
- }
350
- .grid-item-' . $mocc . ' img {
351
- width: 100%;
352
- }
353
- </style>';
354
-
355
- // The thumbs
356
- foreach ( $thumbs as $tt ) {
357
- $counter_thumbs++;
358
-
359
- if ( wppa_onpage( 'thumbs', $counter_thumbs, $relpage ) ) {
360
-
361
- $didsome = true;
362
- $html .= '
363
- <div
364
- style=""
365
- id="grid-item-' . $mocc . '-' . wppa_encrypt_photo( $tt['id'] ) . '"
366
- class="grid-item grid-item-' . $mocc . '" >' .
367
- wppa_get_thumb_masonry( $tt['id'] ) . '
368
- </div>';
369
- }
370
  }
 
 
 
 
371
 
372
- // Close masonry container
373
- $html .= '</div><div style="clear:both" ></div>';
374
- }
375
- wppa_out( wppa_compress_html( $html ) );
376
-
377
- // The footer
378
- wppa_album_name( 'bottom' ); // Optionally display album name
379
- wppa_album_desc( 'bottom' ); // Optionally display album description
380
- wppa_thumb_area( 'close' ); // Close Thumbarea sub-container
381
- } // Masonry plus
382
-
383
- // Default
384
- elseif ( wppa_opt( 'thumbtype' ) == 'default' ) { // Do the thumbs As default
385
-
386
- // The header
387
- wppa_thumb_area( 'open' ); // Open Thumbarea sub-container
388
- wppa_popup(); // Prepare Popup box
389
- wppa_album_name( 'top' ); // Optionally display album name
390
- wppa_album_desc( 'top' ); // Optionally display album description
391
-
392
- // Init
393
- $relpage = wppa_switch( 'thumbs_first' ) ? $curpage : $curpage - $n_album_pages;
394
-
395
- // Process the thumbnails
396
- if ( $thumbs ) foreach ( $thumbs as $tt ) {
397
  $counter_thumbs++;
 
398
  if ( wppa_onpage( 'thumbs', $counter_thumbs, $relpage ) ) {
 
399
  $didsome = true;
400
- wppa_thumb_default( $tt['id'] ); // Show Thumb as default
401
- } // End if on page
 
 
 
 
 
 
402
  }
403
 
404
- // The footer
405
- wppa_album_name( 'bottom' ); // Optionally display album name
406
- wppa_album_desc( 'bottom' ); // Optionally display album description
407
- wppa_thumb_area( 'close' ); // Close Thumbarea sub-container
408
- } // As default
409
-
410
- // Unimplemented thumbnail type
411
- else {
412
- wppa_out( 'Unimplemented thumbnail type: ' . wppa_opt( 'thumbtype' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
413
  }
414
- } // If thumbs
415
-
416
- if ( $didsome && wppa_is_pagination() ) $albums = false; // Pag on and didsome: force a pagebreak by faking no albums
417
- if ( ! wppa_is_pagination() ) $n_thumb_pages = '0'; // Still on page one
418
-
419
- // Process the albums
420
- if ( wppa_switch( 'thumbs_first' ) ) {
421
- if ( $albums ) {
422
- $counter_albums = '0';
423
- wppa_album_list( 'open' ); // Open Albums sub-container
424
- foreach ( $albums as $album ) { // Loop the albums
425
- $counter_albums++;
426
- if ( wppa_onpage( 'albums', $counter_albums, $curpage - $n_thumb_pages ) ) {
427
- wppa_album_cover( $album['id'] ); // Show the cover
428
- $didsome = true;
429
- } // End if on page
430
- }
431
- wppa_album_list( 'close' ); // Close Albums sub-container
432
- } // If albums
433
- }
434
 
435
- // Make pagelinkbar if requested on bottom
436
- if ( wppa_opt( 'pagelink_pos' ) == 'bottom' || wppa_opt( 'pagelink_pos' ) == 'both' ) {
437
- wppa_page_links( $totpag, $curpage );
438
- }
 
439
 
440
- // Empty results?
441
- if ( ! $didsome && ! $wanted_empty ) {
442
- if ( wppa( 'photos_only' ) ) {
443
- wppa_out( wppa_errorbox( __( 'No photos found matching your search criteria.', 'wp-photo-album-plus' ) ) );
444
- wppa_report_nothing(1);
445
- }
446
- elseif ( wppa( 'albums_only' ) ) {
447
- wppa_out( wppa_errorbox( __( 'No albums found matching your search criteria.', 'wp-photo-album-plus' ) ) );
448
- wppa_report_nothing(2);
449
- }
450
- else {
451
- wppa_out( wppa_errorbox( __( 'No albums or photos found matching your search criteria.', 'wp-photo-album-plus' ) ) );
452
- wppa_report_nothing(3);
453
- }
454
- $wppa_empty_content = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
455
  }
456
- } // wppa_page( 'albums' )
457
-
458
- elseif ( wppa_page( 'slide' ) || wppa_page( 'single' ) ) { // Page 'Slideshow' or 'Single' in browsemode requested
459
- $thumbs = wppa_get_thumbs();
460
- wppa_dbg_msg( 'From theme: #thumbs='.( $thumbs ? count( $thumbs ) : '0' ) );
461
- if ( $thumbs ) {
462
- wppa_the_slideshow(); // Producs all the html required for the slideshow
463
- wppa_run_slidecontainer( 'slideshow' ); // Fill in the photo array and display it.
464
  }
465
  else {
466
- wppa_out( wppa_errorbox( __( 'No photos found matching your search criteria.', 'wp-photo-album-plus') ) );
467
- wppa_report_nothing(4);
468
  }
469
- } // wppa_page( 'slide' )
470
-
471
- // Close container
472
- wppa_container( 'close' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
473
 
474
- } // Not delaed
475
  }
476
 
477
  function wppa_is_wanted_empty( $thumbs ) {
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the albums/photos/slideshow in a page or post
6
+ * Version 8.1.07.002
7
  */
8
  function wppa_theme() {
9
 
10
+ global $wppa_version; $wppa_version = '8.1.07.002'; // The version number of this file
11
  global $wppa;
12
  global $wppa_show_statistics; // Can be set to true by a custom page template
13
  global $wppa_empty_content;
18
  $n_thumb_pages = '0'; // "
19
  $mocc = wppa( 'mocc' );
20
 
21
+ // Open container
22
+ wppa_container( 'open' );
23
 
24
+ // Show statistics if set so by the page template
25
+ if ( $wppa_show_statistics ) wppa_statistics();
26
 
27
+ // Display breadcrumb navigation only if it is set in the settings page
28
+ wppa_breadcrumb( 'optional' );
 
 
29
 
 
 
 
30
 
31
+ if ( wppa_page( 'albums' ) ) { // Page 'Albums' requested
 
 
32
 
33
+ // Init for possible alt thumbsize on masonry
34
+ $counter_thumbs = '0';
35
+ $is_alt_thumbsize = false;
36
+ $alb_id = wppa( 'start_album' );
37
+ if ( wppa_is_int( $alb_id ) && $alb_id > '0' ) {
38
+ $is_alt_thumbsize = wppa_get_album_item( $alb_id, 'alt_thumbsize' ) == 'yes';
39
+ }
40
 
41
+ // Get the albums and the thumbs and the number of pages for each set
42
+ $albums = wppa_get_albums(); // Get the albums
43
+ $n_album_pages = wppa_get_npages( 'albums', $albums ); // Get the number of album pages
44
 
45
+ if ( wppa_opt( 'thumbtype' ) != 'none' ) {
46
+ $thumbs = wppa_get_thumbs(); // Get the Thumbs
47
+ } else $thumbs = false;
48
 
49
+ $wanted_empty = wppa_is_wanted_empty( $thumbs ); // See if we need to display an empty thumbnail area
 
50
 
51
+ $n_thumb_pages = wppa_get_npages( 'thumbs', $thumbs ); // Get the number of thumb pages
52
+ if ( $n_thumb_pages == '0' && ! $wanted_empty ) $thumbs = false; // No pages: no thumbs. Maybe want covers only
53
+ if ( $wanted_empty ) $n_thumb_pages = '1';
54
 
55
+ // Get total number of pages
56
+ if ( ! wppa_is_pagination() ) $totpag = '1'; // If both pagination is off, there is only one page
57
+ else $totpag = $n_album_pages + $n_thumb_pages;
58
 
59
+ // Make pagelinkbar if requested on top
60
+ if ( wppa_opt( 'pagelink_pos' ) == 'top' || wppa_opt( 'pagelink_pos' ) == 'both' ) {
61
+ wppa_page_links( $totpag, $curpage );
62
+ }
63
 
64
+ // Process the albums
65
+ if ( ! wppa_switch( 'thumbs_first' ) ) {
66
+ if ( $albums ) {
67
+ $counter_albums = '0';
68
+ wppa_album_list( 'open' ); // Open Albums sub-container
69
+ foreach ( $albums as $album ) { // Loop the albums
70
+ $counter_albums++;
71
+ if ( wppa_onpage( 'albums', $counter_albums, $curpage ) ) {
72
+ wppa_album_cover( $album['id'] ); // Show the cover
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  $didsome = true;
 
74
  } // End if on page
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  }
76
+ wppa_album_list( 'close' ); // Close Albums sub-container
77
+ } // If albums
78
+ }
79
+
80
+ if ( $didsome && wppa_is_pagination() ) $thumbs = false; // Pag on and didsome: force a pagebreak by faking no thumbs
81
+ if ( is_array( $thumbs ) && ! count( $thumbs ) && ! $wanted_empty ) $thumbs = false; // Less than treshold value
82
+ if ( wppa_switch( 'thumbs_first' ) && $curpage > $n_thumb_pages ) $thumbs = false; // If thumbs done, do not display an empty thumbarea
83
+
84
+ // Process the thumbs
85
+ if ( $thumbs || $wanted_empty )
86
+ if ( ! $wanted_empty || ! wppa_switch( 'thumbs_first' ) || wppa_get_curpage() == '1' )
87
+ if ( ! $wanted_empty || wppa_switch( 'thumbs_first' ) || wppa_get_curpage() == $totpag ) {
88
+
89
+ // As covers
90
+ if ( wppa_opt( 'thumbtype' ) == 'ascovers' ||
91
+ wppa_opt( 'thumbtype' ) == 'ascovers-mcr' ) { // Do the thumbs As covers
92
+ wppa_thumb_list( 'open' ); // Open Thumblist sub-container
93
+ $relpage = wppa_switch( 'thumbs_first' ) ? $curpage : $curpage - $n_album_pages;
94
+ foreach ( $thumbs as $tt ) : global $thumb; $thumb = $tt; // Loop the Thumbs
95
+ $counter_thumbs++;
96
+ if ( wppa_onpage( 'thumbs', $counter_thumbs, $relpage ) ) {
97
+ $didsome = true;
98
+ wppa_thumb_ascover( $thumb['id'] ); // Show Thumb as cover
99
+ } // End if on page
100
+ endforeach;
101
+ wppa_thumb_list( 'close' ); // Close Thumblist sub-container
102
+ } // As covers
103
+
104
+ // Masonry vertical
105
+ elseif ( wppa_opt( 'thumbtype' ) == 'masonry-v' ) { // Masonry
106
+
107
+ // The header
108
+ wppa_thumb_area( 'open' ); // Open Thumbarea sub-container
109
+ wppa_popup(); // Prepare Popup box
110
+ wppa_album_name( 'top' ); // Optionally display album name
111
+ wppa_album_desc( 'top' ); // Optionally display album description
112
+
113
+ // Init
114
+ $relpage = wppa_switch( 'thumbs_first' ) ? $curpage : $curpage - $n_album_pages;
115
+ $cont_width = wppa_get_container_width();
116
+ $margin = wppa_opt( 'tn_margin' );
117
+ if ( wppa_is_mobile() ) $margin = ceil( $margin / 2 );
118
+ $count_cols = ceil( $cont_width / ( wppa_opt( $is_alt_thumbsize ? 'thumbsize_alt' : 'thumbsize' ) + $margin ) );
119
+ if ( wppa_is_mobile() ) {
120
+ $count_cols = ceil( $count_cols / 2 );
121
+ }
122
+ $correction = $margin * ( $cont_width / $count_cols ) / 100;
123
+
124
+ // Init the table
125
+ wppa_out( '<table class="wppa-masonry" style="margin-top:3px;" ><tbody class="wppa-masonry" ><tr class="wppa-masonry" >' );
126
+
127
+ // Init the columns
128
+ $col_headers = array();
129
+ $col_contents = array();
130
+ $col_heights = array();
131
+ $col_widths = array();
132
+
133
+ for ( $col = 0; $col < $count_cols; $col++ ) {
134
+ $col_headers[$col] = '';
135
+ $col_contents[$col] = '';
136
+ $col_heights[$col] = 0;
137
+ $col_widths[$col] = 100;
138
+ }
139
 
140
+ // Process the thumbnails
141
+ $col = '0';
142
+ if ( $thumbs ) foreach ( $thumbs as $tt ) {
143
+ $id = $tt['id'];
144
+ $counter_thumbs++;
145
+ if ( wppa_onpage( 'thumbs', $counter_thumbs, $relpage ) ) {
146
+ $col_contents[$col] .= wppa_get_thumb_masonry( $id );
147
+ $col_heights[$col] += ( $correction + wppa_get_thumby( $id ) ) / ( $correction + wppa_get_thumbx( $id ) ) * $col_widths[$col];
148
+ $col += '1';
149
+ if ( $col == $count_cols ) {
150
+ $col = '0';
 
 
151
  }
152
+ $didsome = true;
153
  }
154
+ }
155
 
156
+ // Find longest column
157
+ $long = 0;
158
+ for ( $col = 0; $col < $count_cols; $col++ ) {
159
+ if ( $col_heights[$col] > $long ) $long = $col_heights[$col];
160
+ }
161
 
162
+ // Adjust column widths to resize lengths to equal lengths
163
+ for ( $col = 0; $col < $count_cols; $col++ ) {
164
+ if ( $col_heights[$col] ) {
165
+ $col_widths[$col] = $long / $col_heights[$col] * $col_widths[$col];
 
166
  }
167
+ }
168
 
169
+ // Adjust column widths to total 100
170
+ $wide = 0;
171
+ for ( $col = 0; $col < $count_cols; $col++ ) {
172
+ $wide += $col_widths[$col];
173
+ }
174
+ for ( $col = 0; $col < $count_cols; $col++ ) {
175
+ $col_widths[$col] = $col_widths[$col] * 100 / $wide;
176
+ }
177
 
178
+ // Make column headers
179
+ for ( $col = 0; $col < $count_cols; $col++ ) {
180
+ $col_headers[$col] = '<td style="width: '.$col_widths[$col].'%; vertical-align:top;" class="wppa-masonry" >';
181
+ }
182
 
183
+ // Add the columns to the output stream
184
+ for ( $col = 0; $col < $count_cols; $col++ ) {
185
+ wppa_out( $col_headers[$col] );
186
+ wppa_out( $col_contents[$col] );
187
+ wppa_out( '</td>' );
188
+ }
189
 
190
+ // Close the table
191
+ wppa_out( '</tr></tbody></table>' );
192
+
193
+ // The footer
194
+ wppa_album_name( 'bottom' ); // Optionally display album name
195
+ wppa_album_desc( 'bottom' ); // Optionally display album description
196
+ wppa_thumb_area( 'close' ); // Close Thumbarea sub-container
197
+ } // Masonry-v
198
+
199
+ // Masonry horizontal
200
+ elseif ( wppa_opt( 'thumbtype' ) == 'masonry-h' ) { // Masonry
201
+
202
+ // The header
203
+ wppa_thumb_area( 'open' ); // Open Thumbarea sub-container
204
+ wppa_popup(); // Prepare Popup box
205
+ wppa_album_name( 'top' ); // Optionally display album name
206
+ wppa_album_desc( 'top' ); // Optionally display album description
207
+
208
+ // Init
209
+ $relpage = wppa_switch( 'thumbs_first' ) ? $curpage : $curpage - $n_album_pages;
210
+ $cont_width = wppa_get_container_width( 'netto' );
211
+ $correction = wppa_opt( 'tn_margin' );
212
+
213
+ // Init the table
214
+ wppa_out( '<table class="wppa-masonry wppa-masonry-h" style="margin-top:3px;" ><tbody class="wppa-masonry" >' );
215
+
216
+ // Process the thumbnails
217
+ $row_content = '';
218
+ $row_width = 0;
219
+ $target_row_height = wppa_opt( $is_alt_thumbsize ? 'thumbsize_alt' : 'thumbsize' ) * 0.75 + $correction;
220
+ $rw_count = 0;
221
+ $tr_count = '1';
222
+ $done_count = 0;
223
+ $last = false;
224
+ $max_row_height = $target_row_height * 0.8; // Init keep track for last
225
+ if ( $thumbs ) foreach ( $thumbs as $tt ) {
226
+ $id = $tt['id'];
227
+ $counter_thumbs++;
228
+ if ( wppa_onpage( 'thumbs', $counter_thumbs, $relpage ) ) {
229
+ $row_content .= wppa_get_thumb_masonry( $tt['id'] );
230
+ $rw_count += 1;
231
+ $row_width += wppa_get_thumbratioxy( $id ) * ( $target_row_height - $correction );
232
+ $didsome = true;
233
+ }
234
+ $done_count += 1;
235
+ $last = $done_count == count( $thumbs );
236
+ if ( $row_width > $cont_width || $last ) {
237
+ $tot_marg = $rw_count * $correction;
238
+ $row_height = $row_width ? ( ( $target_row_height - $correction ) * ( $cont_width - $tot_marg ) / ( $row_width ) + $correction ) : '0';
239
+ if ( ! $last ) {
240
+ $max_row_height = max( $max_row_height, $row_height );
241
  }
242
+ if ( $last && $row_height > wppa_get_thumby( $id ) ) {
243
+ $row_height = $max_row_height;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  }
245
+ $row_height_p = $row_height / $cont_width * 100;
246
+ wppa_out( '<tr class="wppa-masonry" >' .
247
+ '<td style="border:none;padding:0;margin:0" >' .
248
+ '<div' .
249
+ ' id="wppa-mas-h-'.$tr_count.'-'.wppa( 'mocc' ).'"' .
250
+ ' style="height:'.$row_height.'px;"' .
251
+ ' class="wppa-masonry"' .
252
+ ' data-height-perc="'.$row_height_p.'"' .
253
+ ' >');
254
+ wppa_out( $row_content );
255
+ wppa_out( '</div></td></tr>' );
256
+ $row_content = '';
257
+ $row_width = 0;
258
+ $row_height = wppa_opt( 'thumbsize' );
259
+ $rw_count = 0;
260
+ $tr_count += '1';
261
  }
262
+ }
263
+ wppa_out( '<tr class="wppa-masonry" ><td class="wppa-dummy" style="padding:0;border:none;" ></td></tr>' );
264
+ wppa_out( '</tbody></table>' );
265
+
266
+ // The footer
267
+ wppa_album_name( 'bottom' ); // Optionally display album name
268
+ wppa_album_desc( 'bottom' ); // Optionally display album description
269
+ wppa_out( '<script type="text/javascript" >' . // Fix bug in IE and Chrome
270
+ 'jQuery(document).ready(function(){wppaSetMasHorFrameWidthsForIeAndChrome(' . wppa( 'mocc' ) . ');});' .
271
+ '</script>' );
272
+ wppa_thumb_area( 'close' ); // Close Thumbarea sub-container
273
+
274
+ } // Masonry-h
275
+
276
+ // Masonry plus
277
+ elseif ( wppa_opt( 'thumbtype' ) == 'masonry-plus' ) {
278
+
279
+ // The header
280
+ wppa_thumb_area( 'open' ); // Open Thumbarea sub-container
281
+ wppa_popup(); // Prepare Popup box
282
+ wppa_album_name( 'top' ); // Optionally display album name
283
+ wppa_album_desc( 'top' ); // Optionally display album description
284
+
285
+ // Init
286
+ $relpage = wppa_switch( 'thumbs_first' ) ? $curpage : $curpage - $n_album_pages;
287
+
288
+ // Process the thumbnails
289
+ if ( $thumbs ) {
290
+
291
+ // Open masonry contatiner
292
+ $html = '
293
+ <div
294
+ id="grid-' . $mocc . '"
295
+ class="grid-' . $mocc . ' grid-masonryplus"
296
+ style="padding-top:6px;padding-bottom:6px;padding-right:6px;margin:0 auto;"
297
+ >';
298
+
299
+ // Add css
300
+ $html .= '
301
+ <style type="text/css" >
302
+ .grid-item-' . $mocc . ' {
303
+ line-height: 0;
304
+ visibility: hidden;
305
+ text-align: center;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
  }
307
+ .grid-item-' . $mocc . ' img {
308
+ width: 100%;
309
+ }
310
+ </style>';
311
 
312
+ // The thumbs
313
+ foreach ( $thumbs as $tt ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
314
  $counter_thumbs++;
315
+
316
  if ( wppa_onpage( 'thumbs', $counter_thumbs, $relpage ) ) {
317
+
318
  $didsome = true;
319
+ $html .= '
320
+ <div
321
+ style=""
322
+ id="grid-item-' . $mocc . '-' . wppa_encrypt_photo( $tt['id'] ) . '"
323
+ class="grid-item grid-item-' . $mocc . '" >' .
324
+ wppa_get_thumb_masonry( $tt['id'] ) . '
325
+ </div>';
326
+ }
327
  }
328
 
329
+ // Close masonry container
330
+ $html .= '</div><div style="clear:both" ></div>';
331
+ }
332
+ wppa_out( wppa_compress_html( $html ) );
333
+
334
+ // The footer
335
+ wppa_album_name( 'bottom' ); // Optionally display album name
336
+ wppa_album_desc( 'bottom' ); // Optionally display album description
337
+ wppa_thumb_area( 'close' ); // Close Thumbarea sub-container
338
+ } // Masonry plus
339
+
340
+ // Default
341
+ elseif ( wppa_opt( 'thumbtype' ) == 'default' ) { // Do the thumbs As default
342
+
343
+ // The header
344
+ wppa_thumb_area( 'open' ); // Open Thumbarea sub-container
345
+ wppa_popup(); // Prepare Popup box
346
+ wppa_album_name( 'top' ); // Optionally display album name
347
+ wppa_album_desc( 'top' ); // Optionally display album description
348
+
349
+ // Init
350
+ $relpage = wppa_switch( 'thumbs_first' ) ? $curpage : $curpage - $n_album_pages;
351
+
352
+ // Process the thumbnails
353
+ if ( $thumbs ) foreach ( $thumbs as $tt ) {
354
+ $counter_thumbs++;
355
+ if ( wppa_onpage( 'thumbs', $counter_thumbs, $relpage ) ) {
356
+ $didsome = true;
357
+ wppa_thumb_default( $tt['id'] ); // Show Thumb as default
358
+ } // End if on page
359
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
 
361
+ // The footer
362
+ wppa_album_name( 'bottom' ); // Optionally display album name
363
+ wppa_album_desc( 'bottom' ); // Optionally display album description
364
+ wppa_thumb_area( 'close' ); // Close Thumbarea sub-container
365
+ } // As default
366
 
367
+ // Unimplemented thumbnail type
368
+ else {
369
+ wppa_out( 'Unimplemented thumbnail type: ' . wppa_opt( 'thumbtype' ) );
370
+ }
371
+ } // If thumbs
372
+
373
+ if ( $didsome && wppa_is_pagination() ) $albums = false; // Pag on and didsome: force a pagebreak by faking no albums
374
+ if ( ! wppa_is_pagination() ) $n_thumb_pages = '0'; // Still on page one
375
+
376
+ // Process the albums
377
+ if ( wppa_switch( 'thumbs_first' ) ) {
378
+ if ( $albums ) {
379
+ $counter_albums = '0';
380
+ wppa_album_list( 'open' ); // Open Albums sub-container
381
+ foreach ( $albums as $album ) { // Loop the albums
382
+ $counter_albums++;
383
+ if ( wppa_onpage( 'albums', $counter_albums, $curpage - $n_thumb_pages ) ) {
384
+ wppa_album_cover( $album['id'] ); // Show the cover
385
+ $didsome = true;
386
+ } // End if on page
387
+ }
388
+ wppa_album_list( 'close' ); // Close Albums sub-container
389
+ } // If albums
390
+ }
391
+
392
+ // Make pagelinkbar if requested on bottom
393
+ if ( wppa_opt( 'pagelink_pos' ) == 'bottom' || wppa_opt( 'pagelink_pos' ) == 'both' ) {
394
+ wppa_page_links( $totpag, $curpage );
395
+ }
396
+
397
+ // Empty results?
398
+ if ( ! $didsome && ! $wanted_empty ) {
399
+ if ( wppa( 'photos_only' ) ) {
400
+ wppa_out( wppa_errorbox( __( 'No photos found matching your search criteria.', 'wp-photo-album-plus' ) ) );
401
+ wppa_report_nothing(1);
402
  }
403
+ elseif ( wppa( 'albums_only' ) ) {
404
+ wppa_out( wppa_errorbox( __( 'No albums found matching your search criteria.', 'wp-photo-album-plus' ) ) );
405
+ wppa_report_nothing(2);
 
 
 
 
 
406
  }
407
  else {
408
+ wppa_out( wppa_errorbox( __( 'No albums or photos found matching your search criteria.', 'wp-photo-album-plus' ) ) );
409
+ wppa_report_nothing(3);
410
  }
411
+ $wppa_empty_content = true;
412
+ }
413
+ } // wppa_page( 'albums' )
414
+
415
+ elseif ( wppa_page( 'slide' ) || wppa_page( 'single' ) ) { // Page 'Slideshow' or 'Single' in browsemode requested
416
+ $thumbs = wppa_get_thumbs();
417
+ wppa_dbg_msg( 'From theme: #thumbs='.( $thumbs ? count( $thumbs ) : '0' ) );
418
+ if ( $thumbs ) {
419
+ wppa_the_slideshow(); // Producs all the html required for the slideshow
420
+ wppa_run_slidecontainer( 'slideshow' ); // Fill in the photo array and display it.
421
+ }
422
+ else {
423
+ wppa_out( wppa_errorbox( __( 'No photos found matching your search criteria.', 'wp-photo-album-plus') ) );
424
+ wppa_report_nothing(4);
425
+ }
426
+ } // wppa_page( 'slide' )
427
+
428
+ // Close container
429
+ wppa_container( 'close' );
430
 
 
431
  }
432
 
433
  function wppa_is_wanted_empty( $thumbs ) {
wppa-admin.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains the admin menu and startups the admin pages
6
- * Version 8.1.06.006
7
  *
8
  */
9
 
@@ -340,22 +340,29 @@ add_filter( 'block_categories_all', 'wppa_block_categories', 10, 2 );
340
  // Fix Gutenberg bug and clear cache selectively
341
  function wppa_fix_gutenberg_shortcodes( $id, $post, $update ) {
342
 
 
343
  $post_content = $post->post_content;
344
 
345
- // Fix
346
  $new_content = str_replace( array( 'wp:wppa/gutenberg-photo', 'wp:wppa/gutenberg-wppa' ), 'wp:shortcode', $post_content );
347
 
348
- $temp = explode( '[wppa ', $new_content );
349
- if ( is_array( $temp ) ) {
350
- foreach( array_keys( $temp ) as $key ) {
351
- $t = explode( ']', $temp[$key] );
352
- $t[0] = str_replace( '@', '#', $t[0] );
353
- $temp[$key] = implode( ']', $t );
 
 
 
 
 
 
 
354
  }
355
- $new_content = implode( '[wppa ', $temp );
356
  }
357
 
358
- // Update if fixed
359
  if ( $post_content != $new_content ) {
360
 
361
  $post->post_content = $new_content;
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains the admin menu and startups the admin pages
6
+ * Version 8.1.07.002
7
  *
8
  */
9
 
340
  // Fix Gutenberg bug and clear cache selectively
341
  function wppa_fix_gutenberg_shortcodes( $id, $post, $update ) {
342
 
343
+ // Get content
344
  $post_content = $post->post_content;
345
 
346
+ // Fix block type
347
  $new_content = str_replace( array( 'wp:wppa/gutenberg-photo', 'wp:wppa/gutenberg-wppa' ), 'wp:shortcode', $post_content );
348
 
349
+ // Fix virtual identifiers
350
+ if ( strpos( $post_content, '[wppa' ) !== false ) {
351
+
352
+ $from = ['@topten', '@lasten', '@featen', '@comten', '@tags', '@cat', '@owner', '@upldr', '@all', '@last', '@owner', '@cat', '@all', '@potd', '@last'];
353
+ $to = ['#topten', '#lasten', '#featen', '#comten', '#tags', '#cat', '#owner', '#upldr', '#all', '#last', '#owner', '#cat', '#all', '#potd', '#last'];
354
+ $temp = explode( '[wppa ', $new_content );
355
+ if ( is_array( $temp ) ) {
356
+ foreach( array_keys( $temp ) as $key ) {
357
+ $t = explode( ']', $temp[$key] );
358
+ $t[0] = str_replace( $from, $to, $t[0] );
359
+ $temp[$key] = implode( ']', $t );
360
+ }
361
+ $new_content = implode( '[wppa ', $temp );
362
  }
 
363
  }
364
 
365
+ // Update if something changed
366
  if ( $post_content != $new_content ) {
367
 
368
  $post->post_content = $new_content;
wppa-functions.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various functions
6
- * Version 8.1.05.002
7
  *
8
  */
9
 
@@ -949,7 +949,7 @@ global $other_deps;
949
  }
950
  else wppa_out( '<span style="color:red">ERROR: Missing function wppa_theme(), check the installation of WPPA+. Remove customized wppa_theme.php</span>' );
951
  global $wppa_version;
952
- $expected_version = '8.0.08.008';
953
  if ( $wppa_version != $expected_version ) {
954
  wppa_dbg_msg( 'WARNING: customized wppa-theme.php is out of rev. Expected version: ' . $expected_version . ' found: ' . $wppa_version, 'red' );
955
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various functions
6
+ * Version 8.1.07.002
7
  *
8
  */
9
 
949
  }
950
  else wppa_out( '<span style="color:red">ERROR: Missing function wppa_theme(), check the installation of WPPA+. Remove customized wppa_theme.php</span>' );
951
  global $wppa_version;
952
+ $expected_version = '8.1.07.002';
953
  if ( $wppa_version != $expected_version ) {
954
  wppa_dbg_msg( 'WARNING: customized wppa-theme.php is out of rev. Expected version: ' . $expected_version . ' found: ' . $wppa_version, 'red' );
955
  }
wppa-gutenberg-wppa.php CHANGED
@@ -2,7 +2,7 @@
2
  /* wppa-gutenberg-wppa.php
3
  * Pachkage: wp-photo-album-plus
4
  *
5
- * Version 8.1.07.001
6
  */
7
 
8
  function wppa_gutenberg_wppa_block() {
@@ -416,7 +416,7 @@ global $wpdb;
416
 
417
  // Please select
418
  $result .= '<option value="" disabled="disabled" selected="selected" style="color:#700 !important;" >-- '.__('Please select a photo', 'wp-photo-album-plus').' --</option>';
419
- $result .= '<option value="#potd" >-- '.__('The photo of the day', 'wp-photo-album-plus').' --</option>';
420
 
421
  // Most recent 100 photos
422
  foreach ( $photos as $photo ) {
@@ -445,8 +445,8 @@ global $wpdb;
445
  ' (' . wppa_get_album_name( $photo['album'] ) . ')' .
446
  '</option>';
447
  }
448
- $result .= '<option value="#last" >-- '.__('The most recently uploaded photo', 'wp-photo-album-plus').' --</option>'.
449
- '<option value="#potd" >-- '.__('The photo of the day', 'wp-photo-album-plus').' --</option>';
450
  }
451
  else {
452
  $result .= '<option value="0" >'.__('There are no photos yet', 'wp-photo-album-plus').'</option>';
2
  /* wppa-gutenberg-wppa.php
3
  * Pachkage: wp-photo-album-plus
4
  *
5
+ * Version 8.1.07.002
6
  */
7
 
8
  function wppa_gutenberg_wppa_block() {
416
 
417
  // Please select
418
  $result .= '<option value="" disabled="disabled" selected="selected" style="color:#700 !important;" >-- '.__('Please select a photo', 'wp-photo-album-plus').' --</option>';
419
+ $result .= '<option value="@potd" >-- '.__('The photo of the day', 'wp-photo-album-plus').' --</option>';
420
 
421
  // Most recent 100 photos
422
  foreach ( $photos as $photo ) {
445
  ' (' . wppa_get_album_name( $photo['album'] ) . ')' .
446
  '</option>';
447
  }
448
+ $result .= '<option value="@last" >-- '.__('The most recently uploaded photo', 'wp-photo-album-plus').' --</option>'.
449
+ '<option value="@potd" >-- '.__('The photo of the day', 'wp-photo-album-plus').' --</option>';
450
  }
451
  else {
452
  $result .= '<option value="0" >'.__('There are no photos yet', 'wp-photo-album-plus').'</option>';
wppa-setup.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the setup stuff
6
- * Version 8.1.02.001
7
  *
8
  */
9
 
@@ -38,8 +38,6 @@ global $wppa_error;
38
 
39
  if ( $old_rev == $wppa_revno && ! $force ) return; // Nothing to do here
40
 
41
- wppa_clear_cache( array( 'force' => true ) );
42
-
43
  $wppa_error = false; // Init no error
44
 
45
  $create_albums = "CREATE TABLE $wpdb->wppa_albums (
@@ -213,9 +211,34 @@ global $wppa_error;
213
  // Create or update db tables
214
  $tn = array( WPPA_ALBUMS, WPPA_PHOTOS, WPPA_RATING, WPPA_COMMENTS, WPPA_IPTC, WPPA_EXIF, WPPA_INDEX, WPPA_SESSION, WPPA_CACHES );
215
  $tc = array( $create_albums, $create_photos, $create_rating, $create_comments, $create_iptc, $create_exif, $create_index, $create_session, $create_caches );
 
 
 
 
 
 
 
 
 
 
 
 
216
  $idx = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
217
 
218
- // Change longtext into text in existring db
219
  if ( $old_rev > '100' ) {
220
  $wpdb->query( "ALTER TABLE $wpdb->wppa_albums CHANGE `custom` `custom` TEXT CHARACTER SET utf8 NOT NULL;" );
221
  $wpdb->query( "ALTER TABLE $wpdb->wppa_photos CHANGE `custom` `custom` TEXT CHARACTER SET utf8 NOT NULL;" );
@@ -223,13 +246,16 @@ global $wppa_error;
223
  $wpdb->query( "ALTER TABLE $wpdb->wppa_photos CHANGE `description` `description` TEXT CHARACTER SET utf8 NOT NULL;" );
224
  }
225
 
 
 
226
  while ( $idx < 9 ) {
227
- dbDelta( $tc[$idx] );
228
  $idx++;
229
  }
230
  wppa_log( 'OBS', 'DB UPDATED' );
231
 
232
- // Clear cahce statistics
 
233
  delete_option( 'wppa_cache_hits' );
234
  delete_option( 'wppa_cache_misses' );
235
 
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the setup stuff
6
+ * Version 8.1.07.002
7
  *
8
  */
9
 
38
 
39
  if ( $old_rev == $wppa_revno && ! $force ) return; // Nothing to do here
40
 
 
 
41
  $wppa_error = false; // Init no error
42
 
43
  $create_albums = "CREATE TABLE $wpdb->wppa_albums (
211
  // Create or update db tables
212
  $tn = array( WPPA_ALBUMS, WPPA_PHOTOS, WPPA_RATING, WPPA_COMMENTS, WPPA_IPTC, WPPA_EXIF, WPPA_INDEX, WPPA_SESSION, WPPA_CACHES );
213
  $tc = array( $create_albums, $create_photos, $create_rating, $create_comments, $create_iptc, $create_exif, $create_index, $create_session, $create_caches );
214
+
215
+ // Find existing tables
216
+ $r = $wpdb->get_results( "SHOW TABLES", ARRAY_A );
217
+ $s = array();
218
+ foreach( $r as $i ) {
219
+ foreach( $i as $j ) {
220
+ $existing_tables[] = $j;
221
+ }
222
+ }
223
+
224
+ // Add missing tables
225
+ // W@e do this here because dbDelta() generates an error when a new table is created
226
  $idx = 0;
227
+ while ( $idx < 9 ) {
228
+ if ( ! in_array( $tn[$idx], $existing_tables ) ) {
229
+ wppa_log( 'obs', 'Attempting to create ' . $tn[$idx] );
230
+ $bret = $wpdb->query( $tc[$idx] );
231
+ if ( $bret ) {
232
+ wppa_log( 'obs', $tn[$idx] . ' successfully created' );
233
+ }
234
+ else {
235
+ wppa_log( 'err', 'Failed to create ' . $tn[$idx] );
236
+ }
237
+ }
238
+ $idx++;
239
+ }
240
 
241
+ // Change longtext into text in existring tables
242
  if ( $old_rev > '100' ) {
243
  $wpdb->query( "ALTER TABLE $wpdb->wppa_albums CHANGE `custom` `custom` TEXT CHARACTER SET utf8 NOT NULL;" );
244
  $wpdb->query( "ALTER TABLE $wpdb->wppa_photos CHANGE `custom` `custom` TEXT CHARACTER SET utf8 NOT NULL;" );
246
  $wpdb->query( "ALTER TABLE $wpdb->wppa_photos CHANGE `description` `description` TEXT CHARACTER SET utf8 NOT NULL;" );
247
  }
248
 
249
+ // Update tables with possibly new fields
250
+ $idx = 0;
251
  while ( $idx < 9 ) {
252
+ @ dbDelta( $tc[$idx] );
253
  $idx++;
254
  }
255
  wppa_log( 'OBS', 'DB UPDATED' );
256
 
257
+ // Clear cahce and statistics
258
+ wppa_clear_cache( array( 'force' => true ) );
259
  delete_option( 'wppa_cache_hits' );
260
  delete_option( 'wppa_cache_misses' );
261
 
wppa.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  * Plugin Name: WP Photo Album Plus
4
  * Description: Easily manage and display your photo albums and slideshows within your WordPress site.
5
- * Version: 8.1.07.001
6
  * Author: J.N. Breetvelt a.k.a. OpaJaap
7
  * Author URI: http://wppa.opajaap.nl/
8
  * Plugin URI: http://wordpress.org/extend/plugins/wp-photo-album-plus/
@@ -24,7 +24,7 @@ global $wp_version;
24
 
25
  /* WPPA GLOBALS */
26
  global $wppa_api_version;
27
- $wppa_api_version = '8.1.07.001'; // WPPA software version
28
  global $wppa_revno;
29
  $wppa_revno = str_replace( '.', '', $wppa_api_version ); // WPPA db version
30
 
2
  /*
3
  * Plugin Name: WP Photo Album Plus
4
  * Description: Easily manage and display your photo albums and slideshows within your WordPress site.
5
+ * Version: 8.1.07.002
6
  * Author: J.N. Breetvelt a.k.a. OpaJaap
7
  * Author URI: http://wppa.opajaap.nl/
8
  * Plugin URI: http://wordpress.org/extend/plugins/wp-photo-album-plus/
24
 
25
  /* WPPA GLOBALS */
26
  global $wppa_api_version;
27
+ $wppa_api_version = '8.1.07.002'; // WPPA software version
28
  global $wppa_revno;
29
  $wppa_revno = str_replace( '.', '', $wppa_api_version ); // WPPA db version
30