source: trunk/www.guidonia.net/wp/wp-content/themes/atahualpa/functions/bfa_rotating_header_images.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 1.5 KB
Line 
1<?php
2global $options;
3foreach ($options as $value) {
4if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); } }
5
6$selected_header_image = "";
7
8if (file_exists(ABSPATH."/wpmu-settings.php")) {
9
10 ################### images in WP upload folder (on WPMU)
11
12 $header_images_in_wp_upload_folder = m_find_in_dir(get_option('upload_path'),
13 'atahualpa_header_[0-9]+\.(jpe?g|png|gif|bmp)$');
14
15 if ($header_images_in_wp_upload_folder) {
16 shuffle($header_images_in_wp_upload_folder);
17 $selected_header_image = array_shift($header_images_in_wp_upload_folder);
18 $selected_header_image = str_replace(get_option('upload_path'),
19 get_option('fileupload_url'), $selected_header_image);
20 }
21
22}
23
24# If no user uploaded header image files were found, or this is not WPMU
25
26if (!file_exists(ABSPATH."/wpmu-settings.php") OR $selected_header_image == "" ) {
27
28
29 ################### images in /images/header/ (on regular WordPress)
30
31 $files = "";
32 $imgpath = TEMPLATEPATH . '/images/header/';
33 $imgdir = get_bloginfo('template_directory') . '/images/header/';
34 $dh = opendir($imgpath);
35
36 while (false !== ($filename = readdir($dh))) {
37 if(eregi('.jpg', $filename) || eregi('.gif', $filename) || eregi('.png', $filename)) {
38 $files[] = $filename;
39 }
40 }
41 closedir($dh);
42
43 /* Generate a random number */
44 $amount_images = count($files);
45 $number_images = ($amount_images-1);
46 $randnum = rand(0,$number_images);
47
48 /* print the result */
49 $selected_header_image = $imgdir . $files[$randnum];
50
51}
52?>
Note: See TracBrowser for help on using the repository browser.