Version Description
- New Feature: It is now possible to filter the HTML produced to represent each individual icon, making it possible to add extra attributes and other modifications on the fly as document icons are generated. This will probably only be of use to developers and people who don't mind getting their hands dirty. (See bottom **Installation* tab for more details.)*
- Enhancement: There have been a lot of optimizations to the underlying plugin code to make it run more efficiently and be easier to read, if you are so inclined.
- Enhancement: Changed how images, when included within the gallery, are generated so that the format of the icon returned now matches the rest of the icons.
Download this release
Release Info
Developer | dan.rossiter |
Plugin | Document Gallery |
Version | 1.3 |
Comparing to | |
See all releases |
Code changes from version 1.2.1 to 1.3
- document-gallery.php +94 -94
- readme.txt +172 -82
- screenshot-1.png +0 -0
document-gallery.php
CHANGED
@@ -2,13 +2,18 @@
|
|
2 |
/*
|
3 |
Plugin Name: Document Gallery
|
4 |
Description: Display non-images (and images) in gallery format on a page or post with the [dg] shortcode.
|
5 |
-
Version: 1.
|
6 |
Author: Dan Rossiter
|
7 |
Author URI: http://danrossiter.org/
|
8 |
License: GPL2
|
9 |
*/
|
10 |
|
11 |
define( 'DG_URL', plugin_dir_url( __FILE__ ) );
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
// CREATE GALLERY STRING //
|
14 |
function dg_get_attachment_icons($atts) {
|
@@ -23,19 +28,20 @@ function dg_get_attachment_icons($atts) {
|
|
23 |
|
24 |
// INIT
|
25 |
$attachments = array();
|
|
|
26 |
$errs = array();
|
27 |
|
28 |
|
29 |
// ATTRIBUTE VALIDATION
|
30 |
-
|
31 |
|
32 |
$order = strtoupper( $order );
|
33 |
if($order != 'ASC' && $order != 'DEC')
|
34 |
$errs[] = "The order attribute must be either ASC or DEC. You entered $order.";
|
35 |
|
36 |
-
|
37 |
|
38 |
-
|
39 |
|
40 |
if( strtolower($ids) == "false" ){ $ids = FALSE; }
|
41 |
|
@@ -45,11 +51,10 @@ function dg_get_attachment_icons($atts) {
|
|
45 |
|
46 |
|
47 |
// LET'S GET SOME DOCUMENTS!
|
48 |
-
if( $ids && ( $ids = explode( ',', $ids ) ) )
|
49 |
$attachments = dg_get_attachments_by_ids( $ids );
|
50 |
-
}
|
51 |
|
52 |
-
// if 'ids' was used, skip
|
53 |
if( !$attachments ){
|
54 |
$args = array(
|
55 |
'numberposts' => -1,
|
@@ -63,12 +68,13 @@ function dg_get_attachment_icons($atts) {
|
|
63 |
$attachments = get_posts($args);
|
64 |
}
|
65 |
|
66 |
-
if ( $attachments ) {
|
67 |
-
$attachment_str =
|
68 |
-
'http://wordpress.org/extend/plugins/document-gallery -->'.PHP_EOL
|
69 |
|
70 |
-
|
71 |
-
foreach( $attachments as $attachment ) {
|
|
|
72 |
$url = $attachment->guid;
|
73 |
$filename = basename( $url );
|
74 |
|
@@ -77,46 +83,42 @@ function dg_get_attachment_icons($atts) {
|
|
77 |
|
78 |
$title = get_the_title( $attachment->ID );
|
79 |
$icon = dg_get_attachment_image( $attachment->ID, $title, $filename );
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
}
|
88 |
-
$attachment_str[] = ' <div class="document-icon">'.PHP_EOL;
|
89 |
}
|
90 |
|
91 |
-
|
|
|
|
|
92 |
|
93 |
-
if($descriptions) { //
|
94 |
-
$attachment_str
|
95 |
-
" <p>$attachment->post_content</p>".
|
96 |
PHP_EOL.'</div>'.PHP_EOL;
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
$attachment_str[] = '</div>'.PHP_EOL;
|
101 |
-
}
|
102 |
}
|
103 |
-
} //
|
104 |
|
105 |
// for galleries w/ number of docs != mult of 4
|
106 |
-
if( $count % 4 != 0 && !$descriptions )
|
107 |
-
$attachment_str
|
108 |
-
}
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
return PHP_EOL.'<!-- Document Gallery: No attachments to display. -->'.PHP_EOL;
|
115 |
}
|
116 |
add_shortcode('dg', 'dg_get_attachment_icons');
|
117 |
-
// Depreciated as of v1.0. left for backward compatibility
|
118 |
-
add_shortcode('document gallery', 'dg_get_attachment_icons');
|
119 |
|
|
|
|
|
120 |
|
121 |
|
122 |
// HELPERS //
|
@@ -131,7 +133,7 @@ function dg_get_attachments_by_ids( $ids ){
|
|
131 |
return $attachments;
|
132 |
}
|
133 |
|
134 |
-
// pass in $title & $
|
135 |
function dg_get_attachment_image( $id, $title, $filename ) {
|
136 |
$filetype = wp_check_filetype( $filename );
|
137 |
|
@@ -139,7 +141,7 @@ function dg_get_attachment_image( $id, $title, $filename ) {
|
|
139 |
switch( $filetype['ext'] ) {
|
140 |
// Most Common First
|
141 |
case 'pdf':
|
142 |
-
$icon = 'pdf.png';
|
143 |
break;
|
144 |
// MS Office
|
145 |
case 'doc':
|
@@ -147,7 +149,7 @@ function dg_get_attachment_image( $id, $title, $filename ) {
|
|
147 |
case 'docm':
|
148 |
case 'dotx':
|
149 |
case 'dotm':
|
150 |
-
$icon = 'msdoc.png';
|
151 |
break;
|
152 |
case 'ppt':
|
153 |
case 'pot':
|
@@ -161,7 +163,7 @@ function dg_get_attachment_image( $id, $title, $filename ) {
|
|
161 |
case 'ppam':
|
162 |
case 'sldx':
|
163 |
case 'sldm':
|
164 |
-
$icon = 'msppt.png';
|
165 |
break;
|
166 |
case 'xla':
|
167 |
case 'xls':
|
@@ -173,145 +175,143 @@ function dg_get_attachment_image( $id, $title, $filename ) {
|
|
173 |
case 'xltx':
|
174 |
case 'xltm':
|
175 |
case 'xlam':
|
176 |
-
$icon = 'msxls.png';
|
177 |
break;
|
178 |
case 'mdb':
|
179 |
-
$icon = 'msaccess.png';
|
180 |
break;
|
181 |
// Video formats
|
182 |
case 'avi':
|
183 |
-
$icon = 'avi.png';
|
184 |
break;
|
185 |
case 'divx':
|
186 |
-
$icon = 'divx.png';
|
187 |
break;
|
188 |
case 'flv':
|
189 |
-
$icon = 'flv.png';
|
190 |
break;
|
191 |
case 'qt':
|
192 |
case 'mov':
|
193 |
-
$icon = 'mov.png';
|
194 |
break;
|
195 |
case 'asf':
|
196 |
case 'asx':
|
197 |
case 'wax':
|
198 |
case 'wmv':
|
199 |
case 'wmx':
|
200 |
-
$icon = 'wmv.png';
|
201 |
break;
|
202 |
case 'mkv':
|
203 |
-
$icon = 'mkv.png';
|
204 |
break;
|
205 |
// Audio formats
|
206 |
case 'mp3':
|
207 |
-
$icon = 'mp3.png';
|
208 |
break;
|
209 |
case 'wav':
|
210 |
-
$icon = 'wav.png';
|
211 |
break;
|
212 |
case 'ogg':
|
213 |
case 'oga':
|
214 |
-
$icon = 'ogg.png';
|
215 |
break;
|
216 |
case 'midi':
|
217 |
case 'mid':
|
218 |
-
$icon = 'midi.png';
|
219 |
break;
|
220 |
case 'wma':
|
221 |
-
$icon = 'wma.png';
|
222 |
break;
|
223 |
// Text formats
|
224 |
case 'rtx':
|
225 |
-
$icon = 'rtx.png';
|
226 |
break;
|
227 |
case 'ics':
|
228 |
-
$icon = 'ics.png';
|
229 |
break;
|
230 |
case 'csv':
|
231 |
-
$icon = 'csv.png';
|
232 |
break;
|
233 |
// Msc application formats
|
234 |
case 'html':
|
235 |
case 'htm': // death to all who use this!
|
236 |
-
$icon = 'html.png';
|
237 |
break;
|
238 |
case 'css':
|
239 |
-
$icon = 'css.png';
|
240 |
break;
|
241 |
case 'js':
|
242 |
-
$icon = 'javascript.png';
|
243 |
break;
|
244 |
case 'class':
|
245 |
-
$icon = 'java.png';
|
246 |
break;
|
247 |
case 'zip':
|
248 |
-
$icon = 'zip.png';
|
249 |
break;
|
250 |
case 'tar':
|
251 |
case 'gzip':
|
252 |
case 'gz':
|
253 |
case 'bz2': // not yet WP-supported
|
254 |
case 'tgz': // not yet WP-supported
|
255 |
-
$icon = 'compressed.png';
|
256 |
break;
|
257 |
case 'rar': // RAWR!!!
|
258 |
-
$icon = 'rar.png';
|
259 |
break;
|
260 |
case '7z':
|
261 |
-
$icon = '7zip.png';
|
262 |
break;
|
263 |
case 'exec':
|
264 |
-
$icon = 'exec.png';
|
265 |
break;
|
266 |
case 'rtf':
|
267 |
-
$icon = 'rtf.png';
|
268 |
break;
|
269 |
case 'swf':
|
270 |
-
$icon = 'shockwave.png';
|
271 |
break;
|
272 |
// OpenOffice formats
|
273 |
case 'odt':
|
274 |
-
$icon = 'opendocument-text.png';
|
275 |
break;
|
276 |
case 'odp':
|
277 |
-
$icon = 'opendocument-presentation.png';
|
278 |
break;
|
279 |
case 'ods':
|
280 |
-
$icon = 'opendocument-spreadsheet.png';
|
281 |
break;
|
282 |
case 'odg':
|
283 |
-
$icon = 'opendocument-graphics.png';
|
284 |
break;
|
285 |
case 'odb':
|
286 |
-
$icon = 'opendocument-database.png';
|
287 |
break;
|
288 |
case 'odf':
|
289 |
-
$icon = 'opendocument-formula.png';
|
290 |
break;
|
291 |
-
// fallback to default icons if not recognized
|
292 |
default:
|
293 |
// handle images
|
294 |
-
if(
|
295 |
-
( $icon =
|
296 |
-
|
|
|
|
|
297 |
|
298 |
-
// fallback to
|
299 |
-
if( $icon =
|
300 |
-
|
|
|
|
|
301 |
|
302 |
-
|
|
|
303 |
}
|
304 |
|
305 |
-
return
|
306 |
}
|
307 |
|
308 |
-
//
|
309 |
-
// doubling the amount of processing for each icon. The native WP function would create the icon,
|
310 |
-
// then 99% of the time this function would replace it. Better to just call the native WP function
|
311 |
-
// at the end when needed. Filter would look like this:
|
312 |
-
// add_filter( 'attachment_icon', 'dg_get_attachment_icon', 10, 2 );v
|
313 |
-
|
314 |
-
// ADD SOME STYLING //
|
315 |
function dg_add_header_css() {
|
316 |
wp_enqueue_style( 'document-gallery-css', plugins_url('style.css', __FILE__) );
|
317 |
}
|
2 |
/*
|
3 |
Plugin Name: Document Gallery
|
4 |
Description: Display non-images (and images) in gallery format on a page or post with the [dg] shortcode.
|
5 |
+
Version: 1.3
|
6 |
Author: Dan Rossiter
|
7 |
Author URI: http://danrossiter.org/
|
8 |
License: GPL2
|
9 |
*/
|
10 |
|
11 |
define( 'DG_URL', plugin_dir_url( __FILE__ ) );
|
12 |
+
define( 'DG_IMG_STRING', '<img src="%s" title="%s" alt="%s" />' );
|
13 |
+
define( 'DG_DOC_ICON',
|
14 |
+
' <div class="document-icon">'.PHP_EOL.
|
15 |
+
' <a href="%s">%s<br>%s</a>'.PHP_EOL.
|
16 |
+
' </div>'.PHP_EOL );
|
17 |
|
18 |
// CREATE GALLERY STRING //
|
19 |
function dg_get_attachment_icons($atts) {
|
28 |
|
29 |
// INIT
|
30 |
$attachments = array();
|
31 |
+
$count = 0;
|
32 |
$errs = array();
|
33 |
|
34 |
|
35 |
// ATTRIBUTE VALIDATION
|
36 |
+
$descriptions = strtolower($descriptions) == "false" ? FALSE : TRUE;
|
37 |
|
38 |
$order = strtoupper( $order );
|
39 |
if($order != 'ASC' && $order != 'DEC')
|
40 |
$errs[] = "The order attribute must be either ASC or DEC. You entered $order.";
|
41 |
|
42 |
+
$attachment_pg = strtolower($attachment_pg) == "false" ? FALSE : TRUE;
|
43 |
|
44 |
+
$images = strtolower($images) == "false" ? FALSE : TRUE;
|
45 |
|
46 |
if( strtolower($ids) == "false" ){ $ids = FALSE; }
|
47 |
|
51 |
|
52 |
|
53 |
// LET'S GET SOME DOCUMENTS!
|
54 |
+
if( $ids && ( $ids = explode( ',', $ids ) ) )
|
55 |
$attachments = dg_get_attachments_by_ids( $ids );
|
|
|
56 |
|
57 |
+
// if 'ids' was used, skip this
|
58 |
if( !$attachments ){
|
59 |
$args = array(
|
60 |
'numberposts' => -1,
|
68 |
$attachments = get_posts($args);
|
69 |
}
|
70 |
|
71 |
+
if ( $attachments ) {
|
72 |
+
$attachment_str = PHP_EOL.'<!-- Generated using Document Gallery. Get yours here: '.
|
73 |
+
'http://wordpress.org/extend/plugins/document-gallery -->'.PHP_EOL;
|
74 |
|
75 |
+
// DOCUMENT LOOP
|
76 |
+
foreach( $attachments as $attachment ) {
|
77 |
+
// INIT ATTACHMENT-SPECIFIC VARS
|
78 |
$url = $attachment->guid;
|
79 |
$filename = basename( $url );
|
80 |
|
83 |
|
84 |
$title = get_the_title( $attachment->ID );
|
85 |
$icon = dg_get_attachment_image( $attachment->ID, $title, $filename );
|
86 |
+
|
87 |
+
// GENERATE OUTPUT
|
88 |
+
if($descriptions) { // start description wrapper
|
89 |
+
$attachment_str .= '<div class="document-icon-wrapper descriptions">'.PHP_EOL;
|
90 |
+
|
91 |
+
} elseif( $count % 4 == 0 ) { // no description
|
92 |
+
$attachment_str .= '<div id="document-icon-wrapper">'.PHP_EOL;
|
|
|
|
|
93 |
}
|
94 |
|
95 |
+
// insert filtered document-icon
|
96 |
+
$attachment_str .= apply_filters( 'dg_doc_icon',
|
97 |
+
sprintf( DG_DOC_ICON, $url, $icon, $title ), $attachment->ID );
|
98 |
|
99 |
+
if($descriptions) { // add description
|
100 |
+
$attachment_str .= " <p>$attachment->post_content</p>".
|
|
|
101 |
PHP_EOL.'</div>'.PHP_EOL;
|
102 |
+
|
103 |
+
} elseif( ++$count % 4 == 0 ) { // end wrapper
|
104 |
+
$attachment_str .= '</div>'.PHP_EOL;
|
|
|
|
|
105 |
}
|
106 |
+
} // END DOCUMENT LOOP
|
107 |
|
108 |
// for galleries w/ number of docs != mult of 4
|
109 |
+
if( $count % 4 != 0 && !$descriptions ) // end wrapper
|
110 |
+
$attachment_str .= '</div>'.PHP_EOL;
|
|
|
111 |
|
112 |
+
return $attachment_str;
|
113 |
+
} // END IF
|
114 |
+
|
115 |
+
// NO DOCUMENTS
|
116 |
+
return PHP_EOL.'<!-- Document Gallery: No attachments to display. How boring... -->'.PHP_EOL;
|
117 |
}
|
118 |
add_shortcode('dg', 'dg_get_attachment_icons');
|
|
|
|
|
119 |
|
120 |
+
// 'document gallery' shortcode depreciated as of v1.0. left for backward compatibility
|
121 |
+
add_shortcode('document gallery', 'dg_get_attachment_icons');
|
122 |
|
123 |
|
124 |
// HELPERS //
|
133 |
return $attachments;
|
134 |
}
|
135 |
|
136 |
+
// pass in $title & $filename to avoid mult function calls
|
137 |
function dg_get_attachment_image( $id, $title, $filename ) {
|
138 |
$filetype = wp_check_filetype( $filename );
|
139 |
|
141 |
switch( $filetype['ext'] ) {
|
142 |
// Most Common First
|
143 |
case 'pdf':
|
144 |
+
$icon = DG_URL.'icons/pdf.png';
|
145 |
break;
|
146 |
// MS Office
|
147 |
case 'doc':
|
149 |
case 'docm':
|
150 |
case 'dotx':
|
151 |
case 'dotm':
|
152 |
+
$icon = DG_URL.'icons/msdoc.png';
|
153 |
break;
|
154 |
case 'ppt':
|
155 |
case 'pot':
|
163 |
case 'ppam':
|
164 |
case 'sldx':
|
165 |
case 'sldm':
|
166 |
+
$icon = DG_URL.'icons/msppt.png';
|
167 |
break;
|
168 |
case 'xla':
|
169 |
case 'xls':
|
175 |
case 'xltx':
|
176 |
case 'xltm':
|
177 |
case 'xlam':
|
178 |
+
$icon = DG_URL.'icons/msxls.png';
|
179 |
break;
|
180 |
case 'mdb':
|
181 |
+
$icon = DG_URL.'icons/msaccess.png';
|
182 |
break;
|
183 |
// Video formats
|
184 |
case 'avi':
|
185 |
+
$icon = DG_URL.'icons/avi.png';
|
186 |
break;
|
187 |
case 'divx':
|
188 |
+
$icon = DG_URL.'icons/divx.png';
|
189 |
break;
|
190 |
case 'flv':
|
191 |
+
$icon = DG_URL.'icons/flv.png';
|
192 |
break;
|
193 |
case 'qt':
|
194 |
case 'mov':
|
195 |
+
$icon = DG_URL.'icons/mov.png';
|
196 |
break;
|
197 |
case 'asf':
|
198 |
case 'asx':
|
199 |
case 'wax':
|
200 |
case 'wmv':
|
201 |
case 'wmx':
|
202 |
+
$icon = DG_URL.'icons/wmv.png';
|
203 |
break;
|
204 |
case 'mkv':
|
205 |
+
$icon = DG_URL.'icons/mkv.png';
|
206 |
break;
|
207 |
// Audio formats
|
208 |
case 'mp3':
|
209 |
+
$icon = DG_URL.'icons/mp3.png';
|
210 |
break;
|
211 |
case 'wav':
|
212 |
+
$icon = DG_URL.'icons/wav.png';
|
213 |
break;
|
214 |
case 'ogg':
|
215 |
case 'oga':
|
216 |
+
$icon = DG_URL.'icons/ogg.png';
|
217 |
break;
|
218 |
case 'midi':
|
219 |
case 'mid':
|
220 |
+
$icon = DG_URL.'icons/midi.png';
|
221 |
break;
|
222 |
case 'wma':
|
223 |
+
$icon = DG_URL.'icons/wma.png';
|
224 |
break;
|
225 |
// Text formats
|
226 |
case 'rtx':
|
227 |
+
$icon = DG_URL.'icons/rtx.png';
|
228 |
break;
|
229 |
case 'ics':
|
230 |
+
$icon = DG_URL.'icons/ics.png';
|
231 |
break;
|
232 |
case 'csv':
|
233 |
+
$icon = DG_URL.'icons/csv.png';
|
234 |
break;
|
235 |
// Msc application formats
|
236 |
case 'html':
|
237 |
case 'htm': // death to all who use this!
|
238 |
+
$icon = DG_URL.'icons/html.png';
|
239 |
break;
|
240 |
case 'css':
|
241 |
+
$icon = DG_URL.'icons/css.png';
|
242 |
break;
|
243 |
case 'js':
|
244 |
+
$icon = DG_URL.'icons/javascript.png';
|
245 |
break;
|
246 |
case 'class':
|
247 |
+
$icon = DG_URL.'icons/java.png';
|
248 |
break;
|
249 |
case 'zip':
|
250 |
+
$icon = DG_URL.'icons/zip.png';
|
251 |
break;
|
252 |
case 'tar':
|
253 |
case 'gzip':
|
254 |
case 'gz':
|
255 |
case 'bz2': // not yet WP-supported
|
256 |
case 'tgz': // not yet WP-supported
|
257 |
+
$icon = DG_URL.'icons/compressed.png';
|
258 |
break;
|
259 |
case 'rar': // RAWR!!!
|
260 |
+
$icon = DG_URL.'icons/rar.png';
|
261 |
break;
|
262 |
case '7z':
|
263 |
+
$icon = DG_URL.'icons/7zip.png';
|
264 |
break;
|
265 |
case 'exec':
|
266 |
+
$icon = DG_URL.'icons/exec.png';
|
267 |
break;
|
268 |
case 'rtf':
|
269 |
+
$icon = DG_URL.'icons/rtf.png';
|
270 |
break;
|
271 |
case 'swf':
|
272 |
+
$icon = DG_URL.'icons/shockwave.png';
|
273 |
break;
|
274 |
// OpenOffice formats
|
275 |
case 'odt':
|
276 |
+
$icon = DG_URL.'icons/opendocument-text.png';
|
277 |
break;
|
278 |
case 'odp':
|
279 |
+
$icon = DG_URL.'icons/opendocument-presentation.png';
|
280 |
break;
|
281 |
case 'ods':
|
282 |
+
$icon = DG_URL.'icons/opendocument-spreadsheet.png';
|
283 |
break;
|
284 |
case 'odg':
|
285 |
+
$icon = DG_URL.'icons/opendocument-graphics.png';
|
286 |
break;
|
287 |
case 'odb':
|
288 |
+
$icon = DG_URL.'icons/opendocument-database.png';
|
289 |
break;
|
290 |
case 'odf':
|
291 |
+
$icon = DG_URL.'icons/opendocument-formula.png';
|
292 |
break;
|
|
|
293 |
default:
|
294 |
// handle images
|
295 |
+
if( strpos( $filetype['type'], 'image' ) === 0 &&
|
296 |
+
( $icon = wp_get_attachment_image_src( $id, 'thumbnail', false ) ) ){
|
297 |
+
$icon = $icon[0];
|
298 |
+
break;
|
299 |
+
}
|
300 |
|
301 |
+
// fallback to default icons if not recognized
|
302 |
+
if( $icon = wp_get_attachment_image_src( $id, null, true ) ){
|
303 |
+
$icon = $icon[0];
|
304 |
+
break;
|
305 |
+
}
|
306 |
|
307 |
+
// everything failed. This is bad...
|
308 |
+
return "<!-- Failed to retrive icon for attachment #$id -->";
|
309 |
}
|
310 |
|
311 |
+
return sprintf( DG_IMG_STRING, $icon, $title, $title );
|
312 |
}
|
313 |
|
314 |
+
// ADD SOME STYLING
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
function dg_add_header_css() {
|
316 |
wp_enqueue_style( 'document-gallery-css', plugins_url('style.css', __FILE__) );
|
317 |
}
|
readme.txt
CHANGED
@@ -1,59 +1,70 @@
|
|
1 |
=== Document Gallery ===
|
2 |
Contributors: dan.rossiter
|
3 |
-
Tags: attachments, icons, documents, gallery, ms office, doc, ppt, xls, docx, pptx, xlsx, pdf,
|
4 |
Requires at least: 2.6
|
5 |
-
Tested up to: 3.5
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
-
This plugin allows the user to easily create a "gallery" of all non-image
|
11 |
-
making them easy to share.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
This plugin allows the user to effortlessly include a gallery, much like a
|
16 |
-
of all your non-image attachments anywhere within your post.
|
17 |
|
18 |
-
The plugin will, by default, inherit the styling within your active theme, but
|
19 |
-
little CSS knowledge it is easily modified to meet your specific needs.
|
20 |
|
21 |
Read more in the **Installation** tab!
|
22 |
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
== Installation ==
|
27 |
|
28 |
1. Upload `document-gallery` to the `/wp-content/plugins/` directory
|
29 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
30 |
-
1. Place `[dg]` in any posts or pages you want a document gallery included. See
|
|
|
31 |
|
32 |
= Document Gallery Options =
|
33 |
|
34 |
-
In order to include all compatible docuements from a given page or post, you
|
35 |
-
the following shortcode in the post:
|
36 |
|
37 |
-
`[dg descriptions=[true/false] orderby=[menu_order, title, date, author, rand]
|
38 |
-
|
|
|
39 |
|
40 |
**Default Values**
|
41 |
|
42 |
-
By default, document gallery will use `descriptions=false`,
|
43 |
-
, `attachment_pg=false`, `images=false`, and
|
|
|
44 |
|
45 |
**Descriptions Option**
|
46 |
|
47 |
-
If `true`, each document will take its own line with the description displayed
|
|
|
48 |
|
49 |
-
*Note: this will use the `description` field, **not** the `caption`. Be
|
50 |
-
your document data.*
|
51 |
|
52 |
**Orderby Option**
|
53 |
|
54 |
-
* `menu_order` - This is probably the one you want to use. Order by the
|
55 |
-
Upload Media Gallery dialog. Note that
|
56 |
-
|
|
|
57 |
* `title` - Alphabetical order based on title.
|
58 |
* `date` - Order by date of document upload.
|
59 |
* `author` - Order by the owner of the upload (username).
|
@@ -61,129 +72,208 @@ you must populate the fields before this option will work.
|
|
61 |
|
62 |
**Order Option**
|
63 |
|
64 |
-
This option works alongsied the `orderby` option to determine whether the
|
65 |
-
ascending or decending order.
|
66 |
|
67 |
**Attachment Page Option** *(New in Version 1.1)*
|
68 |
|
69 |
-
This option determines whether each document icon will link to the actual file
|
70 |
-
If you want the user to be able to click on the
|
71 |
-
|
72 |
-
|
|
|
73 |
|
74 |
**Images** *(New in Version 1.2)*
|
75 |
|
76 |
-
This option will tell the plugin to pull all images attached to to a page or
|
|
|
77 |
|
78 |
**Ids** *(New in Version 1.2)*
|
79 |
|
80 |
-
This is an advanced option intended for experienced WordPress users. If this
|
81 |
-
|
|
|
82 |
|
83 |
-
*Note: If this attribute is used, the `order`, `orderby`, and `images`
|
84 |
-
by the order the ids are
|
|
|
85 |
|
86 |
= Customize Appearance =
|
87 |
|
88 |
-
By default, the document gallery will use the styles within your active theme
|
89 |
-
but, with a little CSS knowledge, you can
|
90 |
-
|
91 |
-
|
|
|
92 |
|
93 |
**Example**
|
94 |
|
95 |
-
Say I would like to include a border for the right and bottom of thedocument
|
96 |
-
are shown (to deliniate the icon from the
|
97 |
-
CSS to my
|
|
|
98 |
|
99 |
`.document-icon-wrapper.descriptions .document-icon{
|
100 |
-
|
101 |
-
|
102 |
}`
|
103 |
|
104 |
-
Now, if I wanted to modify that code to instead add the same border to all of
|
105 |
-
whether they have a description or not, I
|
|
|
106 |
|
107 |
`.document-icon-wrapper .document-icon`
|
108 |
|
109 |
-
*NOTE: Please don't modify the plugin stylesheet directly or your changes will
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
-
|
|
|
|
|
|
|
|
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
|
117 |
== Screenshots ==
|
118 |
|
119 |
-
1. This is an example of multiple Document Galleries on a single page (using
|
120 |
-
how images will appear in a Document
|
|
|
121 |
possibilites are endless!
|
122 |
-
2. This is how the Document Gallery looks with `descriptions=true`. The
|
123 |
-
description field from when you
|
124 |
-
|
125 |
-
|
|
|
126 |
|
127 |
== Changelog ==
|
128 |
|
129 |
-
=
|
130 |
|
131 |
-
* Full integration with the new [Wordpress 3.5 Media
|
|
|
132 |
* Option to include player for any music or video attachments uploaded to page.
|
133 |
-
* Option to open documents directly within your browser (à la [Google Drive
|
|
|
134 |
* Support for adding your own filetypes/icons.
|
135 |
-
* Whatever else **you** would like (post on the [support
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
= 1.2.1 =
|
138 |
-
|
|
|
|
|
139 |
|
140 |
= 1.2 =
|
141 |
|
142 |
-
* **New Feature:** Images can now be included alongside documents in a
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
|
|
|
|
|
|
147 |
|
148 |
= 1.1 =
|
149 |
|
150 |
-
* **New Feature:** Included option to link to the attachment page as well as
|
|
|
151 |
* **Enhancement:** Added documentation for customizing the appearance of the plugin.
|
152 |
-
* **Enhancement:** Many improvements to the backend, including pretty HTML output
|
153 |
-
calls to WordPress core functions.
|
154 |
|
155 |
= 1.0.4 =
|
156 |
|
157 |
-
* **Bug Fix:** Removed extra `div` at bottom when number of documents is
|
|
|
158 |
|
159 |
= 1.0.3 =
|
160 |
|
161 |
-
* **Bug Fix:** Resolved issue with detecting plugin directory. (Thanks,
|
162 |
-
|
|
|
|
|
163 |
|
164 |
= 1.0.2 =
|
165 |
|
166 |
-
* **Bug Fix:** Merge for changes in 1.0 did not go through correctly so users
|
167 |
-
|
|
|
168 |
|
169 |
= 1.0.1 =
|
170 |
|
171 |
-
* **Bug Fix:** Resolved issue with long document titles being cut off in some
|
|
|
172 |
|
173 |
= 1.0 =
|
174 |
|
|
|
175 |
* **Enhancement:** Optimized gallery generation (faster!)
|
176 |
-
* **Enhancement:**
|
177 |
-
|
178 |
-
* **Enhancement:** Changed shortcode to `[dg]` (`[document gallery]` will still
|
|
|
179 |
* **Enhancement:** Gave documentation some **much needed** revisions.
|
180 |
|
181 |
= 0.8.5 =
|
182 |
|
183 |
-
* **Enhancement:** Added support for
|
|
|
184 |
|
185 |
= 0.8 =
|
186 |
|
187 |
* **Release:** First public release of Document Gallery.
|
188 |
-
* **Feature:** Displays PDF, Word, PowerPoint, Excel, and ZIP documents from a
|
189 |
-
|
|
1 |
=== Document Gallery ===
|
2 |
Contributors: dan.rossiter
|
3 |
+
Tags: attachments, icons, documents, gallery, ms office, doc, ppt, xls, docx, pptx, xlsx, pdf,openoffice
|
4 |
Requires at least: 2.6
|
5 |
+
Tested up to: 3.5.1
|
6 |
+
Stable tag: 1.3
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
+
This plugin allows the user to easily create a "gallery" of all non-image
|
11 |
+
attachments on a given post/page, making them easy to share.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
This plugin allows the user to effortlessly include a gallery, much like a
|
16 |
+
photo gallery, of all your non-image attachments anywhere within your post.
|
17 |
|
18 |
+
The plugin will, by default, inherit the styling within your active theme, but
|
19 |
+
with a little CSS knowledge it is easily modified to meet your specific needs.
|
20 |
|
21 |
Read more in the **Installation** tab!
|
22 |
|
23 |
+
= Developers =
|
24 |
+
|
25 |
+
Document Gallery includes features intended to make integrating the plugin into
|
26 |
+
the core of your theme or plugin very convenient. See the bottom of the
|
27 |
+
**Installation** tab for specific documentation on the various features included.
|
28 |
+
|
29 |
+
*If this plugin has helped you, please take a moment to [rate
|
30 |
+
it](http://wordpress.org/support/view/plugin-reviews/document-gallery#postform)!*
|
31 |
|
32 |
== Installation ==
|
33 |
|
34 |
1. Upload `document-gallery` to the `/wp-content/plugins/` directory
|
35 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
36 |
+
1. Place `[dg]` in any posts or pages you want a document gallery included. See
|
37 |
+
below for additional display options.
|
38 |
|
39 |
= Document Gallery Options =
|
40 |
|
41 |
+
In order to include all compatible docuements from a given page or post, you
|
42 |
+
must include the following shortcode in the post:
|
43 |
|
44 |
+
`[dg descriptions=[true/false] orderby=[menu_order, title, date, author, rand]
|
45 |
+
order=[ASC/DEC] attachment_pg=[true/false] images=[true/false]
|
46 |
+
ids=[false/comma-separated list of id #s]]`
|
47 |
|
48 |
**Default Values**
|
49 |
|
50 |
+
By default, document gallery will use `descriptions=false`,
|
51 |
+
`orderby=menu_order`, `order=ASC` , `attachment_pg=false`, `images=false`, and
|
52 |
+
`ids=false` if you do not specify otherwise.
|
53 |
|
54 |
**Descriptions Option**
|
55 |
|
56 |
+
If `true`, each document will take its own line with the description displayed
|
57 |
+
alongside it.
|
58 |
|
59 |
+
*Note: this will use the `description` field, **not** the `caption`. Be
|
60 |
+
careful when entering your document data.*
|
61 |
|
62 |
**Orderby Option**
|
63 |
|
64 |
+
* `menu_order` - This is probably the one you want to use. Order by the
|
65 |
+
integer fields in the Insert / Upload Media Gallery dialog. (Note that
|
66 |
+
these fields may be blank by default. If this is the case, you must
|
67 |
+
populate the fields before this option will work.
|
68 |
* `title` - Alphabetical order based on title.
|
69 |
* `date` - Order by date of document upload.
|
70 |
* `author` - Order by the owner of the upload (username).
|
72 |
|
73 |
**Order Option**
|
74 |
|
75 |
+
This option works alongsied the `orderby` option to determine whether the
|
76 |
+
documents are displayed in ascending or decending order.
|
77 |
|
78 |
**Attachment Page Option** *(New in Version 1.1)*
|
79 |
|
80 |
+
This option determines whether each document icon will link to the actual file
|
81 |
+
or to its attachment page. If you want the user to be able to click on the
|
82 |
+
icon and directly rective the option to download then use
|
83 |
+
`attachment_pg=false` (the default). If you have information on the attachment
|
84 |
+
page that you want the link to go to, use `attachment_pg=true`.
|
85 |
|
86 |
**Images** *(New in Version 1.2)*
|
87 |
|
88 |
+
This option will tell the plugin to pull all images attached to to a page or
|
89 |
+
post in addition to all documents.
|
90 |
|
91 |
**Ids** *(New in Version 1.2)*
|
92 |
|
93 |
+
This is an advanced option intended for experienced WordPress users. If this
|
94 |
+
option is used, the plugin will ignore attached documents, instead including
|
95 |
+
all attachments defined by the ids attribute (e.g.: `ids=10,2,4,42`).
|
96 |
|
97 |
+
*Note: If this attribute is used, the `order`, `orderby`, and `images`
|
98 |
+
attributes will be ignored. Order is defined by the order the ids are
|
99 |
+
provided.*
|
100 |
|
101 |
= Customize Appearance =
|
102 |
|
103 |
+
By default, the document gallery will use the styles within your active theme
|
104 |
+
to handle most of the appearance, but, with a little CSS knowledge, you can
|
105 |
+
customize pretty much anything about how it looks. See
|
106 |
+
[`style.css`](http://plugins.svn.wordpress.org/document-gallery/trunk/style.css)
|
107 |
+
for an idea of what will select different elements within the gallery display.
|
108 |
|
109 |
**Example**
|
110 |
|
111 |
+
Say I would like to include a border for the right and bottom of thedocument
|
112 |
+
icon, but only when descriptions are shown (to deliniate the icon from the
|
113 |
+
description text). To do this, I would need to add the following CSS to my
|
114 |
+
theme stylesheet:
|
115 |
|
116 |
`.document-icon-wrapper.descriptions .document-icon{
|
117 |
+
border-right: 1px solid #37824A;
|
118 |
+
border-bottom: 1px solid #37824A;
|
119 |
}`
|
120 |
|
121 |
+
Now, if I wanted to modify that code to instead add the same border to all of
|
122 |
+
the document-icons, regardless of whether they have a description or not, I
|
123 |
+
would just change the first line, removing the descriptions class like so:
|
124 |
|
125 |
`.document-icon-wrapper .document-icon`
|
126 |
|
127 |
+
*NOTE: Please don't modify the plugin stylesheet directly or your changes will
|
128 |
+
be lost when a new version is released.*
|
129 |
+
|
130 |
+
= Developers =
|
131 |
+
|
132 |
+
**Filter document-icon Content**
|
133 |
+
For those unfamiliar with content filters, [here is some
|
134 |
+
documentation](http://codex.wordpress.org/Plugin_API/Filter_Reference) that you
|
135 |
+
should read before continuing.
|
136 |
+
|
137 |
+
Document Gallery implements its own filter, allowing developers to customize
|
138 |
+
the output generated. Specifically, the `div.document-icon` content, including
|
139 |
+
the div itself, the URL to the attachment, the attachment icon, and the
|
140 |
+
attachment title. Hooking into the `dg_doc_icon` filter will allow you to
|
141 |
+
modify any of this content before it reaches your users.
|
142 |
|
143 |
+
Any function using this filter will receive two parameters, the content to be
|
144 |
+
filtered and the ID number of the file represented by the icon in question.
|
145 |
+
If you are implementing something to override the plugin default functionality,
|
146 |
+
it may be useful to be able to query various attributes of the attachment with
|
147 |
+
this value.
|
148 |
|
149 |
+
One example use for this filter, which I have personally used in a project I
|
150 |
+
am working on, will add a query parameter to the end of each attachment url.
|
151 |
+
This parameter, `rid`, specifies the refering page and allows the page
|
152 |
+
receiving the URL to dynamically detect which page ID the link came from.
|
153 |
+
|
154 |
+
`function dg_doc_icon( $icon, $id ){
|
155 |
+
$ptn = '/(.* href=")([^"]+)(".*)/s';
|
156 |
+
|
157 |
+
if( !preg_match( $ptn, $icon, $matches ) || count( $matches ) !== 4 )
|
158 |
+
return $icon;
|
159 |
+
|
160 |
+
if( strpos( $matches[2], '?' ) !== false )
|
161 |
+
return "{$matches[1]}{$matches[2]}&rid=".get_the_ID().$matches[3];
|
162 |
+
|
163 |
+
return "{$matches[1]}{$matches[2]}?rid=".get_the_ID().$matches[3];
|
164 |
+
}
|
165 |
+
add_filter( 'dg_doc_icon', 'dg_doc_icon', null, 2 );`
|
166 |
+
|
167 |
+
Obviously this is just one very specific example, but anything that requires
|
168 |
+
modifying the image tag, the anchor tag, or the title can be handled with this
|
169 |
+
filter. Note that this function does not use the $id value it receives, which
|
170 |
+
is perfectly alright.
|
171 |
|
172 |
== Screenshots ==
|
173 |
|
174 |
+
1. This is an example of multiple Document Galleries on a single page (using
|
175 |
+
the `ids` attribute). It also shows how images will appear in a Document
|
176 |
+
Gallery. Note that the description field supports HTML markup, so the
|
177 |
possibilites are endless!
|
178 |
+
2. This is how the Document Gallery looks with `descriptions=true`. The
|
179 |
+
descriptions are auto-populated using the description field from when you
|
180 |
+
upload the document.
|
181 |
+
3. This is how the Document Gallery looks with `descriptions=false` (default).
|
182 |
+
Note that the display inherits styling from your active theme.
|
183 |
|
184 |
== Changelog ==
|
185 |
|
186 |
+
= Features For The Future =
|
187 |
|
188 |
+
* Full integration with the new [Wordpress 3.5 Media
|
189 |
+
Manager](http://codex.wordpress.org/Version_3.5#Highlights).
|
190 |
* Option to include player for any music or video attachments uploaded to page.
|
191 |
+
* Option to open documents directly within your browser (à la [Google Drive
|
192 |
+
Viewer](https://drive.google.com/viewer)).
|
193 |
* Support for adding your own filetypes/icons.
|
194 |
+
* Whatever else **you** would like (post on the [support
|
195 |
+
forum](http://wordpress.org/support/plugin/document-gallery) if you have
|
196 |
+
ideas)!
|
197 |
+
|
198 |
+
= 1.3 =
|
199 |
+
|
200 |
+
* **New Feature:** It is now possible to filter the HTML produced to represent
|
201 |
+
each individual icon, making it possible to add extra attributes and other
|
202 |
+
modifications on the fly as document icons are generated. This will probably
|
203 |
+
only be of use to developers and people who don't mind getting their hands
|
204 |
+
dirty. *(See bottom **Installation** tab for more details.)*
|
205 |
+
* **Enhancement:** There have been a lot of optimizations to the underlying
|
206 |
+
plugin code to make it run more efficiently and be easier to read, if you
|
207 |
+
are so inclined.
|
208 |
+
* **Enhancement:** Changed how images, when included within the gallery, are
|
209 |
+
generated so that the format of the icon returned now matches the rest of
|
210 |
+
the icons.
|
211 |
|
212 |
= 1.2.1 =
|
213 |
+
|
214 |
+
* **Bug Fix:** Resolved issue with the `ids` attribute in `1.2` not working.
|
215 |
+
Sorry about that!
|
216 |
|
217 |
= 1.2 =
|
218 |
|
219 |
+
* **New Feature:** Images can now be included alongside documents in a
|
220 |
+
document gallery (using `images=true` attribute).
|
221 |
+
(Thanks for the suggestion, Luca!)
|
222 |
+
* **New Feature:** Attachment ids can now be explicitly listed, allowing for
|
223 |
+
documents not attached to a post or page to be included in a document
|
224 |
+
gallery (e.g.: `ids=2,42,57,1`). Note that no spaces should be included.
|
225 |
+
* **Enhancement:** The CSS stylesheet has been enhanced for more flexibility
|
226 |
+
in sizing icons.
|
227 |
|
228 |
= 1.1 =
|
229 |
|
230 |
+
* **New Feature:** Included option to link to the attachment page as well as
|
231 |
+
to the actual document.
|
232 |
* **Enhancement:** Added documentation for customizing the appearance of the plugin.
|
233 |
+
* **Enhancement:** Many improvements to the backend, including pretty HTML output
|
234 |
+
and best practice implementation in calls to WordPress core functions.
|
235 |
|
236 |
= 1.0.4 =
|
237 |
|
238 |
+
* **Bug Fix:** Removed extra `div` at bottom when number of documents is
|
239 |
+
evenly divisible by 4. (Thanks, joero4ri!)
|
240 |
|
241 |
= 1.0.3 =
|
242 |
|
243 |
+
* **Bug Fix:** Resolved issue with detecting plugin directory. (Thanks,
|
244 |
+
Brigitte!)
|
245 |
+
* **Enhancement:** Minor improvement to how linking to individual
|
246 |
+
documents is handled.
|
247 |
|
248 |
= 1.0.2 =
|
249 |
|
250 |
+
* **Bug Fix:** Merge for changes in 1.0 did not go through correctly so users
|
251 |
+
downloaded the old icon set which broke the plugin. Sorry about that, but
|
252 |
+
all is resolved with this release!
|
253 |
|
254 |
= 1.0.1 =
|
255 |
|
256 |
+
* **Bug Fix:** Resolved issue with long document titles being cut off in some
|
257 |
+
* themes.
|
258 |
|
259 |
= 1.0 =
|
260 |
|
261 |
+
* **New Feature:** Plugin now has **36 icons** representing **72 filetypes**!
|
262 |
* **Enhancement:** Optimized gallery generation (faster!)
|
263 |
+
* **Enhancement:** Added fallback to WordPress default icons if you happen to
|
264 |
+
include one of the few filetypes not yet supported.
|
265 |
+
* **Enhancement:** Changed shortcode to `[dg]` (`[document gallery]` will still
|
266 |
+
work for backward compatibility).
|
267 |
* **Enhancement:** Gave documentation some **much needed** revisions.
|
268 |
|
269 |
= 0.8.5 =
|
270 |
|
271 |
+
* **Enhancement:** Added support for
|
272 |
+
[OpenDocuments](http://en.wikipedia.org/wiki/OpenDocument).
|
273 |
|
274 |
= 0.8 =
|
275 |
|
276 |
* **Release:** First public release of Document Gallery.
|
277 |
+
* **Feature:** Displays PDF, Word, PowerPoint, Excel, and ZIP documents from a
|
278 |
+
given page or post. **Feature:** Documents can be ordered by a number of
|
279 |
+
different factors.
|
screenshot-1.png
CHANGED
Binary file
|