/**
* Include required files - load these first for proper initialization
*/
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly
}
// Define theme paths
define('BUDDY_CHILD_DIR', get_stylesheet_directory());
define('BUDDY_CHILD_INC_DIR', BUDDY_CHILD_DIR . '/inc');
// Initialize error logging
if (!defined('WP_DEBUG')) {
define('WP_DEBUG', true);
}
if (!defined('WP_DEBUG_LOG')) {
define('WP_DEBUG_LOG', true);
}
if (!defined('WP_DEBUG_DISPLAY')) {
define('WP_DEBUG_DISPLAY', false);
}
// Force debug logging regardless of wp-config settings
@ini_set('log_errors', 1);
@ini_set('error_log', BUDDY_CHILD_DIR . '/debug.log');
error_reporting(E_ALL);
// Ensure we can write to our log file
$log_file = BUDDY_CHILD_DIR . '/debug.log';
if (!file_exists($log_file)) {
@touch($log_file);
@chmod($log_file, 0666);
}
// Log startup message to confirm logging is working
error_log('Debug logging initialized - ' . date('Y-m-d H:i:s'));
/**
* Check if Pods plugin is active and working
*/
function is_pods_working() {
if (!function_exists('pods')) {
error_log('Pods plugin is not active');
return false;
}
if (!class_exists('Pods')) {
error_log('Pods class not found');
return false;
}
return true;
}
/**
* Load required files after plugins are loaded
*/
function buddy_child_load_required_files() {
// Define required files and their functions
$required_files = array(
'place-functions.php' => array('get_place_details', 'get_place_schema', 'get_nearby_places'),
'tour-functions.php' => array('get_tour_details'),
'carousel-schema.php' => array('get_carousel_schema')
);
// Check Pods availability
$pods_active = is_pods_working();
if (!$pods_active) {
error_log('Pods plugin not available - some functionality will be limited');
}
// Load required files with enhanced error handling
foreach ($required_files as $file => $required_functions) {
$file_path = BUDDY_CHILD_INC_DIR . '/' . $file;
try {
if (!file_exists($file_path)) {
throw new Exception(sprintf('Required file not found: %s', $file_path));
}
// Include the file
require_once $file_path;
// Verify required functions exist
foreach ($required_functions as $function) {
if (!function_exists($function)) {
throw new Exception(sprintf('Required function %s not found after loading %s', $function, $file));
}
}
error_log(sprintf('Successfully loaded %s and verified required functions', $file));
} catch (Exception $e) {
error_log(sprintf('Error loading required file: %s - %s', $file, $e->getMessage()));
// For place-functions.php, define fallback functions if Pods is not active
if ($file === 'place-functions.php' && !$pods_active) {
if (!function_exists('get_place_details')) {
function get_place_details($post_id) {
error_log('Using fallback get_place_details function - Pods not active');
return array(
'title' => get_the_title($post_id),
'content' => get_the_content($post_id),
'excerpt' => get_the_excerpt($post_id)
);
}
}
if (!function_exists('get_place_schema')) {
function get_place_schema($place_details) {
error_log('Using fallback get_place_schema function - Pods not active');
return '';
}
}
if (!function_exists('get_nearby_places')) {
function get_nearby_places($post_id, $limit = 3) {
error_log('Using fallback get_nearby_places function - Pods not active');
return array();
}
}
}
}
}
}
add_action('plugins_loaded', 'buddy_child_load_required_files', 20);
/**
* Buddy Child Theme Functions
*/
// Add test function to check if logging works
function test_error_logging() {
try {
// Test error logging
error_log('Testing error logging from functions.php');
// Test exception handling
throw new Exception('Test exception from functions.php');
} catch (Exception $e) {
error_log('Caught test exception: ' . $e->getMessage());
}
// Test Pods availability
if (!function_exists('pods')) {
error_log('WARNING: Pods plugin is not active');
} else {
error_log('Pods plugin is active');
}
}
add_action('init', 'test_error_logging', 1);
// Check if Pods is active
if (!function_exists('pods')) {
error_log('Pods plugin is not active - this may cause functionality issues');
}
/**
* Optimize theme performance and SEO
*/
function optimize_theme_performance() {
// Remove unnecessary scripts
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action('wp_head', 'wp_oembed_add_discovery_links');
remove_action('wp_head', 'wp_oembed_add_host_js');
remove_action('wp_head', 'rest_output_link_wp_head');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'rsd_link');
// Disable XML-RPC
add_filter('xmlrpc_enabled', '__return_false');
// Remove jQuery Migrate in frontend
if (!is_admin()) {
add_filter('wp_default_scripts', function($scripts) {
if (!empty($scripts->registered['jquery'])) {
$scripts->registered['jquery']->deps = array_diff(
$scripts->registered['jquery']->deps,
['jquery-migrate']
);
}
});
}
// Optimize WP Query
add_filter('found_posts_query', '__return_empty_string', 10, 2);
add_filter('found_rows_query', '__return_empty_string');
// Add resource hints
add_filter('wp_resource_hints', function($hints, $relation_type) {
if ('dns-prefetch' === $relation_type) {
$hints[] = '//www.google-analytics.com';
$hints[] = '//www.googletagmanager.com';
$hints[] = '//pagead2.googlesyndication.com';
}
if ('preconnect' === $relation_type) {
$hints[] = 'https://www.google-analytics.com';
$hints[] = 'https://www.googletagmanager.com';
}
return $hints;
}, 10, 2);
}
add_action('init', 'optimize_theme_performance');
/**
* Enqueue optimized styles and scripts
*/
function ghostpool_enqueue_child_styles() {
$theme_version = wp_get_theme()->get('Version');
// Dequeue unnecessary parent styles/scripts
wp_dequeue_style('wp-block-library');
wp_dequeue_style('wp-block-library-theme');
// Enqueue parent style with version
wp_enqueue_style('gp-parent-style',
get_template_directory_uri() . '/style.css',
array(),
$theme_version
);
// Enqueue child style with version and parent dependency
wp_enqueue_style('buddy-child-style',
get_stylesheet_directory_uri() . '/style.css',
array('gp-parent-style'),
$theme_version
);
// Add defer to scripts
add_filter('script_loader_tag', function($tag, $handle) {
if (!is_admin() && !in_array($handle, ['jquery'])) {
return str_replace(' src', ' defer src', $tag);
}
return $tag;
}, 10, 2);
}
add_action('wp_enqueue_scripts', 'ghostpool_enqueue_child_styles', 20);
/**
* Add SEO improvements
*/
function add_seo_improvements() {
// Add meta description if not provided by SEO plugin
if (!defined('WPSEO_VERSION') && !defined('RANK_MATH_VERSION')) {
add_action('wp_head', function() {
if (is_singular()) {
$excerpt = wp_strip_all_tags(get_the_excerpt());
if (!empty($excerpt)) {
printf(
' ' . "\n",
esc_attr(wp_trim_words($excerpt, 30))
);
}
}
});
}
// Add Open Graph meta tags if not provided by SEO plugin
if (!defined('WPSEO_VERSION') && !defined('RANK_MATH_VERSION')) {
add_action('wp_head', function() {
if (is_singular()) {
$excerpt = wp_strip_all_tags(get_the_excerpt());
printf(' ' . "\n", esc_attr(get_the_title()));
printf(' ' . "\n");
printf(' ' . "\n", esc_url(get_permalink()));
if (has_post_thumbnail()) {
printf(
' ' . "\n",
esc_url(get_the_post_thumbnail_url(null, 'large'))
);
}
if (!empty($excerpt)) {
printf(
' ' . "\n",
esc_attr(wp_trim_words($excerpt, 30))
);
}
}
});
}
}
add_action('init', 'add_seo_improvements');
/**
* Add image optimization
*/
function optimize_images() {
// Add lazy loading to images
add_filter('the_content', function($content) {
return preg_replace_callback('/ ]+)>/i', function($matches) {
if (strpos($matches[1], 'loading=') === false) {
return ' ';
}
return $matches[0];
}, $content);
});
// Add WebP support
add_filter('wp_get_attachment_image_src', function($image, $attachment_id, $size, $icon) {
if (!is_array($image)) {
return $image;
}
$upload_dir = wp_upload_dir();
$webp_path = str_replace(
['.jpg', '.jpeg', '.png'],
'.webp',
str_replace($upload_dir['baseurl'], $upload_dir['basedir'], $image[0])
);
if (file_exists($webp_path)) {
$image[0] = str_replace(
['.jpg', '.jpeg', '.png'],
'.webp',
$image[0]
);
}
return $image;
}, 10, 4);
}
add_action('init', 'optimize_images');
/**
* Add security improvements
*/
function add_security_improvements() {
// Remove WordPress version
remove_action('wp_head', 'wp_generator');
// Disable XML-RPC
add_filter('xmlrpc_enabled', '__return_false');
// Remove Windows Live Writer manifest
remove_action('wp_head', 'wlwmanifest_link');
// Remove Really Simple Discovery link
remove_action('wp_head', 'rsd_link');
// Add security headers
add_action('send_headers', function() {
if (!is_admin()) {
header('X-Content-Type-Options: nosniff');
header('X-Frame-Options: SAMEORIGIN');
header('X-XSS-Protection: 1; mode=block');
header('Referrer-Policy: strict-origin-when-cross-origin');
}
});
}
add_action('init', 'add_security_improvements');
/**
* Load translation files
*/
if (!function_exists('ghostpool_child_theme_language')) {
function ghostpool_child_theme_language() {
load_child_theme_textdomain('buddy', get_stylesheet_directory() . '/languages');
}
}
add_action('after_setup_theme', 'ghostpool_child_theme_language');
/**
* AdSense Integration
*/
function deploy_adsense_script() {
add_action('wp_head', function() {
echo '';
}, 1);
}
add_action('init', 'deploy_adsense_script');
/**
* GetYourGuide Integration
*/
function add_getyourguide_script() {
echo '';
echo '';
}
add_action('wp_head', 'add_getyourguide_script');
/**
* Affiliate Tracking
*/
function custom_enqueue_script() {
echo '';
}
add_action('wp_footer', 'custom_enqueue_script');
/**
* Custom Post Type Display Functions
*/
// Removed duplicate get_place_details() function - using the one from place-functions.php
// Removed duplicate get_tour_details() function - will move to a separate file
/**
* Custom Taxonomies Display
*/
function get_destination_hierarchy() {
static $hierarchy_cache;
if (isset($hierarchy_cache)) {
return $hierarchy_cache;
}
$terms = get_terms(array(
'taxonomy' => 'destination',
'hide_empty' => false,
'parent' => 0
));
if (is_wp_error($terms)) {
error_log('Error getting destination terms: ' . $terms->get_error_message());
return array();
}
$hierarchy = array();
foreach ($terms as $term) {
$hierarchy[$term->term_id] = array(
'name' => $term->name,
'slug' => $term->slug,
'description' => $term->description,
'children' => get_destination_children($term->term_id)
);
}
$hierarchy_cache = $hierarchy;
return $hierarchy;
}
function get_destination_children($parent_id) {
static $children_cache = array();
if (isset($children_cache[$parent_id])) {
return $children_cache[$parent_id];
}
$children = get_terms(array(
'taxonomy' => 'destination',
'hide_empty' => false,
'parent' => $parent_id
));
if (is_wp_error($children)) {
error_log('Error getting destination children: ' . $children->get_error_message());
return array();
}
$child_terms = array();
foreach ($children as $child) {
$child_terms[$child->term_id] = array(
'name' => $child->name,
'slug' => $child->slug,
'description' => $child->description
);
}
$children_cache[$parent_id] = $child_terms;
return $child_terms;
}
/**
* Schema.org Markup
*/
function add_place_schema() {
if (!is_singular('places')) {
return;
}
try {
$place_details = get_place_details(get_the_ID());
if (empty($place_details)) {
return;
}
$schema = array(
'@context' => 'https://schema.org',
'@type' => 'Place',
'name' => get_the_title(),
'description' => wp_strip_all_tags(get_the_excerpt()),
'url' => get_permalink()
);
// Add address if available
if (!empty($place_details['address'])) {
$schema['address'] = array(
'@type' => 'PostalAddress',
'streetAddress' => $place_details['address']
);
if (!empty($place_details['city'])) {
$schema['address']['addressLocality'] = $place_details['city'];
}
if (!empty($place_details['state'])) {
$schema['address']['addressRegion'] = $place_details['state'];
}
if (!empty($place_details['postal_code'])) {
$schema['address']['postalCode'] = $place_details['postal_code'];
}
if (!empty($place_details['country'])) {
$schema['address']['addressCountry'] = $place_details['country'];
}
}
// Add geo coordinates if available
if (!empty($place_details['latitude']) && !empty($place_details['longitude'])) {
$schema['geo'] = array(
'@type' => 'GeoCoordinates',
'latitude' => floatval($place_details['latitude']),
'longitude' => floatval($place_details['longitude'])
);
}
// Add contact info if available
if (!empty($place_details['phone'])) {
$schema['telephone'] = esc_attr($place_details['phone']);
}
// Add featured image if available
if (has_post_thumbnail()) {
$schema['image'] = array(
'@type' => 'ImageObject',
'url' => get_the_post_thumbnail_url(null, 'full'),
'width' => 1200,
'height' => 630
);
}
printf(
'',
wp_json_encode($schema, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)
);
} catch (Exception $e) {
error_log('Error generating place schema: ' . $e->getMessage());
}
}
add_action('wp_head', 'add_place_schema');
/**
* Custom RSS Feed
*/
function add_featured_image_to_rss($content) {
global $post;
if (has_post_thumbnail($post->ID)) {
$image_url = get_the_post_thumbnail_url($post->ID, 'large');
$content = ' ' . $content;
}
return $content;
}
add_filter('the_content_feed', 'add_featured_image_to_rss');
add_filter('the_excerpt_rss', 'add_featured_image_to_rss');
function add_custom_post_types_to_rss($query) {
if ($query->is_feed) {
$query->set('post_type', array('post', 'places', 'tours'));
}
return $query;
}
add_filter('pre_get_posts', 'add_custom_post_types_to_rss');
// Add admin menu for viewing logs
function add_debug_logs_page() {
add_menu_page(
'Debug Logs',
'Debug Logs',
'manage_options',
'view-debug-logs',
'display_debug_logs',
'dashicons-text',
99
);
}
add_action('admin_menu', 'add_debug_logs_page');
function display_debug_logs() {
if (!current_user_can('manage_options')) {
return;
}
ob_start(); // Start output buffering
echo '
';
echo '
Debug Logs ';
// Get log file content
$log_file = dirname(__FILE__) . '/debug.log';
if (file_exists($log_file)) {
$logs = file_get_contents($log_file);
if ($logs) {
echo '
';
echo '
' . esc_html($logs) . ' ';
echo '
';
} else {
echo '
Log file exists but is empty.
';
}
} else {
echo '
No log file found at: ' . esc_html($log_file) . '
';
// Check if we can create the file
if (@touch($log_file)) {
echo '
Created new log file.
';
error_log('Log file created and initialized');
echo '
Initialized logging. Please check back in a few minutes.
';
} else {
echo '
Could not create log file. Please check directory permissions.
';
}
}
// Add server info
echo '
Server Information ';
echo '
';
echo 'PHP Version: ' . PHP_VERSION . "\n";
echo 'WordPress Version: ' . get_bloginfo('version') . "\n";
echo 'Memory Limit: ' . ini_get('memory_limit') . "\n";
echo 'Max Execution Time: ' . ini_get('max_execution_time') . "\n";
echo 'Document Root: ' . $_SERVER['DOCUMENT_ROOT'] . "\n";
echo ' ';
echo '
';
echo ob_get_clean(); // Output buffered content
}
Private transfer from airport to hotel in Luang Prabang Reviews - Real Journey Travels
Private transfer from airport to hotel in Luang Prabang
Home - Tours - Laos - Private transfer from airport to hotel in Luang Prabang
Description
Nestled in the heart of Luang Prabang, the private transfer from the airport to the hotel offers a seamless and luxurious introduction to this enchanting city. As you disembark from your flight, a professional driver greets you with a warm smile, ready to whisk you away to your accommodation. The journey itself is a feast for the senses, as you soak in the picturesque landscapes and catch glimpses of local life along the way. Your knowledgeable guide is on hand to provide insider tips and fascinating tidbits about the city, setting the stage for an unforgettable stay. This personalized transfer not only ensures comfort and convenience but also serves as a tantalizing preview of the rich tapestry of experiences awaiting you in Luang Prabang.
Key Features:
– Personalized welcome and seamless transition from airport to hotel
– Insightful commentary and local tips from the knowledgeable guide
– Scenic journey offering a glimpse into the local culture and natural beauty
Explore Other Travel Guides & Reviews
No reviews found. Be the first one!
Warning : Undefined array key "related_items" in
/home/u218696733/domains/realjourneytravels.com/public_html/wp-content/themes/buddy/single.php on line
83
Copyright © 2025 RealJourneyTravels.com. All Rights Reserved.