WP Photo Album Plus - Version 8.2.04.004

Version Description

= 8.1.08 =

  • 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.2.04.004
Comparing to
See all releases

Code changes from version 8.2.04.003 to 8.2.04.004

changelog.txt CHANGED
@@ -4,7 +4,8 @@ WP Photo Album Plus Changelog
4
 
5
  * The width and height of portrait oriented mp4 videos is now properly recorded.
6
  * The dirs wp-content/cache and wp-content/widget-cache are now skipped when scanning for importable files.
7
- * To improve previews, you van now add your theme and custom css at the backend. See new settings Advanced settings -> Admin -> VI -> Items 15 and 16.
 
8
 
9
  = 8.2.03 =
10
 
4
 
5
  * The width and height of portrait oriented mp4 videos is now properly recorded.
6
  * The dirs wp-content/cache and wp-content/widget-cache are now skipped when scanning for importable files.
7
+ * To improve previews, you can now add your theme and custom css at the backend. See new settings Advanced settings -> Admin -> VI -> Items 15, 16 and 17.
8
+ * The album cover viewlink now takes into account that there may be hidden or private albums.
9
 
10
  = 8.2.03 =
11
 
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.2.04.003
7
  *
8
  */
9
 
@@ -131,14 +131,17 @@ function theme_styles_for_wppa() {
131
  if ( wppa_switch( 'admin_theme_css' ) ) {
132
 
133
  // Load theme css
134
- wp_enqueue_style( 'parent-style-for-wppa', get_template_directory_uri() . '/style.css',
135
- array( 'wppa_style' )
136
- );
137
 
138
  // Load child theme css
139
- wp_enqueue_style( 'child-style-for-wppa', get_stylesheet_uri(),
140
- array( 'parent-style-for-wppa', 'wppa_style' )
141
- );
 
 
 
 
 
142
  }
143
 
144
  $the_css = wppa_opt( 'admin_inline_css' );
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains the admin menu and startups the admin pages
6
+ * Version 8.2.04.004
7
  *
8
  */
9
 
131
  if ( wppa_switch( 'admin_theme_css' ) ) {
132
 
133
  // Load theme css
134
+ wp_enqueue_style( 'parent-style-for-wppa', get_template_directory_uri() . '/style.css', array( 'wppa_style' ) );
 
 
135
 
136
  // Load child theme css
137
+ wp_enqueue_style( 'child-style-for-wppa', get_stylesheet_uri(), array( 'parent-style-for-wppa', 'wppa_style' ) );
138
+ }
139
+
140
+ $the_url = wppa_opt( 'admin_extra_css' );
141
+ if ( $the_url ) {
142
+
143
+ // Load extra stylesheet
144
+ wp_enqueue_style( 'extra-style-for-wppa', $the_url, array( 'wppa_style' ) );
145
  }
146
 
147
  $the_css = wppa_opt( 'admin_inline_css' );
wppa-ajax.php CHANGED
@@ -2,7 +2,7 @@
2
  /* wppa-ajax.php
3
  *
4
  * Functions used in ajax requests
5
- * Version 8.2.04.002
6
  *
7
  */
8
 
@@ -3830,6 +3830,12 @@ global $wppa;
3830
  case 'wppa_nicescroll_opts':
3831
  $value = wppa_sanitize_nso( $value );
3832
  break;
 
 
 
 
 
 
3833
 
3834
  default:
3835
 
2
  /* wppa-ajax.php
3
  *
4
  * Functions used in ajax requests
5
+ * Version 8.2.04.004
6
  *
7
  */
8
 
3830
  case 'wppa_nicescroll_opts':
3831
  $value = wppa_sanitize_nso( $value );
3832
  break;
3833
+ case 'wppa_admin_extra_css':
3834
+ if ( $value != sanitize_url( $value, is_ssl() ? ['https'] : ['http'] ) ) {
3835
+ $value = '';
3836
+ $alert = __('Not a valid url', 'wp-photo-album-plus');
3837
+ }
3838
+ break;
3839
 
3840
  default:
3841
 
wppa-album-admin-autosave.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * create, edit and delete albums
6
- * Version 8.2.04.002
7
  *
8
  */
9
 
@@ -24,7 +24,34 @@ global $wppa_revno;
24
  elseif ( $from == 'wppa_search' ) {
25
  $back_url = get_admin_url() . 'admin.php?page=wppa_search';
26
  $back_title = __( 'Back to search form', 'wp-photo-album-plus' );
 
 
 
 
 
 
 
 
27
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  // Delete trashed comments
30
  $wpdb->query( "DELETE FROM $wpdb->wppa_comments WHERE status = 'trash'" );
@@ -110,10 +137,10 @@ global $wppa_revno;
110
  // Edit by search token
111
  if ( wppa_get( 'edit-id' ) == 'search' ) {
112
 
113
- if ( wppa_get( 'searchstring' ) ) {
114
- $back_url .= '&wppa-searchstring=' . wppa_get( 'searchstring' );
115
- }
116
- $back_url .= '#wppa-edit-search-tag';
117
 
118
  $task = __( 'Edit photo information', 'wp-photo-album-plus' );
119
  if ( wppa_get( 'bulk' ) ) {
@@ -125,10 +152,14 @@ global $wppa_revno;
125
 
126
  wppa_echo ( '
127
  <a name="manage-photos" id="manage-photos" ></a>
128
- <h2>' . __( 'Manage Photos', 'wp-photo-album-plus' ) . ' - <small><i>' . $task . '</i></small></h2>
129
- <a href="' . $back_url . '" >' .
130
- $back_title .
131
- '</a><br><br>' );
 
 
 
 
132
 
133
  if ( wppa_get( 'bulk' ) ) {
134
  wppa_album_photos_bulk( $ei );
@@ -137,16 +168,10 @@ global $wppa_revno;
137
  wppa_album_photos( $ei );
138
  }
139
 
140
- wppa_echo( '
141
- <a href="#manage-photos">
142
- <div style="position:fixed;right:30px;bottom:30px;background-color:lightblue;float:right" >
143
- &nbsp;' . __( 'Top of page', 'wp-photo-album-plus' ) . '&nbsp;
144
- </div>
145
- </a>
146
- <br>
147
- <a href="' . $back_url . '" >' .
148
- $back_title .
149
- '</a>' );
150
 
151
  return;
152
  }
@@ -156,7 +181,7 @@ global $wppa_revno;
156
 
157
  $h2 = __( 'Manage Trashed Photos', 'wp-photo-album-plus' );
158
  $task = __( 'Edit photo information', 'wp-photo-album-plus' );
159
- wppa_echo( '<div class="wrap"><h2>' . $h2 . ' - <small><i>' . $task . '</i></small></h2>' );
160
  if ( wppa_get( 'bulk' ) ) {
161
  wppa_album_photos_bulk( $ei );
162
  }
@@ -215,7 +240,6 @@ global $wppa_revno;
215
  wppa_set_last_album( $id );
216
  wppa_invalidate_treecounts( $id );
217
  wppa_index_add( 'album', $id );
218
- $sib_id = wppa_get( 'is-sibling-of' );
219
 
220
  if ( $sib_id > 0 ) {
221
 
@@ -224,7 +248,7 @@ global $wppa_revno;
224
  wppa_update_album( array( 'id' => $id,
225
  'cover_type' => $sib_alb['cover_type'],
226
  'cover_linktype' => $sib_alb['cover_linktype'],
227
- 'main_photo' => ( $sib_alb['main_photo'] < '0' ? $sib_alb['main_photo'] : '0' ),
228
  ) );
229
  }
230
 
@@ -546,6 +570,8 @@ jQuery(document).ready(function(){wppaGetCoverPreview( '.$id.', "cover-preview-"
546
  // The header
547
  wppa_echo( '<h1 style="display:inline">' . __( wppa_get_album_name( $id ) ) . '</h1>' );
548
 
 
 
549
  /* Start header buttons */
550
  wppa_echo( '
551
  <div id="wppa-action-container">
@@ -1204,6 +1230,7 @@ jQuery(document).ready(function(){wppaGetCoverPreview( '.$id.', "cover-preview-"
1204
  onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'name\', this )"
1205
  value="' . esc_attr( $name ) . '"
1206
  />
 
1207
  <span class="description" >' .
1208
  __( 'Type the name of the album. Do not leave this empty.', 'wp-photo-album-plus' ) . '
1209
  </span>
@@ -2092,7 +2119,7 @@ jQuery(document).ready(function(){wppaGetCoverPreview( '.$id.', "cover-preview-"
2092
  wppa_echo( '
2093
  <div class="wppa-table-wrap" style="margin-top:20px;clear:both;position:relative;">' );
2094
 
2095
- wppa_echo( '<h2 style="padding-left:12px">' );
2096
 
2097
  if ( wppa_get( 'bulk' ) )
2098
  $result = __( 'Copy / move / delete / edit name / edit description / change status', 'wp-photo-album-plus' );
@@ -2126,14 +2153,9 @@ jQuery(document).ready(function(){wppaGetCoverPreview( '.$id.', "cover-preview-"
2126
 
2127
  /* Footer of the page */
2128
  wppa_echo( '
2129
- <br>
2130
- <a href="' . $back_url . '" >' .
2131
- $back_title .
2132
- '</a>
2133
-
2134
- <a href="#manage-photos">
2135
- <div style="position:fixed;right:30px;bottom:30px;background-color:lightblue;float:right" >&nbsp;' . __( 'Top of page', 'wp-photo-album-plus' ) . '&nbsp;</div>
2136
- </a>
2137
  </div>' );
2138
 
2139
 
@@ -3688,7 +3710,7 @@ global $wpdb;
3688
  onchange="
3689
  wppaAjaxUpdateAlbum( ' . $parent . ', \'suba_order_by\', this );
3690
  var ord=Math.abs(jQuery(this).val());
3691
- var dft=Math.abs(' . wppa_opt('wppa_list_albums_by') . ');
3692
  if (ord == 1 || (ord == 0 && dft == 1)) {
3693
  jQuery(\'#wppa-album-sequence\').show();
3694
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * create, edit and delete albums
6
+ * Version 8.2.04.004
7
  *
8
  */
9
 
24
  elseif ( $from == 'wppa_search' ) {
25
  $back_url = get_admin_url() . 'admin.php?page=wppa_search';
26
  $back_title = __( 'Back to search form', 'wp-photo-album-plus' );
27
+
28
+ if ( wppa_get( 'edit-id' ) == 'search' ) {
29
+
30
+ if ( wppa_get( 'searchstring' ) ) {
31
+ $back_url .= '&wppa-searchstring=' . wppa_get( 'searchstring' );
32
+ }
33
+ $back_url .= '#wppa-edit-search-tag';
34
+ }
35
  }
36
+ $back_link_html = '
37
+ <div style="float:right;background-color:lightblue;">
38
+ &nbsp;
39
+ <a href="' . $back_url . '"
40
+ style=""
41
+ >' .
42
+ $back_title . '
43
+ </a>
44
+ &nbsp;
45
+ </div>';
46
+
47
+ $top_link_html = '
48
+ <div style="position:fixed;right:20px;bottom:30px;background-color:lightblue;float:right" >
49
+ &nbsp;
50
+ <a href="#manage-photos">' .
51
+ __( 'Top of page', 'wp-photo-album-plus' ) . '
52
+ </a>
53
+ &nbsp;
54
+ </div>';
55
 
56
  // Delete trashed comments
57
  $wpdb->query( "DELETE FROM $wpdb->wppa_comments WHERE status = 'trash'" );
137
  // Edit by search token
138
  if ( wppa_get( 'edit-id' ) == 'search' ) {
139
 
140
+ // if ( wppa_get( 'searchstring' ) ) {
141
+ // $back_url .= '&wppa-searchstring=' . wppa_get( 'searchstring' );
142
+ // }
143
+ // $back_url .= '#wppa-edit-search-tag';
144
 
145
  $task = __( 'Edit photo information', 'wp-photo-album-plus' );
146
  if ( wppa_get( 'bulk' ) ) {
152
 
153
  wppa_echo ( '
154
  <a name="manage-photos" id="manage-photos" ></a>
155
+ <h2>' .
156
+ __( 'Manage Photos', 'wp-photo-album-plus' ) . ' - <small><i>' . $task . '</i></small>
157
+ </h2>' .
158
+ $back_link_html . '
159
+ <br><br>' );
160
+ // <a href="' . $back_url . '" >' .
161
+ // $back_title .
162
+ // '</a><br><br>' );
163
 
164
  if ( wppa_get( 'bulk' ) ) {
165
  wppa_album_photos_bulk( $ei );
168
  wppa_album_photos( $ei );
169
  }
170
 
171
+ wppa_echo( $top_link_html . '<br>' . $back_link_html );
172
+ // <a href="' . $back_url . '" >' .
173
+ // $back_title .
174
+ // '</a>' );
 
 
 
 
 
 
175
 
176
  return;
177
  }
181
 
182
  $h2 = __( 'Manage Trashed Photos', 'wp-photo-album-plus' );
183
  $task = __( 'Edit photo information', 'wp-photo-album-plus' );
184
+ wppa_echo( '<div class="wrap"><a name="manage-photos" id="manage-photos" ></a><h2>' . $h2 . ' - <small><i>' . $task . '</i></small></h2>' );
185
  if ( wppa_get( 'bulk' ) ) {
186
  wppa_album_photos_bulk( $ei );
187
  }
240
  wppa_set_last_album( $id );
241
  wppa_invalidate_treecounts( $id );
242
  wppa_index_add( 'album', $id );
 
243
 
244
  if ( $sib_id > 0 ) {
245
 
248
  wppa_update_album( array( 'id' => $id,
249
  'cover_type' => $sib_alb['cover_type'],
250
  'cover_linktype' => $sib_alb['cover_linktype'],
251
+ 'main_photo' => ( $sib_alb['main_photo'] < '0' ? $sib_alb['main_photo'] : '0' )
252
  ) );
253
  }
254
 
570
  // The header
571
  wppa_echo( '<h1 style="display:inline">' . __( wppa_get_album_name( $id ) ) . '</h1>' );
572
 
573
+ wppa_echo( $back_link_html );
574
+
575
  /* Start header buttons */
576
  wppa_echo( '
577
  <div id="wppa-action-container">
1230
  onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'name\', this )"
1231
  value="' . esc_attr( $name ) . '"
1232
  />
1233
+ <br>
1234
  <span class="description" >' .
1235
  __( 'Type the name of the album. Do not leave this empty.', 'wp-photo-album-plus' ) . '
1236
  </span>
2119
  wppa_echo( '
2120
  <div class="wppa-table-wrap" style="margin-top:20px;clear:both;position:relative;">' );
2121
 
2122
+ wppa_echo( '<a name="manage-photos" id="manage-photos" ></a><h2 style="padding-left:12px">' );
2123
 
2124
  if ( wppa_get( 'bulk' ) )
2125
  $result = __( 'Copy / move / delete / edit name / edit description / change status', 'wp-photo-album-plus' );
2153
 
2154
  /* Footer of the page */
2155
  wppa_echo( '
2156
+ <br>' .
2157
+ $back_link_html .
2158
+ $top_link_html . '
 
 
 
 
 
2159
  </div>' );
2160
 
2161
 
3710
  onchange="
3711
  wppaAjaxUpdateAlbum( ' . $parent . ', \'suba_order_by\', this );
3712
  var ord=Math.abs(jQuery(this).val());
3713
+ var dft=Math.abs(' . wppa_opt('list_albums_by') . ');
3714
  if (ord == 1 || (ord == 0 && dft == 1)) {
3715
  jQuery(\'#wppa-album-sequence\').show();
3716
  }
wppa-album-covers.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Functions for album covers
6
- * Version 8.2.04.002
7
  *
8
  */
9
 
@@ -92,7 +92,7 @@ global $wpdb;
92
  // Find album details
93
  $coverphoto = wppa_get_coverphoto_id( $albumid );
94
  $image = wppa_cache_thumb( $coverphoto );
95
- $photocount = wppa_get_photo_count( $albumid );
96
  $albumcount = wppa_get_album_count( $albumid, 'use_treecounts' );
97
 
98
  // Init links
@@ -100,10 +100,8 @@ global $wpdb;
100
  $linkpage = '';
101
  $href_title = '';
102
  $href_slideshow = '';
103
- $href_content = '';
104
  $onclick_title = '';
105
  $onclick_slideshow = '';
106
- $onclick_content = '';
107
 
108
  // See if there is substantial content to the album
109
  $has_content = $albumcount || $photocount;
@@ -146,14 +144,6 @@ global $wpdb;
146
  $href_slideshow = "#";
147
  }
148
 
149
- // Find the content 'View' link
150
- $href_content = wppa_get_album_url( array( 'album' => $albumid, 'page' => $linkpage ) );
151
- $ajax_content = wppa_get_album_url_ajax( array( 'album' => $albumid, 'page' => $linkpage ) );
152
- if ( ! $linkpage ) {
153
- $onclick_content = "wppaDoAjaxRender( " . wppa( 'mocc' ) . ", '" . $ajax_content . "', '" . $href_content . "' )";
154
- $href_content = "#";
155
- }
156
-
157
  // Find the coverphoto link
158
  if ( $coverphoto ) {
159
  $photolink = wppa_get_imglnk_a( 'coverimg',
@@ -318,15 +308,7 @@ global $wpdb;
318
  );
319
 
320
  // The 'View' link
321
- wppa_album_cover_view_link( $albumid,
322
- $has_content,
323
- $photocount,
324
- $albumcount,
325
- '0',
326
- $href_content,
327
- $target,
328
- $onclick_content
329
- );
330
 
331
  // Close the Cover text frame
332
  if ( $photo_pos != 'left' ) {
@@ -395,17 +377,15 @@ global $wpdb;
395
  $coverphoto = false;
396
  }
397
 
398
- $photocount = wppa_get_photo_count( $albumid );
399
  $albumcount = wppa_get_album_count( $albumid, 'use_treecounts' );
400
  $title = '';
401
  $linkpage = '';
402
 
403
  $href_title = '';
404
  $href_slideshow = '';
405
- $href_content = '';
406
  $onclick_title = '';
407
  $onclick_slideshow = '';
408
- $onclick_content = '';
409
 
410
  // See if there is substantial content to the album
411
  $has_content = $albumcount || $photocount;
@@ -477,14 +457,6 @@ global $wpdb;
477
  $href_slideshow = "#";
478
  }
479
 
480
- // Find the content 'View' link
481
- $href_content = wppa_get_album_url( array( 'album' => $albumid, 'page' => $linkpage ) );
482
- $ajax_content = wppa_get_album_url_ajax( array( 'album' => $albumid, 'page' => $linkpage ) );
483
- if ( ! $linkpage ) {
484
- $onclick_content = "wppaDoAjaxRender( " . wppa( 'mocc' ) . ", '" . $ajax_content . "', '" . $href_content . "' )";
485
- $href_content = "#";
486
- }
487
-
488
  $style = '';
489
  if ( is_feed() ) $style .= ' padding:7px;';
490
 
@@ -561,15 +533,7 @@ global $wpdb;
561
  );
562
 
563
  // The 'View' link
564
- wppa_album_cover_view_link( $albumid,
565
- $has_content,
566
- $photocount,
567
- $albumcount,
568
- '0',
569
- $href_content,
570
- $target,
571
- $onclick_content
572
- );
573
 
574
  // Close the Cover text frame
575
  wppa_out( '</div>' );
@@ -611,17 +575,15 @@ global $wpdb;
611
 
612
  $coverphoto = wppa_get_coverphoto_id( $albumid );
613
  $image = wppa_cache_thumb( $coverphoto );
614
- $photocount = wppa_get_photo_count( $albumid );
615
  $albumcount = wppa_get_album_count( $albumid, true );
616
  $title = '';
617
  $linkpage = '';
618
 
619
  $href_title = '';
620
  $href_slideshow = '';
621
- $href_content = '';
622
  $onclick_title = '';
623
  $onclick_slideshow = '';
624
- $onclick_content = '';
625
 
626
  // See if there is substantial content to the album
627
  $has_content = $albumcount || $photocount;
@@ -651,14 +613,6 @@ global $wpdb;
651
  $href_slideshow = "#";
652
  }
653
 
654
- // Find the content 'View' link
655
- $href_content = wppa_get_album_url( array( 'album' => $albumid, 'page' => $linkpage ) );
656
- $ajax_content = wppa_get_album_url_ajax( array( 'album' => $albumid, 'page' => $linkpage ) );
657
- if ( ! $linkpage ) {
658
- $onclick_content = "wppaDoAjaxRender( " . wppa( 'mocc' ) . ", '" . $ajax_content . "', '" . $href_content . "' )";
659
- $href_content = "#";
660
- }
661
-
662
  // Find the coverphoto link
663
  if ( $coverphoto ) {
664
  $photolink = wppa_get_imglnk_a(
@@ -753,15 +707,7 @@ global $wpdb;
753
  wppa_the_slideshow_browse_link( $photocount, $href_slideshow, $onclick_slideshow, $target );
754
 
755
  // The 'View' link
756
- wppa_album_cover_view_link( $albumid,
757
- $has_content,
758
- $photocount,
759
- $albumcount,
760
- '0',
761
- $href_content,
762
- $target,
763
- $onclick_content
764
- );
765
 
766
  // Close the Cover text frame
767
  wppa_out( '</div>' );
@@ -814,7 +760,7 @@ global $wpdb;
814
  $coverphoto = wppa_get_coverphoto_id( $id );
815
  if ( ! $coverphoto ) return;
816
  $image = wppa_cache_thumb( $coverphoto );
817
- $photocount = wppa_get_photo_count( $id );
818
  $albumcount = wppa_get_album_count( $id, 'use_treecounts' );
819
 
820
  // Init links
@@ -1691,116 +1637,164 @@ function wppa_get_album_title_attr_a( $albumid, $linktype, $linkpage, $has_conte
1691
  }
1692
 
1693
  // The 'View' link
1694
- function wppa_album_cover_view_link(
1695
- $albumid, $has_content, $photocount, $albumcount, $mincount, $href_content,
1696
- $target, $onclick_content ) {
1697
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1698
 
1699
- $album = wppa_cache_album( $albumid );
 
 
 
 
1700
 
1701
- if ( wppa_switch( 'show_viewlink' ) ) {
1702
 
1703
- // Find the album specific cover type
1704
- $cover_type = wppa_get_album_item( $albumid, 'cover_type' );
 
 
1705
 
1706
- // No type specified (0), use default
1707
- if ( ! $cover_type ) {
1708
- $cover_type = wppa_opt( 'cover_type' );
1709
- }
 
 
 
 
 
 
1710
 
1711
- // For imgfakt, class .wppa-viewlink-sym
1712
- if ( $cover_type == 'imagefactory' || $cover_type == 'imagefactory-mcr' ) {
1713
- wppa_out( '<div class="wppa-box-text wppa-black wppa-info wppa-viewlink-sym wppa-album-cover-link">' );
 
 
 
 
 
 
1714
  }
1715
 
1716
- // Normal: class .wppa-viewlink
1717
  else {
1718
- wppa_out( '<div class="wppa-box-text wppa-black wppa-info wppa-viewlink wppa-album-cover-link">' );
 
 
 
 
 
1719
  }
1720
 
1721
- if ( $has_content ) {
 
 
1722
 
1723
- // Fake photocount to prevent link to empty page
1724
- if ( wppa_opt( 'thumbtype' ) == 'none' ) $photocount = '0';
1725
-
1726
- // Still has content
1727
- if ( $photocount || $albumcount ) {
1728
-
1729
- // Get treecount data
1730
- // if ( wppa_opt( 'show_treecount' ) != '-none-' ) {
1731
- $treecount = wppa_get_treecounts_a( $albumid );
1732
- // }
1733
- // else {
1734
- // $treecount = false;
1735
- // }
1736
-
1737
- if ( $href_content == '#' ) {
1738
- wppa_out(
1739
- '<a class="wppa-album-cover-link" onclick="' . $onclick_content . '" title="' . __( 'View the album' , 'wp-photo-album-plus' ) . ' ' .
1740
- esc_attr( stripslashes( __( $album['name'] ) ) ) . '" style="cursor:pointer">'
1741
- );
1742
  }
1743
- else {
1744
- wppa_out(
1745
- '<a class="wppa-album-cover-link" href="' . $href_content . '" target="' . $target . '" onclick="' .
1746
- $onclick_content . '" title="' . __( 'View the album' , 'wp-photo-album-plus' ) . ' ' .
1747
- esc_attr( stripslashes( __( $album['name'] ) ) ) .
1748
- '" style="cursor:pointer">'
1749
- );
1750
  }
 
 
 
 
1751
 
1752
- $na = $albumcount;
1753
- $nta = $treecount['treealbums'] > $albumcount ? $treecount['treealbums'] : '';
1754
- $ntax = $treecount['treealbums'] > $albumcount ? $treecount['treealbums'] : $albumcount;
1755
- $np = $photocount;
1756
- $ntp = $treecount['treephotos'] > $photocount ? $treecount['treephotos'] : '';
1757
- $ntpx = $treecount['treephotos'] > $photocount ? $treecount['treephotos'] : $photocount;
1758
-
1759
- $text = '';
1760
-
1761
- if ( wppa_opt( 'show_treecount' ) == 'total' ) {
1762
- if ( $ntax ) {
1763
- $text .= sprintf( _n( 'View %d album', 'View %d albums', $ntax, 'wp-photo-album-plus' ), $ntax ) . ' ';
1764
  }
1765
- if ( $ntpx ) {
1766
- $text .= sprintf( _n( 'View %d photo', 'View %d photos', $ntpx, 'wp-photo-album-plus' ), $ntpx ) . ' ';
 
 
 
 
 
 
1767
  }
1768
  }
1769
  else {
1770
- if ( $na || $nta ) {
1771
- if ( $na ) {
1772
- $text .= sprintf( _n( 'View %d album', 'View %d albums', $na, 'wp-photo-album-plus' ), $na ) . ' ';
1773
- }
1774
- if ( $nta ) {
1775
- $text .= '(' . $nta . ') ';
1776
- }
1777
- if ( $np || $ntp ) {
1778
- $text .= sprintf( _n( 'and %d photo', 'and %d photos', $np, 'wp-photo-album-plus' ), $np ) . ' ';
1779
- }
1780
- if ( $ntp ) {
1781
- $text .= '(' . $ntp . ')';
1782
- }
1783
  }
1784
- else {
1785
- if ( $np || $ntp ) {
1786
- $text .= sprintf( _n( 'View %d photo', 'View %d photos', $np, 'wp-photo-album-plus' ), $np ) . ' ';
1787
- }
1788
- if ( $ntp ) {
1789
- $text .= '(' . $ntp . ')';
1790
- }
1791
  }
1792
  }
 
1793
 
1794
- wppa_out( str_replace( ' ', '&nbsp;', wppa_album_to_gallery( $text ) ) );
1795
-
1796
- wppa_out( '</a>' );
1797
- }
1798
- }
1799
- else {
1800
- wppa_out( '&nbsp;' );
 
 
 
 
 
1801
  }
1802
- wppa_out( '</div>' );
1803
- }
 
 
 
 
1804
  }
1805
 
1806
  function wppa_the_album_title( $alb, $href_title, $onclick_title, $title, $target ) {
@@ -1836,7 +1830,7 @@ function wppa_the_album_title( $alb, $href_title, $onclick_title, $title, $targe
1836
  // Photo count?
1837
  if ( wppa_opt( 'count_on_title' ) != '-none-' ) {
1838
  if ( wppa_opt( 'count_on_title' ) == 'self' ) {
1839
- $cnt = wppa_get_photo_count( $alb );
1840
  }
1841
  if ( wppa_opt( 'count_on_title' ) == 'total' ) {
1842
  $temp = wppa_get_treecounts_a( $alb );
@@ -2064,7 +2058,7 @@ global $wpdb;
2064
 
2065
  // Find the content 'View' link
2066
  $albumid = $album['id'];
2067
- $photocount = wppa_get_photo_count( $albumid );
2068
 
2069
  // Thumbnails and covers, show subalbum covers
2070
  // in case slideshow is requested on an empty album
@@ -2093,7 +2087,7 @@ global $wpdb;
2093
 
2094
  // Subalbum title link
2095
  elseif ( wppa_opt( 'cover_sublinks' ) == 'title' ) {
2096
- $pc = wppa_get_photo_count( $albumid, true );
2097
  $ac = wppa_get_album_count( $albumid, true );
2098
  $sub_attr = wppa_get_album_title_attr_a( $albumid,
2099
  $album['cover_linktype'],
3
  * Package: wp-photo-album-plus
4
  *
5
  * Functions for album covers
6
+ * Version 8.2.04.004
7
  *
8
  */
9
 
92
  // Find album details
93
  $coverphoto = wppa_get_coverphoto_id( $albumid );
94
  $image = wppa_cache_thumb( $coverphoto );
95
+ $photocount = wppa_get_visible_photo_count( $albumid );
96
  $albumcount = wppa_get_album_count( $albumid, 'use_treecounts' );
97
 
98
  // Init links
100
  $linkpage = '';
101
  $href_title = '';
102
  $href_slideshow = '';
 
103
  $onclick_title = '';
104
  $onclick_slideshow = '';
 
105
 
106
  // See if there is substantial content to the album
107
  $has_content = $albumcount || $photocount;
144
  $href_slideshow = "#";
145
  }
146
 
 
 
 
 
 
 
 
 
147
  // Find the coverphoto link
148
  if ( $coverphoto ) {
149
  $photolink = wppa_get_imglnk_a( 'coverimg',
308
  );
309
 
310
  // The 'View' link
311
+ wppa_album_cover_view_link( $albumid );
 
 
 
 
 
 
 
 
312
 
313
  // Close the Cover text frame
314
  if ( $photo_pos != 'left' ) {
377
  $coverphoto = false;
378
  }
379
 
380
+ $photocount = wppa_get_visible_photo_count( $albumid );
381
  $albumcount = wppa_get_album_count( $albumid, 'use_treecounts' );
382
  $title = '';
383
  $linkpage = '';
384
 
385
  $href_title = '';
386
  $href_slideshow = '';
 
387
  $onclick_title = '';
388
  $onclick_slideshow = '';
 
389
 
390
  // See if there is substantial content to the album
391
  $has_content = $albumcount || $photocount;
457
  $href_slideshow = "#";
458
  }
459
 
 
 
 
 
 
 
 
 
460
  $style = '';
461
  if ( is_feed() ) $style .= ' padding:7px;';
462
 
533
  );
534
 
535
  // The 'View' link
536
+ wppa_album_cover_view_link( $albumid );
 
 
 
 
 
 
 
 
537
 
538
  // Close the Cover text frame
539
  wppa_out( '</div>' );
575
 
576
  $coverphoto = wppa_get_coverphoto_id( $albumid );
577
  $image = wppa_cache_thumb( $coverphoto );
578
+ $photocount = wppa_get_visible_photo_count( $albumid );
579
  $albumcount = wppa_get_album_count( $albumid, true );
580
  $title = '';
581
  $linkpage = '';
582
 
583
  $href_title = '';
584
  $href_slideshow = '';
 
585
  $onclick_title = '';
586
  $onclick_slideshow = '';
 
587
 
588
  // See if there is substantial content to the album
589
  $has_content = $albumcount || $photocount;
613
  $href_slideshow = "#";
614
  }
615
 
 
 
 
 
 
 
 
 
616
  // Find the coverphoto link
617
  if ( $coverphoto ) {
618
  $photolink = wppa_get_imglnk_a(
707
  wppa_the_slideshow_browse_link( $photocount, $href_slideshow, $onclick_slideshow, $target );
708
 
709
  // The 'View' link
710
+ wppa_album_cover_view_link( $albumid );
 
 
 
 
 
 
 
 
711
 
712
  // Close the Cover text frame
713
  wppa_out( '</div>' );
760
  $coverphoto = wppa_get_coverphoto_id( $id );
761
  if ( ! $coverphoto ) return;
762
  $image = wppa_cache_thumb( $coverphoto );
763
+ $photocount = wppa_get_visible_photo_count( $id );
764
  $albumcount = wppa_get_album_count( $id, 'use_treecounts' );
765
 
766
  // Init links
1637
  }
1638
 
1639
  // The 'View' link
1640
+ function wppa_album_cover_view_link( $id ) {
1641
+ global $wpdb;
 
1642
 
1643
+ // Anything to do?
1644
+ if ( ! wppa_switch( 'show_viewlink' ) ) return;
1645
+
1646
+ // Find essential data
1647
+ $type = wppa_get_album_item( $id, 'cover_type' ) or wppa_opt( 'cover_type' );
1648
+ $album = wppa_cache_album( $id );
1649
+ $treecount = wppa_get_treecounts_a( $id );
1650
+ $class = 'wppa-box-text wppa-black wppa-info wppa-viewlink wppa-album-cover-link';
1651
+ if ( $type == 'imagefactory' || $type == 'imagefactory-mcr' ) {
1652
+ $class = 'wppa-box-text wppa-black wppa-info wppa-viewlink-sym wppa-album-cover-link';
1653
+ }
1654
+
1655
+ /*
1656
+ // Fix counts for non admin and not login
1657
+ // $na = $treecount['selfalbums'];
1658
+ // $np = $treecount['selfphotos'];
1659
+ $nta = $treecount['treealbums'];
1660
+ $ntp = $treecount['treephotos'];
1661
+ if ( ! wppa_user_is( 'administrator' ) ) {
1662
+ $na -= $treecount['hiddenalbums'];
1663
+ // $np -= $treecount['pendselfphotos'];
1664
+ $nta -= $treecount['hiddentreealbums'];
1665
+ $ntp -= $treecount['pendtreephotos'];
1666
+ }
1667
+ if ( ! is_user_logged_in() ) {
1668
+ $na -= $treecount['privatealbums'];
1669
+ // $np -= $treecount[];
1670
+ $nta -= $treecount['privatetreealbums'];
1671
+ // $ntp -= $treecount[];
1672
+ }
1673
+ */
1674
+ $na = wppa_get_visible_album_count( $id );
1675
+ $np = wppa_get_visible_photo_count( $id );
1676
+ $nta = wppa_get_visible_subtree_album_count( $id );
1677
+ $ntp = wppa_get_visible_subtree_photo_count( $id );
1678
+
1679
+ /*
1680
+ // Verify the direct subalbums left (if any) are all non-empty
1681
+ if ( $na ) {
1682
+ $children = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_albums WHERE a_parent = %s", $id ) );
1683
+ $new_na = '0';
1684
+ foreach( $children as $c ) {
1685
+ if ( ! wppa_is_album_empty( $c ) ) {
1686
+ $new_na++;
1687
+ }
1688
+ }
1689
+ if ( $new_na != $na ) {
1690
+ wppa_log('obs', "na corrected from $na to $new_na for album $id");
1691
 
1692
+ // Correct tree albums
1693
+ $nta = $nta + $new_na - $na;
1694
+ $na = $new_na;
1695
+ }
1696
+ }
1697
 
1698
+ */
1699
 
1700
+ // Anything left to show?
1701
+ if ( ! $na && ! $np && ! $nta && ! $ntp ) {
1702
+ return;
1703
+ }
1704
 
1705
+ // Find the content 'View' link href and ajax url and onclick
1706
+ $page = max( $album['cover_linkpage'], '0' );
1707
+ $href = wppa_get_album_url( array( 'album' => $id, 'page' => $page ) );
1708
+ $ajax = wppa_get_album_url_ajax( array( 'album' => $id, 'page' => $page ) );
1709
+ $onclick = '';
1710
+ if ( ! $page ) {
1711
+ $onclick = "wppaDoAjaxRender( " . wppa( 'mocc' ) . ", '" . $ajax . "', '" . $href . "' )";
1712
+ $href = "#";
1713
+ }
1714
+ $target = '_self';
1715
 
1716
+ // Open the div
1717
+ wppa_out( '<div class="' . $class . '">' );
1718
+
1719
+ // Ajax link
1720
+ if ( $href == '#' ) {
1721
+ wppa_out(
1722
+ '<a class="wppa-album-cover-link" onclick="' . $onclick . '" title="' . __( 'View the album' , 'wp-photo-album-plus' ) . ' ' .
1723
+ esc_attr( stripslashes( __( $album['name'] ) ) ) . '" style="cursor:pointer">'
1724
+ );
1725
  }
1726
 
1727
+ // Non ajax
1728
  else {
1729
+ wppa_out(
1730
+ '<a class="wppa-album-cover-link" href="' . $href . '" target="' . $target . '" onclick="' .
1731
+ $onclick . '" title="' . __( 'View the album' , 'wp-photo-album-plus' ) . ' ' .
1732
+ esc_attr( stripslashes( __( $album['name'] ) ) ) .
1733
+ '" style="cursor:pointer">'
1734
+ );
1735
  }
1736
 
1737
+ // Make the link text
1738
+ $text = '';
1739
+ switch( wppa_opt( 'show_treecount' ) ) {
1740
 
1741
+ case '-none-':
1742
+ if ( $na && $np ) {
1743
+ $text .= sprintf( _n( 'View %d album', 'View %d albums', $na, 'wp-photo-album-plus' ), $na ) . ' ';
1744
+ $text .= sprintf( _n( 'and %d photo', 'and %d photos', $np, 'wp-photo-album-plus' ), $np );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1745
  }
1746
+ elseif ( $na ) {
1747
+ $text .= sprintf( _n( 'View %d album', 'View %d albums', $na, 'wp-photo-album-plus' ), $na );
 
 
 
 
 
1748
  }
1749
+ elseif ( $np ) {
1750
+ $text .= sprintf( _n( 'View %d photo', 'View %d photos', $np, 'wp-photo-album-plus' ), $np );
1751
+ }
1752
+ break;
1753
 
1754
+ case 'detail':
1755
+ if ( $na ) {
1756
+ if ( $na ) {
1757
+ $text .= sprintf( _n( 'View %d album', 'View %d albums', $na, 'wp-photo-album-plus' ), $na ) . ' ';
 
 
 
 
 
 
 
 
1758
  }
1759
+ if ( $nta && $na != $nta ) {
1760
+ $text .= '(' . $nta . ') ';
1761
+ }
1762
+ if ( $np || $ntp ) {
1763
+ $text .= sprintf( _n( 'and %d photo', 'and %d photos', $np, 'wp-photo-album-plus' ), $np ) . ' ';
1764
+ }
1765
+ if ( $ntp && $np != $ntp ) {
1766
+ $text .= '(' . $ntp . ')';
1767
  }
1768
  }
1769
  else {
1770
+ if ( $np || $ntp ) {
1771
+ $text .= sprintf( _n( 'View %d photo', 'View %d photos', $np, 'wp-photo-album-plus' ), $np ) . ' ';
 
 
 
 
 
 
 
 
 
 
 
1772
  }
1773
+ if ( $ntp && $np != $ntp ) {
1774
+ $text .= '(' . $ntp . ')';
 
 
 
 
 
1775
  }
1776
  }
1777
+ break;
1778
 
1779
+ case 'total':
1780
+ if ( $nta && $np ) {
1781
+ $text .= sprintf( _n( 'View %d album', 'View %d albums', $nta, 'wp-photo-album-plus' ), $nta ) . ' ';
1782
+ $text .= sprintf( _n( 'and %d photo', 'and %d photos', $np, 'wp-photo-album-plus' ), $np );
1783
+ }
1784
+ elseif ( $nta ) {
1785
+ $text .= sprintf( _n( 'View %d album', 'View %d albums', $nta, 'wp-photo-album-plus' ), $nta );
1786
+ }
1787
+ elseif ( $np ) {
1788
+ $text .= sprintf( _n( 'View %d photo', 'View %d photos', $np, 'wp-photo-album-plus' ), $np );
1789
+ }
1790
+ break;
1791
  }
1792
+
1793
+ wppa_out( str_replace( ' ', '&nbsp;', wppa_album_to_gallery( $text ) ) );
1794
+
1795
+ wppa_out( '</a>' );
1796
+
1797
+ wppa_out( '</div>' );
1798
  }
1799
 
1800
  function wppa_the_album_title( $alb, $href_title, $onclick_title, $title, $target ) {
1830
  // Photo count?
1831
  if ( wppa_opt( 'count_on_title' ) != '-none-' ) {
1832
  if ( wppa_opt( 'count_on_title' ) == 'self' ) {
1833
+ $cnt = wppa_get_visible_photo_count( $alb );
1834
  }
1835
  if ( wppa_opt( 'count_on_title' ) == 'total' ) {
1836
  $temp = wppa_get_treecounts_a( $alb );
2058
 
2059
  // Find the content 'View' link
2060
  $albumid = $album['id'];
2061
+ $photocount = wppa_get_visible_photo_count( $albumid );
2062
 
2063
  // Thumbnails and covers, show subalbum covers
2064
  // in case slideshow is requested on an empty album
2087
 
2088
  // Subalbum title link
2089
  elseif ( wppa_opt( 'cover_sublinks' ) == 'title' ) {
2090
+ $pc = wppa_get_visible_photo_count( $albumid, true );
2091
  $ac = wppa_get_album_count( $albumid, true );
2092
  $sub_attr = wppa_get_album_title_attr_a( $albumid,
2093
  $album['cover_linktype'],
wppa-album-navigator-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * display album names linking to content
6
- * Version 8.2.01.001
7
  */
8
 
9
  class AlbumNavigatorWidget extends WP_Widget {
@@ -265,7 +265,7 @@ class AlbumNavigatorWidget extends WP_Widget {
265
  // Link is lightbox
266
  if ( $link['is_lightbox'] ) {
267
 
268
- $count = wppa_get_photo_count( $a, true ); //$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE album = %s", $album['id'] ) );
269
  if ( $count <= 1000 ) {
270
  $thumbs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE album = %s " . wppa_get_photo_order( $album['id'] ), $album['id'] ), ARRAY_A );
271
  wppa_cache_thumb( 'invalidate' );
3
  * Package: wp-photo-album-plus
4
  *
5
  * display album names linking to content
6
+ * Version 8.2.04.004
7
  */
8
 
9
  class AlbumNavigatorWidget extends WP_Widget {
265
  // Link is lightbox
266
  if ( $link['is_lightbox'] ) {
267
 
268
+ $count = wppa_get_visible_photo_count( $a, true ); //$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE album = %s", $album['id'] ) );
269
  if ( $count <= 1000 ) {
270
  $thumbs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE album = %s " . wppa_get_photo_order( $album['id'] ), $album['id'] ), ARRAY_A );
271
  wppa_cache_thumb( 'invalidate' );
wppa-breadcrumb.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Functions for breadcrumbs
6
- * Version 8.2.01.005
7
  *
8
  */
9
 
@@ -732,7 +732,7 @@ global $wpdb;
732
  $slide = ( wppa_get_album_title_linktype( $parent ) == 'slide' ) ? '&amp;wppa-slide' : '';
733
 
734
  // NOT SLIDE when there are no photos
735
- if ( ! wppa_get_photo_count( $parent, 'use_treecounts' ) ) {
736
  $slide = '';
737
  }
738
 
3
  * Package: wp-photo-album-plus
4
  *
5
  * Functions for breadcrumbs
6
+ * Version 8.2.04.004
7
  *
8
  */
9
 
732
  $slide = ( wppa_get_album_title_linktype( $parent ) == 'slide' ) ? '&amp;wppa-slide' : '';
733
 
734
  // NOT SLIDE when there are no photos
735
+ if ( ! wppa_get_visible_photo_count( $parent, 'use_treecounts' ) ) {
736
  $slide = '';
737
  }
738
 
wppa-comment-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the recent commets on photos
6
- * Version 8.2.01.001
7
  */
8
 
9
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
@@ -114,7 +114,7 @@ class wppaCommentWidget extends WP_Widget {
114
  else {
115
  $widget_content .= __( 'Photo not found', 'wp-photo-album-plus' );
116
  }
117
- $widget_content .= "\n\t".'<span style="font-size:'.wppa_opt( 'fontsize_widget_thumb' ).'px; cursor:pointer" title="'.esc_attr($first_comment['comment']).'" >'.htmlspecialchars($first_comment['user']).'</span>';
118
  $widget_content .= "\n".'</div>';
119
 
120
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the recent commets on photos
6
+ * Version 8.2.04.004
7
  */
8
 
9
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
114
  else {
115
  $widget_content .= __( 'Photo not found', 'wp-photo-album-plus' );
116
  }
117
+ $widget_content .= "\n\t".'<span class="wppa-comment-owner" style="font-size:'.wppa_opt( 'fontsize_widget_thumb' ).'px; cursor:pointer" title="'.esc_attr($first_comment['comment']).'" >'.htmlspecialchars($first_comment['user']).'</span>';
118
  $widget_content .= "\n".'</div>';
119
 
120
  }
wppa-common-functions.php CHANGED
@@ -2,7 +2,7 @@
2
  /* wppa-common-functions.php
3
  *
4
  * Functions used in admin and in themes
5
- * Version 8.2.03.006
6
  *
7
  */
8
 
@@ -1791,7 +1791,7 @@ global $wpdb;
1791
  // Filter for must have content
1792
  if ( $args['content'] ) {
1793
  foreach ( array_keys( $albums ) as $albidx ) {
1794
- if ( ! wppa_get_photo_count( $albums[$albidx]['id'] ) ) unset ( $albums[$albidx] );
1795
  }
1796
  }
1797
  // Add paths
2
  /* wppa-common-functions.php
3
  *
4
  * Functions used in admin and in themes
5
+ * Version 8.2.04.004
6
  *
7
  */
8
 
1791
  // Filter for must have content
1792
  if ( $args['content'] ) {
1793
  foreach ( array_keys( $albums ) as $albidx ) {
1794
+ if ( ! wppa_get_visible_photo_count( $albums[$albidx]['id'] ) ) unset ( $albums[$albidx] );
1795
  }
1796
  }
1797
  // Add paths
wppa-defaults.php CHANGED
@@ -973,6 +973,7 @@ horizrailenabled:false,";
973
  'wppa_use_wp_editor' => 'no',
974
  'wppa_admin_theme_css' => 'no',
975
  'wppa_admin_inline_css' => '',
 
976
  'wppa_generator_max' => '100', // B21
977
  'wppa_retry_mails' => '2', // M100
978
  'wppa_minimum_tags' => '', // A11
973
  'wppa_use_wp_editor' => 'no',
974
  'wppa_admin_theme_css' => 'no',
975
  'wppa_admin_inline_css' => '',
976
+ 'wppa_admin_extra_css' => '',
977
  'wppa_generator_max' => '100', // B21
978
  'wppa_retry_mails' => '2', // M100
979
  'wppa_minimum_tags' => '', // A11
wppa-init.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * This file loads required php files and contains all functions used in init actions.
6
  *
7
- * Version 8.2.02.008
8
  */
9
 
10
  /* LOAD SIDEBAR WIDGETS */
@@ -254,6 +254,7 @@ function wppa_verify_multisite_config() {
254
  $errtxt .= __('<br><br><b>define( \'WPPA_MULTISITE_INDIVIDUAL\', true );</b> <small>// Multisite WP 3.5 or later with every site its own albums and photos</small>', 'wp-photo-album-plus' );
255
  $errtxt .= __('<br><b>define( \'WPPA_MULTISITE_BLOGSDIR\', true );</b> <small>// Multisite prior to WP 3.5 with every site its own albums and photos</small>', 'wp-photo-album-plus' );
256
  $errtxt .= __('<br><b>define( \'WPPA_MULTISITE_GLOBAL\', true );</b> <small>// Multisite with one common set of albums and photos</small>', 'wp-photo-album-plus' );
 
257
  $errtxt .= __('<br><br>For more information see: <a href="https://wordpress.org/plugins/wp-photo-album-plus/faq/">the faq</a>', 'wp-photo-album-plus' );
258
  $errtxt .= __('<br><br><em>If you upload photos, they will be placed in the wrong location and will not be visible for visitors!</em><strong>', 'wp-photo-album-plus' );
259
 
@@ -532,7 +533,7 @@ function wppa_activate_albtogal_conversion() {
532
  if ( get_option( 'wppa_album_use_gallery', 'no' ) == 'no' ) {
533
  return;
534
  }
535
-
536
  add_filter( 'gettext', 'wppa_album_to_gallery', 100 );
537
  }
538
  add_action( 'plugins_loaded', 'wppa_activate_albtogal_conversion', 20 );
4
  *
5
  * This file loads required php files and contains all functions used in init actions.
6
  *
7
+ * Version 8.2.04.004
8
  */
9
 
10
  /* LOAD SIDEBAR WIDGETS */
254
  $errtxt .= __('<br><br><b>define( \'WPPA_MULTISITE_INDIVIDUAL\', true );</b> <small>// Multisite WP 3.5 or later with every site its own albums and photos</small>', 'wp-photo-album-plus' );
255
  $errtxt .= __('<br><b>define( \'WPPA_MULTISITE_BLOGSDIR\', true );</b> <small>// Multisite prior to WP 3.5 with every site its own albums and photos</small>', 'wp-photo-album-plus' );
256
  $errtxt .= __('<br><b>define( \'WPPA_MULTISITE_GLOBAL\', true );</b> <small>// Multisite with one common set of albums and photos</small>', 'wp-photo-album-plus' );
257
+ $errtxt .= __('<br><br>Make sure to add this in wp-config.php prior to the line "require_once ABSPATH . \'wp-settings.php\';"', 'wp-photo-album-plus' );
258
  $errtxt .= __('<br><br>For more information see: <a href="https://wordpress.org/plugins/wp-photo-album-plus/faq/">the faq</a>', 'wp-photo-album-plus' );
259
  $errtxt .= __('<br><br><em>If you upload photos, they will be placed in the wrong location and will not be visible for visitors!</em><strong>', 'wp-photo-album-plus' );
260
 
533
  if ( get_option( 'wppa_album_use_gallery', 'no' ) == 'no' ) {
534
  return;
535
  }
536
+
537
  add_filter( 'gettext', 'wppa_album_to_gallery', 100 );
538
  }
539
  add_action( 'plugins_loaded', 'wppa_activate_albtogal_conversion', 20 );
wppa-items.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains functions to retrieve album and photo items
6
- * Version 8.1.09.004
7
  *
8
  */
9
 
@@ -118,105 +118,77 @@ function wppa_cache_photo( $id, $data = '' ) {
118
  }
119
  function wppa_cache_thumb( $id, $data = '' ) {
120
  global $wpdb;
121
- static $thumb;
122
- static $thumb_cache_2;
123
 
124
  // $id?
125
  if ( ! $id ) {
126
  return false;
127
  }
128
 
 
 
 
 
 
129
  // Invalidate ?
130
  if ( $id == 'invalidate' ) {
131
  if ( $data ) {
132
- if ( isset( $thumb_cache_2[$data] ) ) unset( $thumb_cache_2[$data] );
133
- $thumb = false;
 
 
134
  return false;
135
  }
136
  else {
137
- $thumb = null;
138
- $thumb_cache_2 = null;
139
  return false;
140
  }
141
  }
142
 
143
  // Add ?
144
  if ( $id == 'add' ) {
145
- if ( ! $data ) { // Nothing to add
146
- return false;
147
- }
148
- elseif ( isset( $data['id'] ) ) { // Add a single thumb to 2nd level cache
149
- if ( count( $data ) < 31 ) {
150
- wppa_log( 'Err', 'Attempt to cache add incomplete photo item '.$data['id'].'. Only '.count( $data ).' items supplied.' );
151
- return false;
152
  }
153
- $thumb_cache_2[$data['id']] = $data; // Looks valid
154
- }
155
- elseif ( count( $data ) > 10000 ) {
156
- return false; // Too many, may cause out of memory error
157
- }
158
- else foreach( $data as $thumb ) { // Add multiple
159
- if ( isset( $thumb['id'] ) ) { // Looks valid
160
- if ( count( $thumb ) < 31 ) {
161
- wppa_log( 'Err', 'Attempt to cache add incomplete photo item '.$thumb['id'].'. Only '.count( $thumb ).' items supplied.' );
162
- return false;
163
- }
164
- $thumb_cache_2[$thumb['id']] = $thumb;
165
  }
166
  }
167
  return false;
168
  }
169
 
170
- // Count ?
171
- if ( $id == 'count' ) {
172
- if ( is_array( $thumb_cache_2 ) ) {
173
- return count( $thumb_cache_2 );
174
- }
175
- else {
176
- return false;
177
- }
178
- }
179
-
180
  // Error in arg?
181
  if ( ! wppa_is_int( $id ) || $id < '1' ) {
182
- wppa_dbg_msg( 'Invalid arg wppa_cache_thumb('.serialize($id).')', 'red' );
183
  wppa_log('err', 'Invalid arg wppa_cache_thumb('.serialize($id).')', true);
184
- $thumb = false;
185
- wppa( 'current_photo', false );
186
  return false;
187
  }
188
 
189
- // In first level cache?
190
- if ( isset( $thumb['id'] ) && $thumb['id'] == $id ) {
191
- wppa_dbg_cachecounts( 'photohit' );
192
- wppa( 'current_photo', $thumb );
193
- return $thumb;
194
- }
195
-
196
- // In second level cache?
197
- if ( ! empty( $thumb_cache_2 ) ) {
198
- if ( in_array( $id, array_keys( $thumb_cache_2 ) ) ) {
199
- $thumb = $thumb_cache_2[$id];
200
- wppa( 'current_photo', $thumb );
201
- wppa_dbg_cachecounts( 'photohit' );
202
- return $thumb;
203
- }
204
  }
205
 
206
  // Not in cache, do query
207
- $thumb = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE id = %s", $id ), ARRAY_A );
208
- wppa_dbg_cachecounts( 'photomis' );
209
-
210
- // Found one?
211
- if ( $thumb ) {
212
- // Store in second level cache
213
- $thumb_cache_2[$id] = $thumb;
214
- wppa( 'current_photo', $thumb );
215
- return $thumb;
216
  }
217
  else {
218
- wppa_dbg_msg( 'Photo '.$id.' does not exist', 'red' );
219
  wppa( 'current_photo', false );
 
220
  return false;
221
  }
222
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains functions to retrieve album and photo items
6
+ * Version 8.2.04.004
7
  *
8
  */
9
 
118
  }
119
  function wppa_cache_thumb( $id, $data = '' ) {
120
  global $wpdb;
121
+ static $cache;
 
122
 
123
  // $id?
124
  if ( ! $id ) {
125
  return false;
126
  }
127
 
128
+ // Init
129
+ if ( ! is_array( $cache ) ) {
130
+ $cache = array();
131
+ }
132
+
133
  // Invalidate ?
134
  if ( $id == 'invalidate' ) {
135
  if ( $data ) {
136
+ if ( isset( $cache[$data] ) ) {
137
+ unset( $cache[$data] );
138
+ wppa_log('obs', "Cache invalidate in wppa_cache_thumb $data");
139
+ }
140
  return false;
141
  }
142
  else {
143
+ $cache = array();
 
144
  return false;
145
  }
146
  }
147
 
148
  // Add ?
149
  if ( $id == 'add' ) {
150
+ if ( ! is_array( $data ) ) return;
151
+ foreach( $data as $item ) {
152
+ if ( is_array( $item ) && isset( $item['id'] ) ) {
153
+ $cache[$item['id']] = $item;
 
 
 
154
  }
155
+ else {
156
+ wppa_log('err', 'Invalid data in wppa_cache_thumb');
157
+ $cache = array();
158
+ return false;
 
 
 
 
 
 
 
 
159
  }
160
  }
161
  return false;
162
  }
163
 
 
 
 
 
 
 
 
 
 
 
164
  // Error in arg?
165
  if ( ! wppa_is_int( $id ) || $id < '1' ) {
 
166
  wppa_log('err', 'Invalid arg wppa_cache_thumb('.serialize($id).')', true);
 
 
167
  return false;
168
  }
169
 
170
+ // In cache?
171
+ if ( isset( $cache[$id] ) ) {
172
+ wppa( 'current_photo', $cache[$id] );
173
+ // $stack = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 4 );
174
+ // $f = $stack[1]['function'] . ' - ' . $stack[2]['function'] . ' - ' . $stack[3]['function'];
175
+ // wppa_log('obs', "Cache hit in wppa_cache_thumb $id from $f");
176
+ return $cache[$id];
 
 
 
 
 
 
 
 
177
  }
178
 
179
  // Not in cache, do query
180
+ $cache[$id] = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE id = %s", $id ), ARRAY_A );
181
+ if ( $cache[$id] ) {
182
+ wppa( 'current_photo', $cache[$id] );
183
+ // $stack = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 4 );
184
+ // $f = $stack[1]['function'] . ' - ' . $stack[2]['function'] . ' - ' . $stack[3]['function'];
185
+ // wppa_log('obs', "Cache miss in wppa_cache_thumb $id from $f");
186
+ return $cache[$id];
 
 
187
  }
188
  else {
189
+ unset( $cache[$id] );
190
  wppa( 'current_photo', false );
191
+ wppa_log( 'war', 'Photo '.$id.' does not exist (wppa_cache_thumb)' );
192
  return false;
193
  }
194
  }
wppa-links.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * Frontend links
6
 
7
- * Version 8.1.09.003
8
  */
9
 
10
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
@@ -822,6 +822,7 @@ global $wpdb;
822
  function wppa_moderate_links( $type, $id, $comid = '' ) {
823
 
824
  $thumb = wppa_cache_thumb( $id );
 
825
 
826
  if ( wppa_user_is( 'administrator' ) || current_user_can('wppa_moderate') || ( current_user_can('wppa_comments') && $type == 'comment' ) ) {
827
  switch ( $type ) {
4
  *
5
  * Frontend links
6
 
7
+ * Version 8.2.04.004
8
  */
9
 
10
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
822
  function wppa_moderate_links( $type, $id, $comid = '' ) {
823
 
824
  $thumb = wppa_cache_thumb( $id );
825
+ $result = '';
826
 
827
  if ( wppa_user_is( 'administrator' ) || current_user_can('wppa_moderate') || ( current_user_can('wppa_comments') && $type == 'comment' ) ) {
828
  switch ( $type ) {
wppa-mailing.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * Contains mailing functions
6
  *
7
- * Version 8.2.02.002
8
  *
9
  */
10
 
@@ -404,8 +404,10 @@ global $wpdb;
404
  wppa_log( 'Eml', 'photo owner ' . $owuser->ID . ', ' . $owuser->user_login );
405
 
406
  // Comment owner
407
- $cowner = $author ? array( $author->ID ) : array();
408
- wppa_log( 'Eml', 'comment owner ' . $author->ID . ', ' . $author->user_login );
 
 
409
 
410
  // Superusers
411
  $susers = wppa_get_superuser_ids_a();
4
  *
5
  * Contains mailing functions
6
  *
7
+ * Version 8.2.04.004
8
  *
9
  */
10
 
404
  wppa_log( 'Eml', 'photo owner ' . $owuser->ID . ', ' . $owuser->user_login );
405
 
406
  // Comment owner
407
+ if ( $author ) {
408
+ $cowner == $author ? array( $author->ID ) : array();
409
+ wppa_log( 'Eml', 'comment owner ' . $author->ID . ', ' . $author->user_login );
410
+ }
411
 
412
  // Superusers
413
  $susers = wppa_get_superuser_ids_a();
wppa-maintenance.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains (not yet, but in the future maybe) all the maintenance routines
6
- * Version 8.2.04.001
7
  *
8
  */
9
 
@@ -305,11 +305,8 @@ global $wppa_endtime;
305
  break;
306
 
307
  case 'wppa_remove_empty_albums':
308
- $p = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE album = %s", $id ) );
309
- $a = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE a_parent = %s", $id ) );
310
- if ( ! $a && ! $p ) {
311
  $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_albums WHERE id = %s", $id ) );
312
- // wppa_delete_album_source( $id );
313
  wppa_invalidate_treecounts( $id );
314
  wppa_index_remove( 'album', $id );
315
  wppa_clear_catlist();
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains (not yet, but in the future maybe) all the maintenance routines
6
+ * Version 8.2.04.004
7
  *
8
  */
9
 
305
  break;
306
 
307
  case 'wppa_remove_empty_albums':
308
+ if ( wppa_is_album_empty( $id ) ) {
 
 
309
  $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_albums WHERE id = %s", $id ) );
 
310
  wppa_invalidate_treecounts( $id );
311
  wppa_index_remove( 'album', $id );
312
  wppa_clear_catlist();
wppa-setting-functions.php CHANGED
@@ -3,11 +3,11 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * manage all options
6
- * Version 8.2.01.007
7
  *
8
  */
9
 
10
- function wppa_input( $xslug, $width, $minwidth = '', $text = '', $onchange = '', $placeholder = '' ) {
11
  global $wppa_opt;
12
 
13
  $slug = substr( $xslug, 5 );
3
  * Package: wp-photo-album-plus
4
  *
5
  * manage all options
6
+ * Version 8.2.04.004
7
  *
8
  */
9
 
10
+ function wppa_input( $xslug, $width = '300px', $minwidth = '', $text = '', $onchange = '', $placeholder = '' ) {
11
  global $wppa_opt;
12
 
13
  $slug = substr( $xslug, 5 );
wppa-settings-autosave.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * manage all options
6
- * Version 8.2.04.003
7
  *
8
  */
9
 
@@ -8084,6 +8084,13 @@ global $wppa_subtab_names;
8084
  $html = wppa_textarea($slug);
8085
  wppa_setting_new($slug, '16', $name, $desc, $html, $help);
8086
 
 
 
 
 
 
 
 
8087
  wppa_setting_box_footer_new();
8088
  }
8089
  // Optional menu items
3
  * Package: wp-photo-album-plus
4
  *
5
  * manage all options
6
+ * Version 8.2.04.004
7
  *
8
  */
9
 
8084
  $html = wppa_textarea($slug);
8085
  wppa_setting_new($slug, '16', $name, $desc, $html, $help);
8086
 
8087
+ $name = __('Extra backend stylesheet', 'wp-photo-album-plus');
8088
+ $desc = __('Enter the full url to the extra stylesheet to load at the backend', 'wp-photo-album-plus');
8089
+ $help = '';
8090
+ $slug = 'wppa_admin_extra_css';
8091
+ $html = wppa_input($slug, '500px', '', '', '', site_url() . '/wp-content/example-extra-style.css');
8092
+ wppa_setting_new($slug, '17', $name, $desc, $html, $help);
8093
+
8094
  wppa_setting_box_footer_new();
8095
  }
8096
  // Optional menu items
wppa-statistics.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * Functions for counts etc
6
  * Common use front and admin
7
- * Version 8.2.02.002
8
  *
9
  */
10
 
@@ -38,8 +38,9 @@ function wppa_get_statistics() {
38
  return $result;
39
  }
40
 
 
41
  // get number of photos in album
42
- function wppa_get_photo_count( $id = '0', $use_treecounts = false ) {
43
  global $wpdb;
44
 
45
  if ( $use_treecounts && $id ) {
@@ -79,6 +80,7 @@ global $wpdb;
79
  }
80
  return $count;
81
  }
 
82
 
83
  // get number of albums in album
84
  function wppa_get_album_count( $id, $use_treecounts = false ) {
@@ -425,7 +427,11 @@ global $wpdb;
425
  'scheduledselfphotos',
426
  'scheduledtreephotos',
427
  'selfphotoviews',
428
- 'treephotoviews'
 
 
 
 
429
  */
430
 
431
  // Do the dirty work
@@ -511,6 +517,39 @@ global $wpdb;
511
  $result['treephotoviews'] += $child_treecounts['treephotoviews'];
512
  }
513
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
514
  // Save result
515
  wppa_save_treecount_a( $alb, $result );
516
 
@@ -572,7 +611,7 @@ global $wpdb;
572
  // Do it
573
  if ( $alb && is_array( $treecounts ) ) {
574
 
575
- $keys = array( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10' );
576
  $result = array_combine( $keys, $treecounts );
577
  $result = serialize( $result );
578
 
@@ -598,6 +637,10 @@ global $wpdb;
598
  $scheduledtreephotos = '8';
599
  $selfphotoviews = '9';
600
  $treephotoviews = '10';
 
 
 
 
601
 
602
  // Sanitize arg
603
  if ( $alb ) {
@@ -619,7 +662,7 @@ global $wpdb;
619
  }
620
 
621
  // Fill in missing elements
622
- $defaults = array( 1,0,0,0,0,0,0,0,0,0,0 );
623
  $i = 0;
624
  $n = count( $defaults );
625
  while ( $i < $n ) {
@@ -640,7 +683,11 @@ global $wpdb;
640
  'scheduledselfphotos',
641
  'scheduledtreephotos',
642
  'selfphotoviews',
643
- 'treephotoviews'
 
 
 
 
644
  );
645
 
646
  $result = array_combine( $keys, $treecount_array );
@@ -658,3 +705,227 @@ global $wpdb;
658
  // Done
659
  return $result;
660
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  *
5
  * Functions for counts etc
6
  * Common use front and admin
7
+ * Version 8.2.04.004
8
  *
9
  */
10
 
38
  return $result;
39
  }
40
 
41
+ /*
42
  // get number of photos in album
43
+ function wppa_get _photo_count( $id = '0', $use_treecounts = false ) {
44
  global $wpdb;
45
 
46
  if ( $use_treecounts && $id ) {
80
  }
81
  return $count;
82
  }
83
+ */
84
 
85
  // get number of albums in album
86
  function wppa_get_album_count( $id, $use_treecounts = false ) {
427
  'scheduledselfphotos',
428
  'scheduledtreephotos',
429
  'selfphotoviews',
430
+ 'treephotoviews',
431
+ 'privatealbums',
432
+ 'hiddenalbums',
433
+ 'privatetreealbums',
434
+ 'hiddentreealbums'
435
  */
436
 
437
  // Do the dirty work
517
  $result['treephotoviews'] += $child_treecounts['treephotoviews'];
518
  }
519
 
520
+ // Private albums
521
+ $result['privatealbums'] = $wpdb->get_var( "SELECT COUNT(*)
522
+ FROM $wpdb->wppa_albums
523
+ WHERE a_parent = $alb
524
+ AND status = 'private'"
525
+ );
526
+
527
+ // Hidden albums
528
+ $result['hiddenalbums'] = $wpdb->get_var( "SELECT COUNT(*)
529
+ FROM $wpdb->wppa_albums
530
+ WHERE a_parent = $alb
531
+ AND status = 'hidden'"
532
+ );
533
+
534
+ // Private tree albums
535
+ $result['privatetreealbums'] = $result['privatealbums'];
536
+ foreach( $child_ids as $child ) {
537
+
538
+ // Recursively get childrens private albums and add it
539
+ $child_treecounts = wppa_verify_treecounts_a( $child );
540
+ $result['privatetreealbums'] += $child_treecounts['privatealbums'];
541
+ }
542
+
543
+ // Hidden tree albums
544
+ $result['hiddentreealbums'] = $result['hiddenalbums'];
545
+ foreach( $child_ids as $child ) {
546
+
547
+ // Recursively get childrens private albums and add it
548
+ $child_treecounts = wppa_verify_treecounts_a( $child );
549
+ $result['hiddentreealbums'] += $child_treecounts['hiddenalbums'];
550
+ }
551
+
552
+
553
  // Save result
554
  wppa_save_treecount_a( $alb, $result );
555
 
611
  // Do it
612
  if ( $alb && is_array( $treecounts ) ) {
613
 
614
+ $keys = array( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14' );
615
  $result = array_combine( $keys, $treecounts );
616
  $result = serialize( $result );
617
 
637
  $scheduledtreephotos = '8';
638
  $selfphotoviews = '9';
639
  $treephotoviews = '10';
640
+ $privatealbums = '11';
641
+ $hiddenalbums = '12';
642
+ $privatetreealbums = '13';
643
+ $hiddentreealbums = '14';
644
 
645
  // Sanitize arg
646
  if ( $alb ) {
662
  }
663
 
664
  // Fill in missing elements
665
+ $defaults = array( 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0 );
666
  $i = 0;
667
  $n = count( $defaults );
668
  while ( $i < $n ) {
683
  'scheduledselfphotos',
684
  'scheduledtreephotos',
685
  'selfphotoviews',
686
+ 'treephotoviews',
687
+ 'privatealbums',
688
+ 'hiddenalbums',
689
+ 'privatetreealbums',
690
+ 'hiddentreealbums'
691
  );
692
 
693
  $result = array_combine( $keys, $treecount_array );
705
  // Done
706
  return $result;
707
  }
708
+
709
+ // An album is physically empty when it has no subalbums, no photos and no recoverable deleted photos
710
+ function wppa_is_album_empty( $id ) {
711
+ global $wpdb;
712
+
713
+ $has_albums = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE a_parent = %s", $id ) );
714
+ if ( $has_albums ) {
715
+ return false;
716
+ }
717
+
718
+ $has_photos = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE album = %s", $id ) );
719
+ if ( $has_photos ) {
720
+ return false;
721
+ }
722
+
723
+ $has_deleted_photos = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE album = %s", - ( $id + '9' ) ) );
724
+ if ( $has_deleted_photos ) {
725
+ return false;
726
+ }
727
+
728
+ return true;
729
+ }
730
+
731
+ // See if an album is visible to the current user. This takes 'skip empty albums' into account.
732
+ function wppa_is_album_visible( $id ) {
733
+ global $wpdb;
734
+
735
+ // Everything is visible for admin and superusers
736
+ if ( wppa_user_is( 'administrator' ) ) {
737
+ return true;
738
+ }
739
+
740
+ // Album is alwaus visible for the owner
741
+ $user = wppa_get_user();
742
+ $album = wppa_cache_album( $id );
743
+ if ( $user == $album['owner'] ) {
744
+ return true;
745
+ }
746
+
747
+ // Look at album status
748
+ switch( $album['status'] ) {
749
+ case 'hidden':
750
+ return false;
751
+ break;
752
+ case 'private':
753
+ if ( ! is_user_logged_in() ) {
754
+ return false;
755
+ }
756
+ break;
757
+
758
+ default:
759
+ // Depends on skip switch and content
760
+ }
761
+
762
+ // Look at skip switch
763
+ if ( ! wppa_switch( 'skip_empty_albums' ) ) {
764
+ return true;
765
+ }
766
+
767
+ // Look at content. If no visible albums or photos, this album is not visible
768
+ $tc = wppa_get_treecounts_a( $id );
769
+
770
+ // Look at photos
771
+ $photos = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_photos WHERE album = %s", $id ) );
772
+ foreach( $photos as $p ) {
773
+
774
+ if ( wppa_is_photo_visible( $p ) ) {
775
+ return true;
776
+ }
777
+ }
778
+
779
+ // Look at subalbums
780
+ $albs = $wpdb->get_results( $wpdb->prepare( "SELECT id, status FROM $wpdb->wppa_albums WHERE a_parent = %s", $id ), ARRAY_A );
781
+ foreach( $albs as $alb ) {
782
+
783
+ if ( wppa_is_album_visible( $alb['id'] ) ) {
784
+ return true;
785
+ }
786
+ }
787
+
788
+ return false; // This album is not visible for the current user
789
+ }
790
+
791
+ // Get number of visible 1st generation albums
792
+ function wppa_get_visible_album_count( $id ) {
793
+ // global $wpdb;
794
+
795
+ $result = '0';
796
+
797
+ $albs = wppa_get_sub_album_ids( $id );
798
+ if ( $albs ) {
799
+ foreach( $albs as $alb ) {
800
+ if ( wppa_is_album_visible( $alb ) ) {
801
+ $result++;
802
+ }
803
+ }
804
+ }
805
+ return $result;
806
+ }
807
+
808
+ // Get the total tree number of visible albums, assuming this album is visible
809
+ function wppa_get_visible_subtree_album_count( $id, $first = true ) {
810
+ static $cache;
811
+
812
+ if ( ! is_array( $cache ) ) $cache = array();
813
+ if ( isset( $cache[$id] ) ) {
814
+ return $cache[$id];
815
+ // wppa_log( 'obs', 'Cache hit wppa_get_visible_subtree_album_count( '.$id.' )');
816
+ }
817
+ $result = '0';
818
+
819
+ $albs = wppa_get_sub_album_ids( $id );
820
+ if ( $albs ) {
821
+ foreach( $albs as $alb ) {
822
+ if ( wppa_is_album_visible( $alb ) ) {
823
+ $result += wppa_get_visible_subtree_album_count( $alb, false );
824
+ }
825
+ }
826
+ }
827
+
828
+ if ( ! $first ) $result += '1'; // Myself
829
+ $cache[$id] = $result;
830
+ return $result;
831
+ }
832
+
833
+ // Find out if a given photo is visible for the current user
834
+ function wppa_is_photo_visible( $id ) {
835
+
836
+ $p = wppa_cache_photo( $id );
837
+ if ( $p ) {
838
+ switch( $p['status'] ) {
839
+ case 'publish': // A published photo found, visible to every one
840
+ case 'featured':
841
+ case 'gold':
842
+ case 'silver':
843
+ case 'bronze':
844
+ return true;
845
+ break;
846
+ case 'private':
847
+ if ( is_user_logged_in() ) { // A logged in user may see private photos
848
+ return true;
849
+ }
850
+ break;
851
+ case 'pending': // Pending and scheduled may be seen by owner
852
+ case 'scheduled':
853
+ $user = wppa_get_user();
854
+ if ( $user == $p['owner'] ) {
855
+ return true;
856
+ }
857
+ break;
858
+ default:
859
+ break;
860
+ }
861
+ }
862
+
863
+ return false; // This photo is not visible for the current user
864
+ }
865
+
866
+ // Get visible photocount
867
+ function wppa_get_visible_photo_count( $id ) {
868
+ global $wpdb;
869
+ static $cache;
870
+
871
+ if ( ! is_array( $cache ) ) $cache = array();
872
+ if ( isset( $cache[$id] ) ) {
873
+ // wppa_log( 'obs', 'Cache hit wppa_get_visible_photo_count( '.$id.' )');
874
+ return $cache[$id];
875
+ }
876
+
877
+ if ( wppa_user_is( 'administrator' ) ) {
878
+ $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE album = %s", $id ) );
879
+ }
880
+ elseif ( is_user_logged_in() ) {
881
+ $user = wppa_get_user();
882
+ $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE album = %s AND ( status NOT IN ('pending','scheduled') OR owner = %s )", $id, $user ) );
883
+ }
884
+ else {
885
+ $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE album = %s AND status NOT IN ('pending','private','scheduled' )", $id ) );
886
+ }
887
+ $cache[$id] = $result;
888
+ return $result;
889
+ }
890
+
891
+ function wppa_get_visible_subtree_photo_count( $id ) {
892
+ static $cache;
893
+
894
+ if ( ! is_array( $cache ) ) $cache = array();
895
+ if ( isset( $cache[$id] ) ) {
896
+ // wppa_log( 'obs', 'Cache hit wppa_get_visible_subtree_photo_count( '.$id.' )');
897
+ return $cache[$id];
898
+ }
899
+ $result = '0';
900
+
901
+ $albs = wppa_get_sub_album_ids( $id );
902
+ if ( $albs ) {
903
+ foreach( $albs as $alb ) {
904
+ if ( wppa_is_album_visible( $alb ) ) {
905
+ $result += wppa_get_visible_subtree_photo_count( $alb );
906
+ }
907
+ }
908
+ }
909
+
910
+ $result += wppa_get_visible_photo_count( $id );
911
+ $cache[$id] = $result;
912
+ return $result;
913
+ }
914
+
915
+ // Get array of subalbum ids
916
+ function wppa_get_sub_album_ids( $id ) {
917
+ global $wpdb;
918
+ static $cache;
919
+
920
+ if ( ! is_array( $cache ) ) $cache = array();
921
+ if ( isset( $cache[$id] ) ) {
922
+ // wppa_log( 'obs', 'Cache hit wppa_get_sub_album_ids( '.$id.' )');
923
+ return $cache[$id];
924
+ }
925
+
926
+ $result = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_albums WHERE a_parent = %s", $id ) );
927
+
928
+ $cache[$id] = $result;
929
+
930
+ return $result;
931
+ }
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.2.04.003
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.2.04.003'; // 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.2.04.004
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.2.04.004'; // WPPA software version
28
  global $wppa_revno;
29
  $wppa_revno = str_replace( '.', '', $wppa_api_version ); // WPPA db version
30