/* Plugin Name: THA R2 Hike Gallery Description: Displays a random selection of images from Cloudflare R2 folders using post title as folder name. Version: 1.4 Author: Darren Edwards | Trail Hiking Australia */ // Enqueue simple CSS for the masonry grid and JavaScript for Load More functionality function r2_gallery_enqueue_styles() { echo ''; // Enqueue JavaScript for Load More functionality echo ''; } add_action('wp_head', 'r2_gallery_enqueue_styles'); // Shortcode to display gallery function r2_gallery_shortcode($atts) { global $post; if (!$post) return ''; // Get the post title and remove the colon $folder_name = str_replace([':', '?'], '', $post->post_title); // Remove colons and question marks $folder_name = urlencode($folder_name); // URL encode the folder name $base_url = 'https://tha-gallery-worker.explore-961.workers.dev'; // Your Cloudflare Worker URL $image_list_url = $base_url . '?folder=' . $folder_name . '&page=1'; $response = wp_remote_get($image_list_url); if (is_wp_error($response)) return do_shortcode("[reblex id='112486']"); $body = wp_remote_retrieve_body($response); $images = json_decode($body); if (!$images || !is_array($images)) { return do_shortcode("[reblex id='112486']"); } // Filter out non-image URLs $image_extensions = ['jpg', 'jpeg', 'png', 'gif', 'webp']; $valid_images = array_values(array_filter($images, function($url) use ($image_extensions) { $extension = strtolower(pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_EXTENSION)); return in_array($extension, $image_extensions); })); if (empty($valid_images)) { return do_shortcode("[reblex id='112486']"); } // Limit to the first 10 images for the first page $limited_images = array_slice($valid_images, 0, 10); $output = '
'; $output .= '
'; return $output; } add_shortcode('r2_gallery', 'r2_gallery_shortcode'); Events - Trail Hiking Australia

Events

All Events in Wattle Ridge

Explore Hiking and Outdoor Events Across Australia

Join the hiking community and explore Australia's stunning trails! Our events calendar showcases a variety of hikes led by passionate locals. Whether you're a seasoned hiker or a beginner, there's an adventure waiting for you. Use the Trail Hiking Australia event management tool to create your own hiking event or join one from our calendar. Find out how to use it here.

Loading...