src/web/app/themes/atahualpa/functions/bfa_rotating_header_images.php
changeset 0 505fe5249d9c
child 1 407d5a626a50
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/web/app/themes/atahualpa/functions/bfa_rotating_header_images.php	Wed Dec 04 11:40:06 2019 +0100
@@ -0,0 +1,46 @@
+<?php
+function bfa_rotating_header_images() {
+	global $bfa_ata;
+
+	$files = array();
+	$img_folder = $bfa_ata['ata_images_dir'];
+
+    if(!isset($bfa_ata['ata_images_dir']) 
+    OR ($bfa_ata['ata_images_dir'] == '') ) {	
+       	$img_folder = 'ata-images'; } 
+
+    if($bfa_ata['images_root'] != "wp-content") {
+           $imgpath = get_template_directory() . '/images/header/';
+           $imgdir  = get_template_directory_uri() . '/images/header/';
+        } else {
+           $imgpath = ABSPATH . 'wp-content/' . $img_folder . '/header/';
+           $imgdir  = content_url() . '/' . $img_folder . '/header/';
+        }
+
+		$dh  = @opendir($imgpath);
+		if ($dh == FALSE) {
+			echo $imgpath . ' - ' . $bfa_ata['images_root'] . '<br /><strong><span style="color: #ff0000;">the folder permission or path to your header image folder is incorrect </color></span><br />';
+			return(FALSE);
+		}
+		while (FALSE !== ($filename = readdir($dh))) {
+			if( preg_match('/\.jpg/i', $filename) || preg_match('/\.gif/i', $filename) || preg_match('/\.png/i', $filename) ) {
+		   $files[] = $filename;
+		   }
+		}
+
+		if(isset($bfa_ata['header_image_sort_or_shuffle'])) {
+			if ($bfa_ata['header_image_sort_or_shuffle'] == "Sort") {
+				sort($files); } 
+			else { 
+				shuffle($files); }
+		}
+		
+		closedir($dh);
+
+		foreach($files as $value) {
+			$bfa_header_images[] = '\'' . $imgdir . $value . '\'';
+		} 
+
+return $bfa_header_images;
+}
+?>
\ No newline at end of file